GPS speedometer and clock
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Shop by category
Shop all componentsCAN is a robust two-wire bus where nodes broadcast short messages with an ID, and every node hears them. An MCP2515 module adds CAN to an Arduino over SPI. In this demo one Uno sends a counter every half second with ID 0x100, and the other prints it on the Serial Monitor and blinks its LED. Once this works, the same wiring is how you start listening to a machine's CAN network.
Do not connect this to a vehicle's bus while driving.
Do not send messages onto a machine you do not fully understand.
Tick anything you already have and the total updates.
MCP2515 CAN bus module with a TJA1050 transceiver
MCP2515 CAN shield with a Sub-D connector for a neater set-up
Follow the colours: red is power, dark grey is ground, blue is a signal.
Power each Uno from its own USB port, and join the two GNDs with a wire if they run from different supplies.
can_sender.inoVerify & upload in Electrolark#include <mcp_can.h>
#include <SPI.h>
MCP_CAN CAN0(10);
byte counter = 0;
void setup() {
Serial.begin(115200);
// The module crystal is 8 MHz or 16 MHz: read it on the metal can and change MCP_8MHZ if needed
while (CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) != CAN_OK) { Serial.println("CAN init failed"); delay(500); }
CAN0.setMode(MCP_NORMAL);
}
void loop() {
byte data[1] = { counter++ };
CAN0.sendMsgBuf(0x100, 0, 1, data); // ID 0x100, standard frame, 1 byte
delay(500);
}
can_receiver.inoVerify & upload in Electrolark#include <mcp_can.h>
#include <SPI.h>
MCP_CAN CAN0(10);
const int INT_PIN = 2;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(INT_PIN, INPUT);
while (CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) != CAN_OK) { Serial.println("CAN init failed"); delay(500); }
CAN0.setMode(MCP_NORMAL);
}
void loop() {
if (!digitalRead(INT_PIN)) { // INT goes low when a frame arrives
long unsigned int id; byte len; byte buf[8];
CAN0.readMsgBuf(&id, &len, buf);
Serial.print("ID 0x"); Serial.print(id, HEX); Serial.print(" data "); Serial.println(buf[0]);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}
Check the SPI wires, 5 V and the crystal setting. An 8 MHz module needs MCP_8MHZ, a 16 MHz one MCP_16MHZ.
Both modules must use the same bit rate, and the bus needs 120 ohm at each end.
Use twisted pair, keep stubs short and lower the bit rate.
Listening only is usually safe, but sending messages to a vehicle can affect safety systems. Do not do it on the road.
Classic CAN reaches 1 Mbit/s over short cables; longer bus lengths need a lower rate.
To test a link, yes. Alternatively, join the module to an existing CAN device and only listen.
5 parts: 2 × Uno R3 CH340G ATmega328p Development Board w/ Micro-USB, 2 × MCP2515 CAN Bus Module TJA1050 Transceiver SPI Arduino, MCP2515 CAN Bus Shield Board w/ SPI & Sub-D Connector, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (can_sender.ino and can_receiver.ino).
About ₹2,002 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How CAN frames, IDs and bit rates work; Using an MCP2515 module over SPI; Why a CAN bus needs 120 ohm termination.
Do not connect this to a vehicle's bus while driving. Do not send messages onto a machine you do not fully understand.
Ideas that reuse this build: RS485 sensor reader. They are listed under Take it further on this page.
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Records where you went every five seconds, ready to open on a map.
Two boards, two radios: press the button at the gate and it rings indoors.
Check temperature, humidity and pressure from any phone on your Wi-Fi.
Learning project. Check every circuit and the datasheet of each part before you power it up.