Why this happens
The MCP2515 is a common CAN controller that talks to a microcontroller over SPI, and many modules pair it with a transceiver. It has a listen-only mode, which receives frames without transmitting or acknowledging them. That makes it a good, cheap learning tool, as long as it stays on a bench and is never used to send messages on a vehicle.
What you need
Tools
- Soldering iron and solder
- Digital multimeter
- Laptop with the Arduino IDE and a serial monitor
- Bench power supply with current limit
Materials
- Arduino Uno or Nano
- MCP2515 CAN module with transceiver
- A second microcontroller board with a CAN module to act as a test sender
- Twisted-pair wire and jumper wires
- Two 120 ohm resistors (or module termination jumpers)
- Inline fuse and fire-safe mat
Before you start
- Keep the sniffer on your bench network; never connect it to a vehicle that is ridden or driven.
- Never add transmit, replay or injection code for use on a vehicle; it can interfere with brakes, throttle or battery protection.
- Power the bench from a current-limited supply with a fuse, not from an EV battery.
- Accessing a vehicle's internal network usually means opening covers, which can void the warranty.
Step by step
- 1
Identify your module's crystal
Read the marking on the small crystal on the MCP2515 module: common values are 8 MHz and 16 MHz. The library needs the correct crystal frequency to calculate bit timing. If it is set wrong, the module will run at the wrong bit rate and see only errors. Write the value on the module with a marker so you do not forget.
- 2
Wire SPI and power
Connect the module's SPI pins to the Arduino: SCK, MOSI, MISO, chip select to a digital pin, and the interrupt pin to an interrupt-capable pin. Power the module from the Arduino's supply pins and connect grounds. Check the module's supply requirements; some transceivers need 5 V while the controller logic level must suit your board.
- 3
Build the bench bus
Program the second board as a test sender that transmits a few frames with known IDs and data, such as a counter and a simulated temperature. Connect CAN-H to CAN-H and CAN-L to CAN-L between the two modules with twisted-pair wire. Enable termination at both ends and confirm about 60 ohms between CAN-H and CAN-L with the power off.
- 4
Install the library and set listen-only
Install a maintained MCP2515 library in the Arduino IDE. In your sketch, initialise the controller with the correct crystal and bit rate, then set listen-only mode rather than normal mode. Do not include any send functions in the sniffer sketch at all. That way, even a mistake in the code cannot put frames on the bus.
Tip: Print the controller mode at start-up so you can see it is in listen-only.
- 5
Print frames over serial
In the main loop, when a frame arrives, print a timestamp, the ID in hexadecimal, the data length and each data byte. Use a high serial baud rate so printing keeps up with the bus. Power the bench with the current-limited supply, open the serial monitor and check that frames from your sender appear at the expected interval.
- 6
Troubleshoot errors
If nothing appears, check the crystal setting, the bit rate on both nodes, CAN-H and CAN-L wiring and termination. Note that in listen-only mode, if your sniffer and the sender are the only nodes, the sender gets no acknowledgement and may retry or stop; add a third receiving node in normal mode so the bench bus behaves like a real network.
- 7
Decode and log
Copy the serial output to a CSV file and open it in a spreadsheet. Because you wrote the sender, you know what each byte means: check that the counter increments and the temperature scales correctly. Practise filtering by ID in the sketch. Keep a table of IDs and signal meanings, which is the same method used to document real networks.
How to tell it worked
The sniffer starts in listen-only mode, prints every frame from your bench sender with correct IDs and data, and causes no errors on the bus.
Stop and call a technician if
- Any bench node resets or reports bus-off when the sniffer is connected; check wiring before going on.
- A module or the supply wiring gets hot.
- You are asked to use the sniffer to change, unlock or tune a vehicle's behaviour.
Questions
Why do I only see errors?
The crystal frequency or bit rate in the sketch usually does not match. Check the crystal marking and make sure both nodes use the same bit rate.
Can I plug this into my e-scooter's diagnostic port?
Not on a vehicle you ride. Use the manufacturer's tools or a service centre for vehicle diagnostics, and keep this build for bench learning.
