SAE J1939 is a standardized communication protocol widely used in heavy-duty vehicles, such as trucks, buses, and agricultural machinery. It operates over a Controller Area Network (CAN) bus, enabling seamless communication between various Electronic Control Units (ECUs). This protocol is essential for networking, diagnostics, and data exchange in modern vehicles, ensuring interoperability between components from different manufacturers.
Explore Projects Built with SAE J1939
Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
This circuit is an OBD-II vehicle diagnostic interface that uses an Arduino Nano to communicate with a vehicle's CAN bus via an MCP2515 CAN controller. It includes a 7805 voltage regulator to step down the vehicle's 12V supply to 5V, powering the Arduino and other components, and a 1.44-inch TFT display for visual output. A pushbutton is also included for user interaction.
This circuit features an ESP32-S3 microcontroller interfaced with an SD card, two OLED displays, a GPS module, and a CAN bus module. It records GPS data to the SD card every second, displays speed in knots on one OLED display, and shows wind speed from the CAN bus in NMEA 2000 format on the other OLED display.
This circuit features an ESP32-S3 microcontroller interfaced with an SD card module, two OLED displays, a GPS module, and a CAN bus module. The ESP32-S3 records GPS data to the SD card, displays speed on one OLED, and shows wind speed from the CAN bus on the other OLED, providing a comprehensive data logging and display system.
This circuit is a vehicle safety and monitoring system using an Arduino Mega 2560, which integrates various sensors including a GPS module, GSM module, alcohol sensor, ultrasonic sensor, vibration sensor, and a hall sensor. The system monitors alcohol levels, seatbelt/helmet usage, speed, and vibrations, and can send alerts via SMS and make emergency calls in case of an accident.
Voltage Levels: Standard CAN voltage levels (dominant: 0V, recessive: 5V)
Error Handling: Built-in CAN error detection and correction mechanisms
Pin Configuration and Descriptions
SAE J1939 uses the CAN bus physical layer, which typically connects to a 9-pin Deutsch connector (commonly used in heavy-duty vehicles). Below is the pinout for the Deutsch connector:
Pin
Signal
Description
1
Ground (GND)
Ground connection for the CAN bus
2
CAN_L
CAN Low signal
3
Shield
Shielding for noise reduction
4
Battery (+)
Positive power supply
5
CAN_H
CAN High signal
6
Reserved
Reserved for future use
7
CAN Termination
Optional termination resistor connection
8
Key Switch Power
Power controlled by the ignition switch
9
Reserved
Reserved for future use
Usage Instructions
How to Use SAE J1939 in a Circuit
Connect the CAN Bus: Use a CAN transceiver (e.g., MCP2551 or SN65HVD230) to interface the microcontroller with the CAN_H and CAN_L lines.
Power the Circuit: Ensure the CAN bus is powered with the appropriate voltage (typically 12V or 24V in vehicles).
Termination Resistors: Place 120-ohm termination resistors at both ends of the CAN bus to prevent signal reflections.
Microcontroller Setup: Configure the microcontroller to use the CAN protocol with a 29-bit identifier and the appropriate baud rate (250 kbps or 500 kbps).
Message Transmission: Use the J1939 protocol stack to format and send messages. Each message includes a Parameter Group Number (PGN), source address, and data payload.
Important Considerations and Best Practices
Network Topology: Keep the CAN bus wiring as short as possible to minimize signal degradation.
Shielding: Use shielded twisted-pair cables to reduce electromagnetic interference (EMI).
Addressing: Ensure each ECU on the network has a unique address to avoid conflicts.
Diagnostics: Regularly monitor the CAN bus for error frames and address any issues promptly.
Example: Connecting SAE J1939 to an Arduino UNO
Below is an example of how to use an Arduino UNO with an MCP2515 CAN module to communicate using SAE J1939:
#include <SPI.h>
#include <mcp_can.h>
// Define the SPI CS pin for the MCP2515 CAN module
#define CAN_CS_PIN 10
// Initialize the MCP_CAN object
MCP_CAN CAN(CAN_CS_PIN);
void setup() {
Serial.begin(115200); // Start serial communication for debugging
while (!Serial);
// Initialize the CAN module at 250 kbps (SAE J1939 standard baud rate)
if (CAN.begin(MCP_ANY, 250000, MCP_8MHZ) == CAN_OK) {
Serial.println("CAN module initialized successfully!");
} else {
Serial.println("Error initializing CAN module.");
while (1);
}
// Set the CAN module to normal mode
CAN.setMode(MCP_NORMAL);
Serial.println("CAN module set to normal mode.");
}
void loop() {
// Example: Send a J1939 message with PGN 65280 (0x00FF00)
unsigned char data[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
unsigned long id = 0x18FF00E5; // 29-bit identifier (PGN + source address)
if (CAN.sendMsgBuf(id, 1, 8, data) == CAN_OK) {
Serial.println("Message sent successfully!");
} else {
Serial.println("Error sending message.");
}
delay(1000); // Wait 1 second before sending the next message
}
Troubleshooting and FAQs
Common Issues and Solutions
No Communication on the CAN Bus:
Verify the wiring connections, especially CAN_H and CAN_L.
Check the termination resistors (120 ohms at both ends of the bus).
Ensure all devices on the network are configured with the same baud rate.
Error Frames on the CAN Bus:
Inspect the cable shielding and grounding to reduce EMI.
Confirm that no two devices have the same address.
Arduino Fails to Initialize the CAN Module:
Ensure the SPI connections between the Arduino and MCP2515 module are correct.
Verify the MCP2515 module's crystal frequency (e.g., 8 MHz) matches the library configuration.
Message Not Received by Other ECUs:
Double-check the message ID and PGN formatting.
Confirm that the receiving ECU is configured to accept the specific PGN.
FAQs
Can SAE J1939 be used with 12V systems?
Yes, SAE J1939 is compatible with both 12V and 24V systems, commonly found in light and heavy-duty vehicles, respectively.
What is the maximum cable length for a J1939 network?
The maximum recommended length is 40 meters, but this may vary depending on the baud rate and cable quality.
Is SAE J1939 backward compatible with CAN 2.0A?
No, SAE J1939 uses the extended 29-bit identifier, which is not compatible with the 11-bit identifier used in CAN 2.0A.
Can I use SAE J1939 for non-automotive applications?
Yes, while it is designed for heavy-duty vehicles, SAE J1939 can be adapted for other industrial applications requiring robust communication over CAN.