CAN-Bus access from ESP32 (One+)

Inquiry and support for Freematics products
Post Reply
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

CAN-Bus access from ESP32 (One+)

Post by seb »

H all,

I want to use the One+ to log the complete CAN-Data from the OBD2 Pins 6/14. About 800 messages/second.

But - the CAN-Transceiver in the ONE+ is connected to the STM32, not the ESP32. Therefore, I cannot use the standard ESP32-CAN-libraries (Twai/Can.h). Is there any library to access the CAN-Bus connected to the STM32 via the UART-Communication from the ESP32?

(I'm running FreeRTOS on the ONE+)

Best,
Sebastian
stanley
Site Admin
Posts: 982
Joined: Sat Mar 01, 2014 3:15 am

Re: CAN-Bus access from ESP32 (One+)

Post by stanley »

ESP32 is not automotive level and we found it could cause various issues when accessing a real vehicle's CAN bus.
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

Re: CAN-Bus access from ESP32 (One+)

Post by seb »

Thanks. I was convinced that there must be a deliberate thought behind it.
I just need to send a single message to the CAN-Bus, is there any best practice on how to do this? (Background Info: I need to collect odometer readings for a fleet tracking application; the dongle works fine for Tesla & Polestar 2 with the sniffer library, but for another model I need to send a trigger message to receive the response).
stanley
Site Admin
Posts: 982
Joined: Sat Mar 01, 2014 3:15 am

Re: CAN-Bus access from ESP32 (One+)

Post by stanley »

What's the specific message like to be sent?
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

Re: CAN-Bus access from ESP32 (One+)

Post by seb »

Thanks for the quick reply. Something like this:

268#0010000000000000

That's for example the command to physically close the doors of my Tesla; a very "visual" test. No authentication needed beforehand.
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

Re: CAN-Bus access from ESP32 (One+)

Post by seb »

Any idea how to accomplish this? It could even be with a sequence of AT-commands, whatever works to send a CAN-Message.
It would also help to set the vehicle into diagnostic code.

I had great success using the One+ to collect the odometer and VIN from my Polestar and the Tesla by just using the sniffer sample, for the Mercedes EQA others I would need to send a message, like

cansend can0 7E0#021A905555555555

on linux.
stanley
Site Admin
Posts: 982
Joined: Sat Mar 01, 2014 3:15 am

Re: CAN-Bus access from ESP32 (One+)

Post by stanley »

We are looking into this. The Tesla message seems to be ISO11898 and is currently not supported.
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

Re: CAN-Bus access from ESP32 (One+)

Post by seb »

Thanks for looking into this. It will help me a lot in my project. My customer just placed an initial order of another 10 dongles just to try. My prototype "hack" is to solder a TTL converter to the external pins and then back to 6/14 of the OBD2-Port - to send the command via the ESP32 internal can. But it does not feel right. The rest of the hardware / software stack is so nice, and the 16MB H-Version really makes a difference.
stanley
Site Admin
Posts: 982
Joined: Sat Mar 01, 2014 3:15 am

Re: CAN-Bus access from ESP32 (One+)

Post by stanley »

To send 7E0#021A905555555555

Code: Select all

obd.setHeaderID(0x7E0);
obd.dataMode = 0x1A;
int value = obd.readPID(0x90);
seb
Posts: 8
Joined: Sat Oct 01, 2022 2:34 am

Re: CAN-Bus access from ESP32 (One+)

Post by seb »

Awesome! Thank you!
Post Reply