I try to connect to my car to sniff the packages that are travelling through the can bus for a future development to get state of charge information from the car (e-car) and forward it via mqtt to openHAB on the local wifi network.
For that I tried to use a wemos d1 mini with MCP2515 and this library: GitHub - gdrapp/WemosMcp2515Gateway: Gateway using WeMos D1 mini and MCP2515 CANbus controller using WiFi and http
It uses the MCP_CAN_LIB from CORYFLOWER under the hood to establish connection to the car with the help of MCP2515 device. Init executed successfully every time I tried, but I cannot see any incoming messages and what the bigger problem is it generates issues with the car like a lot of errorcodes.
I have tried it with '12 Opel Ampera (same as Chevy Volt) where the errors were only transient and could be eliminated with a battery off/on, but I have also tried on my Nissan Leaf ('14) as well and here the problems seems persistent and cause much trouble: power steering, DSC, ventillation, A/C, seems not working at all and the onboard computer has issues too along with a lot off errorcodes!
Could you give me an advice why it has happened (and what can I do to avoid such issues in the future) and most importantly what could I do to reverse these issues in the car??? Now the car although runs but it is barely functioning.
Thank you very much in advance!
I will take a SWAG and ask you to remove the termination jumper on your module. I had the same problem but not with a car.
Are you using a MCP2515/transceiver module that is designed to be powered by 5v?
Picking the wrong baud rate will cause CAN bus errors.
wow, thank you for the suggestion! I will try it today.
Yes, I am using MCP2515 transceiver with 5V. I use it with a voltage regulator. The baud rate I am using is 500kbps which is from what I have found that uses a Leaf.
The other question also applies what to do whit the car now? Is there a trick maybe to solve the already created errors (I have already tried to delete the errorcodes via OBD2 connector but they come back and also tried to reset ECUs by removing cables from battery for a few hours without success), or just bring it to the dealer?
Check your can settings and be sure the crystal settings are correct. I am using the mcp_can.h library. Also the slower you run it the less likely you will have problems. The defaults were 500 but I changed my to 250 and a 8 Mhz crystal as that is what my MCP2515/transceiver module had.
Thank you for the replies! At last I have checked the physical connections once again and it must have been a short somewhere as rebinding the wires eliminated these issues (at least part of them).
It turned out that the permanent errors that the Leaf had caused by a dead fuse and this is caused probably because of an insulation issue among the wires.
Although CORYFLOWER CAN library still causes temporary errorcodes in the car but after switching to another one (SANDEEP MISTRY) the errors don't appear anymore.
Now my problem is that although I receive CAN messages after starting the device but sniffing the messages either stops after an initial 20-30printed messages or only prints RTR message after this initially printed 20-30messages. I am not even sure if this initial messages are correct as if I print out the data in char format it is visualized as garbage (random ASCII characters not even numbers).
I have doublechecked the connections and the wiring but these seems to be ok. Do you have a gint on what can be wrong here?
Many cars use both 11 and 29 bit identifiers, can your code process both? Try printing in HEX format, that will make it easier to read as ASCII generally means nothing in a vehicle.
To avoid creating errors on the bus I would recommend to use Listen-Only mode of the MCP2515. This should allow you to receive all messages but your node will not take part of in the CAN protocol verification. Every active node will listen to all communication and create an error on the bus when it sees a protocol error. When your bitrate is not set correctly the CAN controller will see all messages on the bus as incorrect and create errors until the error counters are too high. Then it will assume it is faulty itself and stop for a while.
Depending on your library you may need stop your library from switching into Normal mode and set Listen-Only mode instead.
If you want to send CAN messages from your node you will need to use Normal mode.
Now I have figured out why MCP2515 stopped outputting the messages (why it stopped working): it does not like to be fed from a voltage regulator... When I powered it from the arduino I have tested with eventually then it worked like a charm. I do not really understand why this is the case? Arduino provides 4.95V, voltage regulator 5.05V. MCP should be good up to 5.5V - according to the datasheet...
Post the regulator circuit schematic, not a frizzy thing. I will take a SWAG and say the regulator is not bypassed properly.
Well, I use a regular LM7805 for this purpose.
In the meantime I have also tried to feed the MCP2515 from 5V DC adapter that providesd 5,4V when measured. Result is the same: messages starting to appear in canhacker but only a few of them (the exact number varies for each attempt from e.g. 5-50messages) and then stops working.
In the beginning I have experimented with DC/DC stepdown to set the 12V voltage that comes via CAN to 5V (at that time it was like 5,05V) but the result was the same.
However when I plug it into the arduino's 5V output then it works flawlessly!
I need to see the schematic complete with all components and connections. Does anything get hot? Without a reliable power source it will not be reliable. This can become the proverbial dog chasing its tail.
The connections are the following (mcp2515 - arduino):
-INT - 2
- SCK - 13
- SI - 11
- SO - 12
- CS - 10
- VCC - LM7805 3rd leg
- GND - LM7805 2nd leg
(12Vinput: positive - LM7805 1st leg, negative - LM7805 2nd leg).
Why do you think that the car's battery, or a 12V adapter is not reliable?
So your LM7805 does not have the capacitors around it? That's why @gilshultz asked for the regulator schematic.
The problem is the electronics world is more complicated than this is a 12V adapter and it can provide 5A of current. These values are rating for a constant current. It does not tell you how fast the power supply can adapt to current changes.
So, while the power supply might be able to drive a motor with 4A it may not be able to provide 100mA for a 1µs pulse. Capacitors can be used to provide short bursts of current to a digital circuit while the power supply will then only charge the capacitor at a slower rate.
This is true not only for power supplies but every element in your circuit. A wire is not just a resistor it has an inductive element that depends on length and frequency as well.
Check the datasheet of components you are using for recommended circuits and PCB layouts. When it is critical the datasheet will often tell you to place the component as close as possible to certain pins.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.