Site Information

 Loading... Please wait...

Monitoring SAE J1939 Data Using The Raspberry Pi Plus PiCAN2 CAN Bus Interface Board

Posted by Wilfried Voss on

Monitoring SAE J1939 Data Using The Raspberry Pi Plus PiCAN2 CAN Bus Interface Board

During the past years, we have received multiple inquiries in regards to creating an Electronic Logging Device (ELD) using the Raspberry Pi in combination with our PiCAN2 CAN Bus interface board, where the PiCAN is being used to monitor SAE J1939 data.

The mere monitoring of SAE J1939 data (Parameter Group Numbers - PGN) is fairly easy, since it does not require the installation of an SAE J1939 protocol stack. Rather, all you need to do is reading CAN data frames using a 29-bit message identifier. Also, the majority of J1939 PGNs contain 8 data bytes, and their interpretation is documented in the SAE J1939 - 71 Standard.

For more information, see also the SAE J1939 Digital Annex.


An electronic logging device (ELD) is electronic hardware that is attached to a commercial motor vehicle engine to record driving hours. The driving hours of commercial drivers (truck and bus drivers) are regulated by a set of rules known as the hours of service (HOS).

An ELD is a device that:

  • Records a commercial motor vehicle’s driving time
  • Records the driver’s hours of operation
  • Is synchronized with the engine of the vehicle
  • Monitors engine data such as:
    • Engine power status
    • Vehicle motion status
    • Miles driven
    • Engine hours

Things become a bit more complicated, when you need to monitor data that are only available on request. In that case, you will need to install an SAE J1939 protocol stack. The protocol stack will allow you to claim a node address (either a specific, user-defined address or assigned/determined by the protocol stack), which will allow you to send a Request message.

At the time of this writing, I have not been aware of an SAE J1939 protocol stack specifically designed for the Raspberry Pi. There are many offers in the marketplace for generic protocol stacks written in C for embedded systems, but they are extremely expensive, i.e. in the range of several thousands of dollars.

The only solution for implementing a full SAE J1939 protocol stack on the Raspberry Pi comes in form of our SAE J1939 Turbo Interface for Raspberry Pi, but that would require switching away from the PiCAN2 board and its additional features such as GPS, Accelerometer, etc.

However, before I go into a solution without protocol stack, let's have a look at the Request message:

  • PGN 59904 (0x00EA00)
  • Requests a Parameter Group Number from a single device or all devices in the network
  • Data Length: 3 Bytes
  • Data Description: Byte 1, 2, 3 = Requested PGN - LSB first

In order to request a PGN (in this sample we are using Engine Hours = PGN 65253, 0x00FEE5) you need to pass the following data:

  • Message ID = 0x18EAFFxx, where xx is the requestor's node address (hex). 0x18 indicates a priority = 6, 0xFA indicates the request, 0xFF indicates the responder's node address, in this case 255 to address all devices in the network.
  • Data 1, 2, 3 = 0xE5, 0xFE, 0x00, the PGN for Engine Hours

In case of the PiCAN2 board, you can use the command line:

./cansend can0 18EAFF80#E5FE000000000000

In this example, I used node address 128 = 0x80.

To make it a point again, you will need a node (source) address in order to be able to send the request. Things are easy when you know your network's node architecture, i.e. all the node addresses used. In that case, you simply assign an address that is not being used.

If you don't know the address structure in your network, you can also send out a Request for Address Claimed but that requires some intimate knowledge of the SAE J1939 Standard. Of course, you can experiment with assigning node addresses, but please be aware that the impact on the network will be unpredictable and may have serious consequences.

A professional approach to reading SAE J1939 per Raspberry Pi with PiCAN2 CAN Bus interface board comes down to:

For instance, our SAE J1939 Simulator & Monitoring board, in combination with the free-of-charge jCOM1939 Monitor software, allows you to scan your vehicle network and determine all node addresses. It also allows you to simulate any PGN, even those who are only available per request. Too many users forget that you need a second CAN node to create a network using the PiCAN2 board, and our J1939 board can simulate an entire network.

And yes, you can connect your PiCAN directly to your vehicle, but chances are that you will run into obstacles that can be resolved far faster with our J1939 simulator.