Macchina Docs
  • Macchina.cc
  • Introduction
    • Disclaimer
  • Product Documentation
    • M2 Docs
      • Getting Started
      • Arduino IDE Quick Start
      • M2 Code libraries
        • CAN bus
        • Single-wire CAN
        • LIN
      • Next Steps with M2
      • Detailed Reference
        • Installation
        • Processor
        • Pin Mapping
        • Automotive Interfaces
        • Communication
          • M2 Bee-Compatible Add-ons
          • Cellular
        • Power
        • Storage/Memory
        • 12V IO
        • LEDS/Buttons
        • Enclosures
        • Breakout Board
        • Schematics and Source
      • Versions of M2
    • A0 Docs
      • Quick Start Guide
      • Firmware Reference
      • Hardware Reference
      • Projects
      • Troubleshooting
    • SuperB Docs
      • Getting Started
      • Hardware
      • Sending AT Commands
    • P1 Docs
      • Getting Started
      • Pin Mapping
      • Interfaces
      • Power Supply Note
    • OBD3way Docs
  • Projects
    • A0 Projects
      • A0 CAN Vehicle Data
      • A0 CAN Point to Point
      • A0 CAN Read VIN
      • Work-in-Progress A0 projects
    • M2 Projects
      • "OK Google, start my car!"
      • M2 and SavvyCAN, the Basics
      • Help Collect Voltage Data
      • Mini-Project Tutorials
        • M2 CAN Loopback
        • M2 CAN Point to Point
        • M2 SWCAN Point to Point
        • M2 VIN Extraction
    • P1 Projects
      • P1 CAN Vehicle Data
      • P1 CAN Loopback
    • Community Projects
    • Project Support
    • Other Resources
  • Support /contact us
    • Contact US / FAQ
    • Common Issues
    • Out of Stock/ Status
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Projects
  2. A0 Projects

A0 CAN Read VIN

Use A0 to read the VIN from a vehicle.

PreviousA0 CAN Point to PointNextWork-in-Progress A0 projects

Last updated 5 months ago

Was this helpful?

Items Used

  • 1x A0

  • 1x Car with OBD-II port

A0 Sketch

Upload THIS SKETCH to your A0, which queries the vehicleβ€˜s Vehicle Identification Number (VIN), and prints the result to the serial monitor. It requires two libraries, which can be found here and here.

Vehicle Setup

Plug A0 into the OBD-II port found beneath the dashboard (usually between the steering wheel and pedals, by your left knee). Keep A0 connected to your computer with the USB cable and open the Arduino IDE's serial monitor at baud 115200.

Test

Watch the serial monitor. It should print out the VIN of your vehicle.

How It works

The Vehicle Identification Number (VIN) can be read from a vehicle using standard OBD-II commands. Several messages must be exchanged because the VIN is too long to fit in a single 8-byte CAN frame.

Standard OBD services are defined in ISO 15031-5. Service 09 - Request vehicle information allows requesting the VIN. The network protocol used to split this request over multiple CAN frames is defined in ISO 15765-2.

The sequence of messages used to read a VIN is as follows:

0x7DF | 02 09 02

A0 sends message from functional request ID 0x7DF. It is a SingleFrame with length of 2 (02). It is a request for the Request vehicle information service (09). The InfoType is VIN (02).

0x7E8 | 10 14 49 02 01 31 4D 38

Response from ECU #1. It is a FirstFrame with length of 20 (10 14). It contains the first 3 characters of the VIN β€œ1M8” (31 4D 38).

0x7E0 | 30 00 00

A0 sends message using ECU #1 request address. It is a FlowControl frame with status ContinueToSend (30). The BlockSize value tells the ECU to send all remaining frames (00). The SeparationTime is 0ms (00).

0x7E8 | 21 47 44 4D 39 41 58 4B

0x7E8 | 22 50 30 34 32 37 38 38

The ECU responds with two ConsecutiveFrame messages with sequence numbers 1 (21) and 2 (22). Each contains seven more characters of the VIN.

The VIN can then be assembled by combining the characters from each of three frames sent by the ECU: 31 4D 38 47 44 4D 39 41 58 4B 50 30 34 32 37 38 38, which translates to 1M8GDM9AXKP042788 in ASCII.

πŸ‘‰
πŸ‘‰
πŸ‘‰