Controller Area Networks (CANs) dominate the network architecture for automotive system. What was once a difficult to access and obfuscated protocol, CAN has recently become a subject of interest for hobbyists and security experts alike.
Today we’ll be building an automotive CAN interface for Teensy3.6. The Teensy3.6 is a strong contender for a DIY CAN interface as it sports two integrated CAN controllers and over 200K of writable memory space. We can also use the Arduino IDE–and Arduino-based libraries such as FlexCAN–to easily program and interact with the Teensy. Grab the pre-reqs to follow along–
- Teensy3.6 (https://www.pjrc.com/store/teensy36.html)
- 3v3 CAN Transceiver (https://www.amazon.com/SN65HVD230-CAN-Board-Communication-Development/dp/B00KM6XMXO)
- OBD-II Cable Pigtail (something like… https://www.amazon.com/iKKEGOL-Connector-Diagnostic-Extension-Pigtail/dp/B07F16GPMB/)
- Some wires or fancy GPIO cables
- Arduino 1.8.10 ( https://www.arduino.cc/en/Main/Software )
- TeensyDuino (https://www.pjrc.com/teensy/teensyduino.html)
Note: At the time of writing, the latest version of TeensyDuino is compatible with the latest version of Arduino (1.8.10). This may change in the future.
Wiring it all together
This tutorial will continue using a Teensy3.6 with pins & a breadboard. First, insert the Teensy into the breadboard. If following exactly, place the micro-usb end into row #1.
For the purpose of CAN, we are only concerned with the following 4 pins on the left-hand side of the Teensy:
Next, insert the CAN Transceiver. An easy to access location is the very bottom of the breadboard. If following along, align the WaveShare CAN Transceiver so that CAN-TX is inserted into Row #30 as follows.
Then, connect the appropriate wires from the Teensy3.6 to the CAN Transceiver.
- Pin 1 -> Pin 28 (GND)
- Pin 5 -> Pin 30 (CAN TX)
- Pin 6 -> Pin 29 (CAN RX)
- Pin 15 -> Pin 27 (3v3 Power)
Finally, connect the OBD cable to the CAN H & CAN L pins of the CAN Transceiver. Since we’re only interested in these two wires, we can disregard the other 14. Some OBD cables purchased online do not include a labeled pinout. A multimeter may be used to identify which wires correlate with the pins in the OBD-II connector.
Next installment, we will use the Arduino IDE to program our Teensy3.6 to send and receive CAN messages.