Free Canadian Shipping on Orders Over $150!

CANBus Transceiver TJA1050 Breakout Board

C1111

12 items left

Use this board to hack your car's CAN Bus!  This is a TJA1050 CAN Bus transceiver on a breakout board.  

All cars built since 2008 have a CAN Bus.  It is the network on which data is transmitted.  There can be many CAN Busses on a car.  Sometimes they are accessible via your car's OBD2 port, and sometimes you have to find the CAN wires and tap in yourself.

This transceiver board can do nothing on its own.  You need to pair it with a CAN controller.  Fortunately, the Particle Photon and Electron have CAN support from the factory!  They work really well with this little breakout and we have some example code below.

Wiring:

  • TX: connect to D1
  • RX: connect to D2
  • Ground to Ground
  • Vcc to 5V IMPORTANT: if you connect to 3.3V you *may* be able to receive CAN data but you will not be able to transmit
  • CANH to CAN High
  • CANL to CAN low

Example code for the Photon:

Reading CAN messages and printing them to serial out:

CANChannel can(CAN_D1_D2);
const auto canSpeed = 500000;

void setup() {
can.begin(canSpeed);
Serial.begin(9600);
}

void loop() {

CANMessage message;
if(can.receive(message)) {
Serial.println(message.id);
Serial.println(message.len);
}
}

Sending a some CAN messages  In this example we are turning on heated seats and spoofing a BSI module on a 2012 Honda:

CANChannel can(CAN_D1_D2);
const auto canSpeed = 125000; //125000 for Honda BCAN at 125kbps

// Don't block the main program while connecting to WiFi/cellular.
// This way the main program runs even outside of WiFi range.
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);


void setup() {
can.begin(canSpeed);
}

unsigned long lastTransmitTime = 0;
const unsigned long transmitInterval = 20; /* ms */

void loop() {
// Send a message at a regular time interval
unsigned long now = millis();

if (now - lastTransmitTime > transmitInterval) {
CANMessage message;

// A CAN message has an ID that identifies the content inside
message.id = 0x12F8AC9F; //arbitration ID for BSI
message.extended = true;
// It can have from 0 to 8 data bytes
message.len = 1;
// Pass the data to be transmitted in the data array
message.data[0] = 0x08; //message for BSI
// Send the message on the bus!
message.id = 0x12F8B151;
message.extended = true;
// It can have from 0 to 8 data bytes
message.len = 1;
// Pass the data to be transmitted in the data array
message.data[0] = 0x80; //drivers seat button press
can.transmit(message);
delay(500);
message.data[0] = 0x20; //passenger seat button presss
can.transmit(message);
lastTransmitTime = now;
}
}

Feeling more adventurous?  Try out awesome SocketCAN library written by Julien Vanier.  With this library you can use the powerful can-utils suite of tools that works with Ubuntu, Raspbian and most other Linux distributions.  


Collections: Carloop

Type: Automotive



Related Items