Hacking car's CAN bus, ESP32 goes into bus-off mode due to errors

Hi all !
I use ESP32 with SN65VHD230 transceiver to hack CAN bus in my car. I already developed working code which was tested with Arduino + MCP2515. But after switch to ESP32, code started to act weird. It sometimes worked properly and sometimes didn't work at all(without any changes in code). So i investigated alert flags and i realised that ESP32 see errors at CAN bus and in result it go to "error passive" state and into "bus-off" state in the end.

My app send my own prepared text to the car's display, so at once there can be 2 nodes sending message with same ID - original display and ESP32. So my theory is that i get bit errors, because when car's display and esp32 are sending message at once with same ID then ESP32 is checking transmited bits and if it will get message from car's display with opposite bit state then it produces error flag.

The weird thing is that, sometimes (very rarely) i still got errors but ESP32 is not going to bus-off state even after long time. Today i got 1000+ errors count at the bus and it still was working well. My theory is that original display in my car is getting errors too and it just got bus-off state before ESP32.

So here is my question - as i can't prevent original display from sending its own messages is there any way to prevent ESP32 going into passive error and bus-off states ? Or maybe to implement error counter clear in main loop() ? Please help me, i'm already out of ideas and don't know what i can do next.

Hi, SN65VHD230 brakeout board from Ali / China ?
I had only problems with these , one from 4 was completely dead, other 3 with weird CAN low level.
Maybe here is the problem ?

It sounds like you are trying to connect to a CAN FD network and your ESP does not know about them.

@ zzila
Yes, ecactly my first transceiver was from China and didn't work at all. That's why i bought 2 more (not from China this time). So transceiver is triple checked. At the moment i ordered second ESP32 because i suspect that built-in SJA1000 controller might be broken and i haven't got any other ideas. (but i doubt it because it give me errors only when i try to send "LCD frame")

@gilshultz
My CAN bus is classic bus (constant 95 kbps), not FD type. But thank you for idea, because i didn't heard about it before.
.

Can you post a simple schematic, I do not think I can help as I use the Arduino and the MPC2515 modules from China. So far I have had no problems once I figured how to connect them. The ESP devices have limits on some of the pins, I do not use them often and always have to look them up. Thinking on paper what happens if you run it with the LCD but do not connect it. It is highly unlikely it is bad but you never know. The other thing is to check the bus levels and impedance. With everything powered down it should be about 60 Ohms regardless if two or more units are connected. It is possible you are not terminated properly and that could also cause this. Let us know how you do.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.