Site Information

 Loading... Please wait...

SAE J1939 Project With Arduino Uno/Mega2560: Requesting & Simulating Vehicle Identification Number (VIN)

Posted by Wilfried Voss on

Arduino Uno with CAN Bus Shield plus jCOM SAE J1939 ECU SimulatorThis post describes an Arduino project (sketch) that requests the Vehicle Identification Number (VIN) from an SAE J1939 vehicle network. Before I go into the technical details, let me describe the hardware configuration.

First, as shown in the picture, I used an Arduino Uno with a  CAN Bus Shield. In order to simulate the SAE J1939 vehicle bus, I used our SAE J1939 ECU Simulator Board With USB Port in combination with the jCOM1939 Monitor software.

Download the Arduino Sketch

The Arduino Sketch will work with the Uno and the Mega 2560. Use the settings in the ARD1939.h file to optimize it for the board you use. The Mega 2560 comes with more memory resources than the Uno and is thus better suited to support the full SAE J1939 protocol, while working with the Uno comes with some minor restrictions.

And yes, the sketch comes with a full-blown SAE J1939 protocol stack (however, in a pre-compiled form). For more information on the stack and how to use it refer to  SAE J1939 ECU Programming & Vehicle Bus Simulation With Arduino. Another valuable resource is Controller Area Networking with Arduino.

In short, the sketch uses a node address of 128 (can be modified in the code) to start the address claim process. After successful address claim, the sketch requests the VIN once per second. When the VIN has been received, it prints the result on the Serial Monitor.

=> Click here to  download the Arduino Sketch (zip)...

Setting up the SAE J1939 Simulation

I will not go into all the details of our  jCOM1939 Monitor, since that is already sufficiently documented. Nevertheless, here are a few screen shots related to the current project.

First of all, after the Arduino Uno/Mega was functional (i.e. the sketch has been compiled and loaded), I assigned node address 130 (just a random number) to the ECU simulator. Then I accomplished a network scan through our jCOM1939Monitor software:

As the image shows, there are two J1939 nodes in the network: Node 128 represents the Arduino Uno and 130 represents the ECU simulator. The scan confirmed the proper working of the network.

In a next step, I set up the transmission of the VIN. According to the SAE J1939/71 standard, the VIN is of variable length of up to 200 characters, which involves the J1939 Transport Protocol (TP; transport of messages longer than 8 bytes).

In the above example, I chose a random VIN terminated with an ASCII delimiter (*) according to the PGN description. Since the VIN is only transmitted after a request, I chose "On Request" as the transmission rate.

The following image shows the data as received and transmitted by the ECU simulator:

Line #1 shows the address claim transmitted by the Arduino Uno, followed by a request for the VIN. The ECU Simulator responds by sending the VIN (PGN 65260). The request and VIN transmission are repeated every one second.

Last, but not least, let's have a look at the Arduino's Serial Monitor:

The result is the same as displayed by the jCOM1939 Monitor software, where a PGN of 0xFEEC represents 65260 decimal.

If you have any questions or need more information, please feel free to contact me through the  Contact Us form on this website.

Programming Arduino Getting Started with Sketches

by Simon Monk

programming-arduino-getting-started-with-sketches-by-simon-monk.jpgClear, easy-to-follow examples show you how to program Arduino with ease! "Programming Arduino: Getting Started with Sketches" helps you understand the software side of Arduino and explains how to write well-crafted Sketches (the name given to Arduino programs) using the C language of Arduino. This practical guide offers an unintimidating, concise approach for non-programmers that will get you up and running right away.

Programming Arduino: Getting Started with Sketches explains basic concepts and syntax of C with simple language and clear examples designed for absolute beginners - no prior knowledge of programming is required. It leads you from basic through to advanced C programming concepts and features dozens of specific examples that illustrate concepts and can be used as-is or modified to suit your purposes.

  • All code from the book is available for download.
  • Helps you develop working Sketches quickly.

Coverage includes: C Language Basics; Functions; Arrays, Strings; Input / Output; Standard Library Goodies; Storage; LCD Displays; Programming for the Web; Program Design; C++ and Library Writing

More Information...