Car To Arduino Communication - CAN Bus Sniffing and Broadcasting With Arduino - 4 Steps - Instructables
Car To Arduino Communication - CAN Bus Sniffing and Broadcasting With Arduino - 4 Steps - Instructables
458,180
340
Open Menu
97 circuits
Save PDF workshop
Favorite
craft
cooking
Introduction:
living
Car to Arduino Communication: CAN Bus
Sniffing and Broadcasting With Arduino
outside
Log InSignup
Search
From Wikipedia, the Controller Area Network (CAN) bus is a "vehicle bus standard designed
to allow microcontrollers and devices to communicate with each other within a vehicle
without a host computer." These devices can also be referred to as electronic control units
(ECUs). Essentially the CAN bus is a bunch of linked ECUs within the vehicle that communicate
with each based on a broadcast. Every ECU intercepts every broadcast, but individually decide
whether or not to react to it.
Here's an example:
Let's imagine there's one ECU that controls the brake lights, one ECU that controls the car
horn, and one ECU that controls the braking system. Whenever you blow the horn, the horn
ECU sends a broadcast message out on the CAN bus network to every ECU it is connected to,
including the brake light ECU and the braking system ECU. The brake light ECU intercepts that
broadcast message, but chooses to ignore it because it has no relevance. The brake light ECU is
really only waiting on the message from the brake system ECU. Also, the horn ECU doesn't
react to the braking system ECU.
This broadcast system is broken down into different components; the two most important are
message ID and message data.
For now, think of the message ID as an ECU address. The message data is the content. It is
typically larger than the ID at around 8 bytes long.
Here's an example:
message ID: 620
data: 10 80 FF FF 80 20 00 80
The ECUs communicate with each other over a twisted wire pair holding CAN-high (CAN+)
and CAN-low (CAN-). CAN-high and CAN-low are accessible through the OBD-II port under the
steering wheel. This is how we'll get in!
Pro-tip: Use a wire tracer/tone generator to backtrace to other CAN Bus access points within
your car.
Volkswagon has a good guide to how the CAN Bus network works:
http://www.volkspage.net/technik/ssp/ssp/SSP_238.pdf
Following
Components:
1- Arduino UNO R3
Note2: At the time of this writing, there were only 6 in stock at Sparkfun.
Note3: Sparkfun's CAN Bus shield also has a joystick (up, down, left, right, center), a micro SD
slot, and support for GPS and LCD modules.
Note4: If you're feeling up to it, you can order the parts from Digikey and make your own
using Sparkfun's provided EAGLE CAD drawing.
4- breakable header pins - the CAN Bus shield doesn't include them:
https://www.sparkfun.com/products/116
Assembly:
1- Break headers into 2x8 pin, 2x6 pin, and (optional - 1x4 pin sections)
https://github.com/sparkfun/SparkFun_CAN-Bus_Ardui...
https://github.com/sparkfun/SparkFun_CAN-Bus_Ardu...
See if you can find messages related to the above. Once you do, write the same messages back
out through your Arduino using Step 2. See if you can unlock or lock your vehicle, pop the
trunk, or blow your horn!
Teachers
I hope to share my findings in the future!
back
All
Thanks for reading!
ELA
Math
Micro:bit
2 People Made This Project!
Science
Social Studies
Engineering
MakeyMakey
Coding
Electronics
Robotics
Arduino
CNC
Laser Cutting
3D Printing
3D Design
FermentedOrder
Art
made it! Music renatoaloi made it!
Theatre
Wood Shop
Metal Shop
Resources Did you make this project? Share it with us!
Grades K-2
Grades 3-5
Grades 6-8 I Made It
Grades 9-12
University+
Recommendations
Comment I Made It
97 Comments
It is CRITICAL to add a CAN termination resistor of 120 Ohm that connects the CAN H, CAN
L at the edge.
Contests
Teachers
Reply
2 replies
Reply
1 reply
How can I read and send extended can frames. I have been trying to send message id -
18FEDF00, which gets converted to 700 when it is read. Can someone help me with respect
to what changes should be made to the code above.
Reply
1 reply
Hello friends . Has anyone read the Renault Scenic 2? Can he send me life messages?
Reply
I am trying to use can bus shield to read data from obd2 and then modify some of the data
and then output the modified data to an external device. The external device is normally
connected directly to the can bus plug so the data it receives is from the high and low
cables. My question is once I modify the message via the processing the data in arduino
and using my custom sketch how do I output it back out into the high and low cables from
arduino output so that the external device receives the modified data in the hi / low
format that the external device it’s expecting when it’s connected directly to the ond2
port.
Reply
Reply
I'm working on an opensource project to read board computer data from busses (coaches).
Those non-consumer vehicles have often a modified ODBII port. So we need to hook-up on
the can-bus before that port. As cutting cables is not an option there are those 'Crocodile'
adaptors (this device: ) to snif and read from the Can-H and Can-L cables
Have anyone of you here already experience here and if yes what hardware are you using
to 'copy' the Can-H and Can-L cable data and then hook onto the Arduino?
I added 2 images. Both have the same function to snap over the 2 can cables to copy the
data. 1 is the can-crocodile and the other is the clicq-system of Squarell. The later comes
with a closed "non open-source" hardware system where you depend on the supplier.
Reply
badillivanov 5 years ago
We uploaded the code to the Arduino with the SparkfunShiels, the connection to the car is
directly from Can-H, Can-L, GND to OBDII. We get initialization ok, but no data. We tried
can-speed 500, 250, and 125. We are working on different cars and have tried the same
procedure in different models. Our main goal is though to communicate with BMW E46
(we got information, that because of the K-line, the E46 needs to be connected to CAN via
14 and 8, in stead of 14 and 6 as the other models).
What to do to get the CAN-data?
Thanks in advance.
Reply
1 reply
Hey everyone,
So, I've been trying to do a bit of can-bus hacking and sadly have been running into some
problems.
First of all, when I connect the Sparkfun shield via OBD-|| cable I get no data, I figured
this is due to the gateway not sending any data unless requested. Does anyone know how
to request all data on all the busses?
Secondly, I have had trouble sending messages that give an expected outcome. e.g. I
filtered out all the messages running on the dashboard bus, found the message for
blinking my lights, but when I send the message back on the bus my lights don't turn on.
How could I do this?
Hey can anyone help with my problem? I cant seem to get data. Tried debugging and got
no where. I will attach pictures of the serial monitor and the hardware I have created.
IMG_1182.HEIC
Reply
Does anyone know if this code works with CAN BUS SHIELD V2.0 + Arduino MEGA 2560?
Reply
HI guys. I am starting to write a program about converting CAN data to USB. is there
anyone who did that before? i would be wounder if you comment URL of some document
about it.
All best
Reply
2 replies
Hari2m 6 years ago
Cant we just use the arduino uno or nodemcu directly to read the can messages. Instead of
using the canbus shield?
Reply
Hello evrybody,
I'm trying to hack a CANbus of KTM motorcycle and I don't knew if I can use the tutorial
that you provided above.
Thankyou for any advices.
Reply
Hi, I tried this on my 2003 VW Golf mk4. I had to hookup my shield directly on the bus
wires, located behind the dashboard to be able to read messages. Took me quite a while to
find the right wires. You have to look for a pair of orange twisted cables connected to the
green plug behind the dashboard. There are three orange pairs. Two of which are
Orange/black and orange/brown. You have to use the light coloured pair. Orange/black is
Can H and orange/brown is Can L (at 500kbps). Currently im collecting data and try to
understand it. My goal is to implement cruise control and an active rev matching system,
controlled by a windows 10 pc in the trunk, which is connected to a touchscreen in the
front, replacing the radio and navigation system.
Reply
ChristianS319 6 years ago
Hi! I'm working on a project for my 1996 Saab 900 turbo. I wonder what message.id does.
Is it an identifier that is sent to the ECU and the ECU then responds back with the same
identifier so it's easier to know what it is responding to? Also I would like to know what
message.header.rtr does. The last queston I have (for now) is if I need to do anything else
to make it run at 615 kbps than to edit the Canbus.h file and change CANSPEED in the
sketch?
Regards,
Christian
Reply
I need to transmit and receive specific CAN messages for a project. I have to use a laptop
with Busmaster on one end and the Arduino with the CAN shield on the other. When I
send messages from the Busmaster to the Arduino I get an error. A CAN message isn't
transmitted by busmaster. Is there anything else I need to add to the code?
The setup is a laptop with busmaster sending CAN signals to the shield-arduino through a
USB-DB9 connector. The Arduino is connected via USB to another laptop on whose serial
monitor I wish to read the messages being transmitted by the first laptop. Also do I need to
worry about adding 120 ohm resistors anywhere in this setup? Please help.
Reply
1 reply
I need an Analog 0-5V to CAN converter at work and the cheapest one I can find is about
£400. So I am thinking of going the Arduino route and developing our own.
I have a joystick that outputs in CAN but I cannot use it for reasons, and it is connected in a
forklift truck (which uses CAN to communicate of course)
I have a joystick that outputs in 0-5V which I can use, but of course, I need to translate the
0-5V to CAN exactly as the OEM.
I am kind of struggling to figure out how to do this. Any help would be appreciated.
Reply
1 reply
hello,
Thanks in advance.
My mail id is: [email protected]
Reply
2 replies
DieterW8 6 years ago
Hello,
CAN-Bus Demo
CAN Init ok
1.Speed
2.RPM
3.Throttle
4.Coolant Temperature
5.O2 Voltage
6.MAF Sensor
Vehicle Speed:
Reply
Reply
1 reply
Reply
Reply
Reply
Hello,
I have read your instructable with great interest and have a doubt about the 4 pin headers
needed to connect to the sparkfun can-shield. When are they used in the code? Or the
hi/low information from the obd2 connector passes the information through the db9
connector on the shield? Browsing the code, I get the idea that it is only necessary to
connect the sparkfun can-shield to the arduino and the rest is code.
Reply
Thank you for your helpful guide. unfortunately i have some major problems with getting
no messages, i soldered on the board an using no db9 connector cable, i am using canH
canL and GND you can find an in detail post right here:
http://forum.arduino.cc/index.php?topic=494722.msg...
thank you!
Reply
Hi,
does anyone had a succesful connection with a VW? I connected it over Line 6 and 14 for
CAN high and low. I tried both Sparkfun example CAN_Demo and ECU_Demo but nothing
works. The Serial Monitor shows me only CAN init ok. I also tried different CAN Bus Speed
125, 250 and 500. I tried also the PID Request but that doesn't work too.
Reply
1 reply
Hello,
Reply
Hi,
I tried the SparkFun_CAN_Demo example but the buffer didn't work properly, I received
about 700 rpm in idle, but when accelerating the car I also received the same amount, it
was not until I maintained the rpm high and waited some seconds that when i asked for
the rpm it replied me with about 2000.
I don’t know what am I doing wrong, if someone had the same issue and managed to solve
it please respond to this comment.
Reply
Hey,
I'm facing issues in reading the data from the ECU using that CAN_READ_DEMO example
given in the library. I get data when no filter is applied, as i apply the filter mentioned in
step 2 I get no data at all! i tried applying other filters as mentioned in other comments,
but none of them worked. Please if you can help me with it, im stuck :( .I'm testing the
code on Honda Civic .Here is what i get when applying no filter.
CAN Init ok
Reply
I'm facing a little problem though.. when I use your "all messages" code, I'm getting the
"can init OK" but nothing after that... if I will put the code below inside the loop (including
the "buffer" declaration at the begining) , I'm getting the engine's rpm correctly...
Canbus.ecu_req(ENGINE_RPM, buffer);
Serial.print("Engine RPM: ");
Serial.println(buffer);
Reply
1 reply
I can confirm what @MoniCris has said: Use the GROUND/GND Luke! Also consider cutting
P1 (right above the CAN-H screw)
I had to do both to finally get my first message from the damned shield in my Ford
Mondeo.
Reply
1. In my Skoda Octavia II (2013), the OBD plug have pins 1,4,5,6,14,16. Rest of the pins have
no connection inside. I connect my Can Shield to 6(can H), 14(can L) and GND. I check the
voltage and I have +2,5V on H and +2,5V on L to GND. I use your library and can not
connect to CAN. I change the can speed to get the can error, but nothing. With and without
engine started
2. Between the drivers door and the car, I reach the Convenience can bus lines. I connect
my can shield and works at 100 kbps. I search for another library because the library you
used is not reaching this low speed. I get thousands of frames just locking doors. I found
the frame witch blocking the doors, and sending it back, is doing the job. Making an error
on can speed from 100 to 125 or 500, I get the Christmas tree lights on my car's dash panel
... normal.
But I wish to use the OBD's can lines. Have you any idea what can be wrong? Next days I
will try on an Skoda Fabia (2003).
Thanks
P.S.: To all others, when you connect can bus, you need to connect 3 wires: CAN HIGH, CAN
LOW, and GROUND!!
Cheers
Reply
3 replies
AboutContact
Wrong Category
Inappropriate
Incomplete
Spam
Cancel Confirm
Edit