-
• #2
Ok, found the GitHub issue [1] referencing CAN support. And I definitely would go crazy about that :-) I already tried fiddling with an MCP2515 and a raspberry pi, but that setup is complicated and it needs way too much peripheral stuff to place them all somewhere in the car.
-
• #3
A11/A12 are used for USB (they're the only available pins), and D0/D1 are the only available pins for the crystal. B8/B9 seem to be available though - and on pins:
http://www.espruino.com/ReferenceESPRUINOBOARD
If someone wants to put the effort in to add CAN support to the software (it may really not be too hard, and all source is available) then I'd love to include it. At the moment I'm afraid I just don't have time to implement it myself though.
The problem really is who will actually use it...
The main use case for it seems to be to look at OBD signals from car engines - but to be honest you can buy an OBD-Serial adaptor that handles multiple protocols (ELM323) ready-wired with the connector for a few pounds on eBay - and Espruino will happily talk to the ELM323 as-is via the USART...
-
• #4
Well. Three year old thread. Did anything ever happen with this?
Here's why: CAN bus communication is part of my bigger project (which involves WS2812B lightstrip control as well, as some of you know from my other postings).
I got one of these on Amazon, 8 bucks:
CHENBO(TM) Smart Electronics MCP2515 CAN Bus Module TJA1050 Receiver SPI
I've been studying the datasheet for MCP2515, and there is an Arduino library for accessing this chip to reference. So, if no one else has implemented anything with the MCP2515 to interface with CAN, I guess I'll be contributing a module to the community soon...
If there is already code out there, a pointer would be greatly appreciated!
@Gordon: Much more than just OBDII (diagnostics). Virtually everything that happens in a modern car is sensed and controlled via messaging over CAN and LIN digital master/slave buses. Once on the CAN bus, it's possible to have an Espruino do all sorts of neat things. Controlling windows; entertainment; lighting; and on and on. Access to every parameter the car either senses or synthesizes.
-
• #5
Well well well... I just bothered to quickly review the STM32 datasheet, and see that there is a full-blown CAN state machine built in, functionality very similar to the MCP2515 above. I now understand Gordon's comments in this thread better.
So... abandoning the MCP2515 for the first go-around; I'm going to try and use the built-in CAN controller, configured on two of the GPIO pins on my Pico. I hope to succeed and be able to contribute a CAN module to the community here.
-
• #6
I think CAN is only available on the STM32F103 (the original Espruino) and not the F401 in the Pico?
I'd really recommend trying the MCP2515... It looks good. I could be wrong, but it seems like you probably want some kind of line driver chip as well - so if you're wiring an extra chip up you might as well just use one of those CAN modules with the MCP2515 on too?
It'll also be a lot quicker to develop as you can write the whole MCP2515 driver in JS.
My point about the ELM323 was just that if you're plugging in via an OBD2 plug, it's actually cheaper to buy the whole plug + ELM323 than it is to buy the plug and wire it up yourself :)
-
• #7
Good points, and I didn't consider that the Pico has an M4. Also, I do have the Chenbo board, which has the line drivers on it already so can wire right in to the bus in my car. Changing my mind again :-)
reRe: ELM323 -- ah, got ya now. I need to do this anyway for the lighting project I'm working on, so I've got to bite the bullet.
The specification for the Espruino board states that A11, A12, D1 and D2 are not connected to connectors. Does that mean that there is no other way than soldering cables directly to the controller to get these pins?
Is there any support for the CAN bus planned in the JavaScript API?