Arduino OBD2 Simulator




Introduction: Arduino OBD2 Simulator

Ive been building an Arduino OBD2 Scanner to interface with my Jeep's OBD2 port, but it became a beeeeeg! schlep to upload code to my Arduino Nano + 16x2 LCD + ELM327 Scanner device, then haul the whole prototype to the Jeep in the gurage the whole time and then only to find there was something small i forgot to change.

I needed to find a way to test my prototype in the comfort of my home.

Ive searched high and low and couldn't find any Arduino OBD2 simulators that i can build my self. I came across one or two websites that's making use of Arduino to build an OBD2 Simulator but they dont give you the code you have to buy the ready made product from them, I.E the FreeMatics for something like a whopping $169, Wheres the love for Open source in that ???? pffft! I dont see $169 I see about 8 Arduinos i can buy with it.

So unfortunatly and fortunatly for you :-) I had to figure out how i'm going to build one my self, which forced me to now focus on a project i had to take on in order to complete my initial project, Took me some time to figure out how to send PIDs in standard OBD2 format. But at the end i could connect a FreeObd Scanner program which you normally get with your ELM327 Scanner.

Stuff you need.

Arduino UNO

CAN-BUS Shield

ELM327 (USB,Bluetooth,Wifi) It doesnt matter which flavour you have. As long as it creates a com port

OBD2 Diagnostics software (Just to Test if it works) any OBD2 software should work, the software you got with the ELM327 scanner should do just fine.

Step 1: Step 1: the Code

Unfortunately for this to work you MUST have a Shield from SeeedStudio Called the CAN-BUS Shield. You also get one from Skpang but the code below will not work for Skpang unless you alter it slightly.

If you dont know already you also need the SeeedStudion CAN-BUS Library loaded int he Arduino IDE.

Upload the below code, if you dont have the CAN-BUS Shield library loaded the below will most probably error out.

//This Arduino UNO Sketch requires the Seeed CAN-BUS Shield Libraries
// #include #include "mcp_can.h"
INT32U canId = 0x000;
//2024    4    65    12    18    248    185    147
unsigned char len = 0;
unsigned char buf[8];
char str[20];
String BuildMessage="";
int MSGIdentifier=0;
void setup()
    if(CAN_OK == CAN.begin(CAN_500KBPS))
        Serial.println("CAN BUS Shield init ok!");
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        goto START_INIT;
void loop()
    char rndCoolantTemp=random(1,200);
    char rndRPM=random(1,55);
    char rndSpeed=random(0,255);
    char rndIAT=random(0,255);
    char rndMAF=random(0,255);
    char rndAmbientAirTemp=random(0,200);
    char rndCAT1Temp=random(1,55);
    unsigned char SupportedPID[8] =       {1,2,3,4,5,6,7,8};
    unsigned char MilCleared[7] =         {4, 65, 63, 34, 224, 185, 147}; 
    unsigned char CoolantTemp[7] =        {4, 65, 5, rndCoolantTemp, 0, 185, 147};  
    unsigned char rpm[7] =                {4, 65, 12, rndRPM, 224, 185, 147};
    unsigned char vspeed[7] =             {4, 65, 13, rndSpeed, 224, 185, 147};
    unsigned char IATSensor[7] =          {4, 65, 15, rndIAT, 0, 185, 147};
    unsigned char MAFSensor[7] =          {4, 65, 16, rndMAF, 0, 185, 147};
    unsigned char AmbientAirTemp[7] =     {4, 65, 70, rndAmbientAirTemp, 0, 185, 147};
    unsigned char CAT1Temp[7] =           {4, 65, 60, rndCAT1Temp, 224, 185, 147};
    unsigned char CAT2Temp[7] =           {4, 65, 61, rndCAT1Temp, 224, 185, 147};
    unsigned char CAT3Temp[7] =           {4, 65, 62, rndCAT1Temp, 224, 185, 147};
    unsigned char CAT4Temp[7] =           {4, 65, 63, rndCAT1Temp, 224, 185, 147};
    if(CAN_MSGAVAIL == CAN.checkReceive())  
      CAN.readMsgBuf(&len, buf); 
        canId = CAN.getCanId();
        for(int i = 0; i

Step 2: Step 2: Preparing the ELM327 Scanner Cable to Test Your New OBDII Simulator.

You can do it which ever way you like. since the ELM327 Scanner cable is quite cheap i modified it to my liking.

I removed the original sticker to get to the 4 screws to open the box, I took a male to female extender USB cable and cut it in half.

and soldered the one piece of the USB cable's end to pin 6-CAN High and Pin 14-CAN Low, made a little hole on the side, closed it up and stuck a sticker on the side to remind me which is which. Look at the photo's

I then terminated the other half of the USB extender cable to the SeeedStudio Can-BUS shield, Obviously CAN-H from ELM327 to CAN-H on the Shield and same with the CAN-L wires.

Step 3: Step 3: the Testing.

I then powered up the Arduino, The Arduino+CANBUS Shield is now stand alone and doesnt need a pc but i just left it connected to get power from the USB port.

Then connectr the ELM327 to USB, in the device manager make sure which comport belongs to the ELM327 double check because you now have 2 com ports the Arduino's COM Port and the ELM327.

Start an OBD diagnostics windows program I.E then let it monitor the RPM.

The OBD Simulator isnt smooth because its programmed to randomly generate "Valid" data I.E the RPM wil randomly jump from say 5RPM to 800RPM to 20RPM to 1800RPM ect ect, Ive made notes in the Arduino code, its easily readable and doesnt support all PID data but you can certainly add to it. By looking at some of the standard PIDs from Wiki and following "My" methodology

You can also if you want build it into a box then add a few buttons to alter the variables assigned to the random generator function, I didnt need smooth values, Just as long as i'm able to test my Arduino ScanTool Prototype.



    • Creative Misuse Contest

      Creative Misuse Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Fix It! Contest

      Fix It! Contest

    27 Discussions


    1 year ago

    Can you suggest an App to use with the ELM device? Those I´ve tried don´t let me conect, looks like the protocol is not recognized.


    1 year ago

    I have follow the instructions but I receive only CAN_NOMSG (4), status from Arduino. Looks like the shield isn´t sending any message to OBS reader, and in fact the RX and TX didn´t blink, I´ve tested with other program and the shield looks fine. What should be wrong?


    1 year ago

    Has anyone managed to get this working with a bluetooth elm327 scan interface?

    Hi, what shield version are you using? 1.0 o 1.2? It will work with both versions? Thanks in advance!

    Hi mviljoen2,

    Like your simulator, instructables code renderer breaks your example. Could you repost your arduino code again or put the .ino file in a zip? Thx

    2 replies

    found your code on a forum post. Put it in a github repo to extend it.

    Thanks cinezaster :-) , that's very helpful, apology for only replying now, I somehow missed your previous message.

    Hmmm, this comes close to what i'm trying to accomplish...
    I have an arduino Ethernet setup in our tugboats engine room, its an old slow running diesel engine w/o obd.
    The arduino has sensors for measuring the engine's rpm, oil pressures, coolant temp etc, and it serves this data on a webpage for the moment.
    Next step is to create a virtual dashboard with DashXL from Palmer Performance, to do so i would have to make the arduino pour the measurements into OBD format and pipe the data from the network to a virtual serial port.
    Is this doable ? Any suggestions on how to approach this project ?

    2 replies

    Just a quick question, im looking to make exactly whst youve described. Were you succesful with your design? Im looking into a track data ligger (harrys lap timer) for a sprint car!

    Hi Eric, Thanks for the comment, Its definitely doable.
    I dont know dashXL at all but quickly looking at it I noticed it can do OBD2 Stuff, do you know the Torque Smartphone App ?, You are able to add customizable PIDs, If you are able to do the same in DashXL and If your tugboat has sensors which is outside of the normal OBD2 Type sensors you could easily just create an "eOBD2" PID as in extended OBD2 which is common on some vehicles I.E My Jeep also has a Transmission Temp sensor but is not part of the usual OBD2 spec, but you are able to add it into Torque Pro by supplying the PID and the message value, So what you should do is look at then use a PID which is not already used and have the Arduino Simulate the data in OBD2 format using you own PID chosen which .

    I'm sure most of the PIDs you need is already available in the standard OBD2 spec.
    In the OBD2 Wiki link i posted it also gives you the formula on how to calculate the PID's IE if you have a temp sensor you would supply it in format by adding 40 to the real value, an OBD reader will then take the value and subtract 40 again as per the spec

    Catch my drift ?,
    You have quite a nice project ahead!, sounds interesting.

    Hi mviljoen2, Thanks to your post I was able to build and run the simulator.

    Using your code I'm able to simulate different sensor values but I'm also interested in simulating DTC's. Could you please guide on how this could done? This link describes that in mode3 set DTC's are returned but i'm unable to figure out how to set the DTCs in this simulator. Any suggestions would be very helpful.


    Hi there! It seems that your code is incomplete, as shown by the lack of sending the data you create, and the incomplete for loop. I could really use this code. Could you upload the missing pieces please? Thank you!

    hmmm this is great....

    how ever my car runs ISO 9141 so i dont think the CanBus shield will work

    any advice?

    any one knws were i can still buy a obd ii simulator??

    Hi, This looks great, I'm going to try it out but have a question if that's OK.

    I'm developing an iOs app and want to use your project for simulating OBDII over WiFI, What method would you recommend for connecting the wifi OBDII dongle up to the CAN-Bus shield? obviously you use a wired setup.

    Any help would be gratefully received.

    2 replies


    I assume you cant make use of Bluetooth because of apple's closed BT api?

    Wireless is going to be quite tricky, and i stand to be corrected , for serial communication to happen over wifi, you need to do the obvious by establishing a wifi connection to the obd2 device, next you need to develop a virtual com port driver, the comport driver then needs to be able to establish connection to the obd2 device using tcp ip,

    So the App talks to the virtual com port using normal serial AT commands, the virtual com port drivers then takes the at commands received and send it over wifi via tcp ip:port on the obd2 device, the obd2 device will then automatically translate to serial again by it self.

    The actual obd2 simulator i built doesnt really have anything to do with the above , the above is just a way to get the commands back and to the Obd2 device which in turn will automatically talk to the obd2 simulator

    Thats how i would approach it.
    Hope this helps

    Yes, Bluetooth would be easier but Apple like to be different!

    I'm fine with getting the app talking to my WiFi dongle, I'm going to try hooking up the dongle to your Arduino project.

    I've got hold of a female OBD2 port to bare end cable, I'm going to hook this up to a DB9 (RS232) connector and plug one end in to the arduino project and the other into my WiFi dongle, I'll let you know how I get on...

    Thanks for your help!