OBD-Pi

327,763

1,500

90

In this instructable you will learn how to connect your Raspberry Pi to a Bluetooth OBD-II adapter and display realtime engine data to your cars aftermarket head unit!

Supplies:

Step 1: Hardware Required:

  1. Raspberry Pi Model B or B+
  2. Aftermarket head unit (Note: Must support Auxiliary input)

  3. Plugable USB Bluetooth 4.0 Low Energy Micro Adapter

  4. 2A Car Supply / Switch or Micro USB Car Charger

  5. ELM327 Bluetooth Adapter or ELM327 USB Cable

  6. RCA cable

  7. Keyboard (*optional)

Step 2: What Is OBD-II?

OBD stands for On-Board Diagnostics, and this standard connector has been mandated in the US since 1996. Now you can think of OBD-II as an on-board computer system that is responsible for monitoring your vehicle’s engine, transmission, and emissions control components.

Vehicles that comply with the OBD-II standards will have a data connector within about 2 feet of the steering wheel. The OBD connector is officially called a SAE J1962 Diagnostic Connector, but is also known by DLC, OBD Port, or OBD connector. It has positions for 16 pins, and looks like this:

Step 3: PyOBD?

pyOBD (aka pyOBD-II or pyOBD2) is an open source OBD-II (SAE-J1979) compliant scantool software written entirely in Python. It is designed to interface with low-cost ELM 32x OBD-II diagnostic interfaces such as ELM-USB. It will basically allow you to talk to your car's ECU, display fault codes, display measured values, read status tests, etc.

I took a fork of pyOBD’s software from their GitHub repository, https://github.com/peterh/pyobd, and used this as the basis for my program.

The program will connect through the OBD-II interface, display the gauges available dependent on the particular vehicle and display realtime engine data to the cars aftermarket head unit in an interactive GUI.

Step 4: Software Installation

Before you start you will need a working install of Raspbian with network access.

We'll be doing this from a console cable connection, but you can just as easily do it from the direct HDMI/TV console or by SSH'ing in. Whatever gets you to a shell will work!

Note: For the following command line instructions, do not type the '#', that is only to indicate that it is a command to enter.

Before proceeding, run:

#  sudo apt-get update
#  sudo apt-get upgrade
#  sudo apt-get autoremove
#  sudo reboot

Install these components using the command:

#  sudo apt-get install python-serial
#  sudo apt-get install bluetooth bluez-utils blueman
#  sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev
#  sudo apt-get install git-core#  sudo reboot

Next, download the OBD-Pi Software direct from GitHub.

(https://github.com/Pbartek/pyobd-pi.git)

Or using the command:

#  cd ~
#  git clone https://github.com/Pbartek/pyobd-pi.git

Step 5: Vehicle Installation

The vehicle installation is quite simple.

1. Insert the USB Bluetooth dongle into the Raspberry Pi along with the SD card.

2. Insert the OBD-II Bluetooth adapter into the SAE J196216 (OBD Port) connector.

3. Connect you RCA cable to the back of your aftermarket head unit and plug the other end into your Raspberry Pi.

4.Install your 2A Car Supply / Switch or Micro USB Car Charger.

5. Finally turn your key to the ON position and navigate your head unit to Auxiliary input.

6. Enter your login credentials and run:

# startx 

7. Launch BlueZ, the Bluetooth stack for Linux. Pair + Trust your ELM327 Bluetooth Adapter and Connect To: SPP Dev. You should see the Notification "Serial port connected to /dev/rfcomm0"

Note: Click the Bluetooth icon, bottom right (Desktop) to configure your device. Right click on your Bluetooth device to bring up Connect To: SPP Dev.

8. Open up Terminal and run:

# cd pyobd-pi

# sudo su

# python obd_gui.py

Use the Left and Right arrow keys to cycle through the gauge display.

To exit the program just press Control and C or Alt and Esc.

Step 6: Data Logging

If you would like to log your data run:

#  cd pyobd-pi
#  python obd_recorder.py

The logged data file will be saved under:

/home/username/pyobd-pi/log/


Enjoy and drive safe!

Step 7: Step by Step Video

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Gardening Contest

      Gardening Contest
    • IoT Challenge

      IoT Challenge

    90 Discussions

    0
    None
    CandyO3

    22 days ago on Introduction

    Que tipo de marcas lee? es genérico? lee autos chinos? la funcion del osciloscopio viene?

    0
    None
    JasperT10

    4 weeks ago

    I just found out about this and I'm stuck on a trying to connect screen. I did connect with the Bluetooth device before giving the command.

    0
    None
    EricH307

    Question 1 year ago on Introduction

    great project Where can I get an aftermarket head unit? My car is old, a 2000 SAAB

    or can I use a laptop in lieu of the head unit?

    thanks for a great start on OBD-II

    1 answer
    0
    None
    Project DEricH307

    Answer 4 months ago

    The idea behind this is to have OBD monitoring integrated into the car. In this instance, the head unit is simply being used as a convenient monitor or display. You wouldn't be able to display your Raspberry Pi through a laptop unless the laptop had some sort of provision to be used as an external display, and I can't think of any that have that ability. But really, if you were going to use a laptop, you might as well use OBD software available for PCs, the Pi would be completely redundant.

    You can get a head unit at pretty much any store that sells car audio products. If you can't find one that's compatible with your Saab's dash, or you don't want to buy a head unit as they can be quite expensive, you can always get a regular Raspberry Pi touchscreen and an appropriate all-in-one housing, such as the pictured ones I found on Amazon, and mount it wherever you like. I would probably go this route to keep costs down, and be less intrusive to the overall dashboard layout.

    61f4fD1JVWL._SL1200_.jpg710mTi1gamL._SL1500_.jpg
    1
    None
    lesincostan

    3 years ago

    Hi,

    i have worked my way through the tutorial today and it worked really well. I have combined the Rasperry Pi with the new Rasperry touch screen and I am looking forward to finish a contineous installation. I think it will be a great asset to my car.

    Thanks a lot for the instructable!

    20151110_152729.jpg
    2 replies
    0
    None
    HenrryClesincostan

    Reply 4 months ago


    Hi ... could you help me with an iso image of the operating system with all the settings I already have problems with the bluetoothtcl when I connect I would appreciate it a lot

    0
    None
    CowFishlesincostan

    Reply 3 years ago

    Hi lesincostan,


    No problem, love your setup!


    Cheers,

    1
    None
    michaelpko

    1 year ago

    Hi install and bt connection all good however I get a blank screen and this:

    ['/dev/rfcomm0']

    Opening interface (serial port)

    Interface successfully /dev/rfcomm0 opened

    Connecting to ECU...

    atz response:ELM327 v2.1

    Got nothing

    Got nothing

    Got nothing

    Got nothing

    Got nothing

    ate0 response:ate0

    0100 response:0100NO DATA

    Connected to /dev/rfcomm0

    Any suggestions??

    2 replies
    0
    None
    HenrryCmichaelpko

    Reply 5 months ago

    I have the same problem ....... have you been able to solve it?

    0
    None
    mfarooqgul

    6 months ago

    Hello, I follow your step. NOw I am stuck to hang my PI. its asked pi password but not accepting any password. what I have to do?

    0
    None
    DavidH1076

    9 months ago

    I Have

    https://www.amazon.com/dp/B01C6CZ0SQ/ref=sspa_dk_...

    This OBDII module, and a Raspiberry Pi 3B+ Bluetooth connection no
    problem, rfcomm bind 0 00:1D:A5:68:98:8C also no problem, start the
    app, continue to get the following error :

    read failed: device reports readiness to read but returned no data
    (device disconnected)

    Any help would be great please.

    0
    None
    KeithP78

    9 months ago

    If you purchased an OBDII Wifi only dongle ELM327 and want to make this work, I found a way.

    apt install socat

    Had to make a virtual serial port ttyUSB0 with socat on raspbian stretch.

    socat pty,link=/dev/ttyUSB0,waitslave tcp:192.168.0.10:35000&

    python obd_gui.py

    The script came up and displayed the data on the screen.

    0
    None
    AnandM12

    10 months ago on Step 5

    The actual article was written 4 yrs ago (6/25/2014). Lot of things have changed since then, esp bluetooth connection. Bluez doesn't work anymore and the Bluetooth GUI is different now. There is no option to trust a device and no option to Connect to SPP Dev. I'm struck in that part.

    After some googling and trying out, I think I now have connected the bluetooth to the serial port. It says "Connected /dev/rfcomm0 to xx:xx:....:xx on channel 1"
    But still when I run the program, it says "trying to connect" and then the screen goes blank. I'm not sure what is the issue
    I run an app in my phone, connected to the OBD device and I'm able to view the data.

    0
    None
    qqmajikpp

    10 months ago

    Did this in my RAV4. Expect a USB scantool today. Hopefully its faster and more reliable than the BT scantool. Exploring adding more PIDs. Very exciting stuff. Thanx for sharing.

    1 reply
    0
    None
    MordechaiF

    1 year ago

    Total Pi noob here... I followed your instructions and can't get the piobd-py.git part to work for me. It does nothing when I type that line in. I tried the link which sent me to github, and searched not knowing wth to do there. I'm sure it's on my end, the knowledge part. This is all experimental for me, I can already do this and more with my phone, like checking the other modules, airbag, ABS, etc.. There's also a wall I'd like to breakthrough here, the one between car types and computer types. I'd eventually like to run my car reliably on a PI or a stack if need be. I'd be impressed if the stock ecu runs at 20mhz. Anywho, step 1 is getting this to work.

    1 reply
    0
    None
    supawiz6991MordechaiF

    Reply 1 year ago

    I assume your talking about
    git clone https://github.com/Pbartek/pyobd-pi.git

    There should be some output from running that command

    when you type git clone does it tell you command not found? If so, run the command sudo apt-get install git (this will install git) and then try again.

    Are you getting a permissions error? add sudo before git clone -or- run the command on a directory that you have permission to write in.

    When you run this command successfully, it should create a directory and download all of the files from the repository into it.

    0
    None
    Pavankumar33

    Question 1 year ago on Step 1

    Can we add other functionality along with diagnostics to the Raspberry pi ?( viz. sensors)

    0
    None
    MariusV26

    2 years ago

    Hi. Thank you for sharing this great project! But I have one question about fuel level is "fuel system stat" means fuel level (because I getting 0100 all the time and S-T and L-T fuel trim at 0)?