OBD-II Engine RPM Simulator

To make it easier to test and debug the CAN bus code, you can save some time using this simulator. It's a lot easier than dragging your laptop out to your car!

Simulator

What you will need:

The reason for Gen 2 is that most CAN interface breakouts are 5V. Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM) only support 3.3V logic. There are some 3.3V CAN breakouts if you want to use a Gen 3 device, but I didn't test that.

Connect the outer pins to 3V3 and GND. Connect the inner (wiper) to A0, the orange wire in the picture above.

Interface

Label Color Photon
INT Yellow A1
SCK Green A3 (SCK)
SI Blue A5 (MOSI)
SO Purple A4 (MISO)
CS Gray A2 (CS)
GND Black GND
VCC White VIN

Note that the CAN interface is powered by VIN, which is only powered when using USB power. On the Electron, you can't power using LiPo as 5V is required for the CAN interface.

On this board, it's also necessary to put a jumper on J1. That's the CAN termination resistor enable, and there should be a termination resistor on both ends of the CAN bus.

Pin Purpose Color
5 Signal Ground (optional) Yellow
6 CANH Green
14 CANL Brown/White

Note that CAN bus is differential and consists of two lines:

As the signals are differential you don't need to connect GND for CAN bus.

When using the simulator you will probably need to add a 120 ohm termination resistor on the Tracker end as well as enabling it on the breakout module.

As the wires on the J1962 cable are a small wire gauge, I soldered some Dupont wires on the ends to make they fit in the screw terminals more securely, but this is optional. Some extra solder on the ends of the wires would probably do the trick as well.

if(CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_8MHZ) == CAN_OK)

Usage