Read VIN?

Inquiry and support for Freematics products
Post Reply
Henke
Posts: 7
Joined: Thu Aug 21, 2014 1:13 am
Location: Sweden

Read VIN?

Post by Henke »

Any ideas how to read out the VIN number?

I can see that there is a declaration of a variable called vin in odb.h
line 123: // current VIN
line 124: byte vin[17];

but I can´t find any function that reads the actual VIN from the OBD interface...

Do I need to implement that function or am I missing something here?
Henke
Posts: 7
Joined: Thu Aug 21, 2014 1:13 am
Location: Sweden

Re: Read VIN?

Post by Henke »

Found the answer :)

write 0902 to ask for the VIN.

With a VIN of WP0ZZZ99ZTS392124 in the OBD-simulator a got this respond back:

014 0: 49 02 01 57 50 30
01: 5A 5A 5A 39 39 5A 54
02: 53 33 39 32 31 32 34

According to the ELM327 specification:

014 - 014 bytes of information (HEX)
0:-sequence number
4902-response to an 0902 request
01-numbers of data items

So if I discard this bytes and convert the remaining hex numbers to ASCII I get:

57 50 30 5A 5A 5A 39 39 5A 54 53 33 39 32 31 32 34
W P 0 Z Z Z 9 9 Z T S 3 9 2 1 2 4

Perfect :D

Hope this can help someone that needs the VIN.
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: Read VIN?

Post by stanley »

Thanks! :D
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Read VIN?

Post by lukeau »

Where are you putting the code to write 0902 to ask for the VIN? Are you putting it in OBD.h or OBD.cpp?
I'm trying to get the VIN myself, would you be willing to share the code snippet please?

I tried adding a definition to OBD.h like this:

Code: Select all

#define PID_VIN 0x02

.. but I can't see how the mode is defined (all other PIDs have a 'mode' of 1, request vehicle data is 9.

I'd love to add this to the OBD library as a definition so that the VIN can be requested in the same way as any other PID, but I can't work out how to account for the different 'mode'.
I also suspect that the string might need to be normalised and formatted in OBD.cpp?
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: Read VIN?

Post by stanley »

In current implementation of OBD library, only mode 01 is handled. You can though send "0902\r" to request for the VIN data and parse it.
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Read VIN?

Post by lukeau »

1. Can I make this request from datalogger.ino, or do I need to do this in the OBD library? Something like this?

Code: Select all

    write("0902\r");
    receive();

2. To make requests of the OBD-II, does "0902\r" need to be prefixed with an special AT command? For example:
    a. requests to the GPS depending on need are prefixed with ATBR2 to set baud rate, ATSGC to set NMEA update rate and ATGRR to get NMEA data.
    b. requests to the OBD-II appear to be prefixed by ATSP.
3. Do you have a code example of how to make the "0902\r" request?

Apologies if my questions seem basic, I am trying to understand how serial requests to the different attached components work.
ronaldpace
Posts: 2
Joined: Sun Apr 23, 2017 6:32 am

Re: Read VIN?

Post by ronaldpace »

I am sending a "0902"<CR> and I am get back 84 bytes of VIN data. Is there another command that can help me parse this VIN data?
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: Read VIN?

Post by stanley »

Please refer to our Arduino library for how to parse the response.
richardjews
Posts: 1
Joined: Mon Aug 28, 2017 7:11 pm
Contact:

Re: Read VIN?

Post by richardjews »

I can´t find any function that reads the actual VIN from the OBD interface...
Ramon08
Posts: 1
Joined: Fri Sep 15, 2017 4:55 am

Re: Read VIN?

Post by Ramon08 »

thanks
Post Reply