OBD-Pi

396,138

1,554

109

Introduction: OBD-Pi

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!

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

Coded Creations

Participated in the
Coded Creations

Be the First to Share

    Recommendations

    • Maps Challenge

      Maps Challenge
    • Fandom Contest

      Fandom Contest
    • Backyard Contest

      Backyard Contest

    109 Comments

    0
    MWongMWong
    MWongMWong

    Question 10 days ago

    How to detect fault code and erase it?

    0
    MWongMWong
    MWongMWong

    10 days ago

    How to detect fault code and erase it?? Pls advise. Thks!

    0
    jennifersmithzzz51
    jennifersmithzzz51

    4 months ago

    Hello .... can you send pdf of this project details step by step procedure

    0
    Acckhe
    Acckhe

    5 months ago

    It's possible to read data from sensors that are not stock? I'm talkin about a oil pressure sensor, most cars are not equipped with one, mine doesn't. So I would love to retrofit a oil pressure sensor and have the info displayed on the pi.

    0
    leoncoolmoon
    leoncoolmoon

    Question 7 months ago on Step 7

    Can you update the program so it can work with homeassistant?

    0
    pixelbend
    pixelbend

    10 months ago

    Great little project and thanks for sharing!

    I just installed it on a Pi 4 and was wondering how to change the sensors being displayed. I'm interested in stats such as boost, oil temp, trip distance, etc. Hoping you could help :)

    Thanks
    Steve

    0
    pixelbend
    pixelbend

    Reply 8 months ago

    Another question. I am having issues with my bluetooth adapter not auto connecting. How did you manage to get that working! Thanks.

    0
    zeesh19791
    zeesh19791

    Reply 9 months ago

    Which obd adapter u used? Link plz

    0
    FBCEN
    FBCEN

    Question 8 months ago on Introduction

    Hello.
    I would like to setup a tool to the cars of my company : a RPi, with RFID reader and GPS. The idea is to record the traject (for funding reasons) and the passengers of the car. I had in mind to code a program, that need the user to scan his RFID card, and RFID card of each passenger, then it will allow the user to start the car and it then start recording the ride.
    Do you think that a OBD-Pi, with a RFID reader and a GPS and plug in the car will allow me code a tracker that lock/unlock the engine ?
    Thanks,

    Fabien

    0
    nelson.osnayo.c
    nelson.osnayo.c

    1 year ago

    Good evening, I am modifying the code to manipulate variable power or somehow the arrangement of the sensor data obtained. some comment If you also have the same intention let me know, nelson.osnayo.c@gmail.com

    0
    zeesh19791
    zeesh19791

    Reply 9 months ago

    Which obd adapter u used? Link plz

    0
    tajer.wrd
    tajer.wrd

    1 year ago

    Thank you I have tried it and worked perfectly, but my lcd screen is 3.5 inch, so how can I modify the size of the object inside to make it readable. I can't see the whole digits only part, it is kinda hidden

    Thank you again

    0
    zeesh19791
    zeesh19791

    Reply 9 months ago

    Which obd adapter u used? Link plz

    0
    zeesh19791
    zeesh19791

    Question 9 months ago

    The recommended elm adapters are not available now. Is there any working one? I used a couple but they seemed to be cloned and not compatible

    0
    eltonkoehn999
    eltonkoehn999

    Question 11 months ago on Step 2

    Have there been any updates for this project? I am currently using a Pi 4 and find the the links to the required packages are no longer good as the package have been updated. Even after installing the updated packages I still don"t have much success with the project.

    Thanks,
    Elton

    0
    nchrisvw
    nchrisvw

    Question 1 year ago

    Been running into a few issues, I I just wanted to confirm that a Rasberry Pi 3 A+ will work in substitution for the B+

    0
    lsvineethsankre
    lsvineethsankre

    1 year ago

    Currently, we are using OBD device for car can we use it for other vehicles like bike?

    0
    junkmail.harry.lee
    junkmail.harry.lee

    Reply 1 year ago

    ODB is standardized and implemented on cars, and is a part of the ECM.

    When you say bike, I would assume you are referring to motorbike. Unfortunately there is no standardized diagnostic system on motorbikes. Almost every brand has their own proprietary diagnostic system, and even different connectors.

    You will have to build a harness to connect to your Pi, do some programming to comprehend the signals from your motorbike.

    Of course, it would be cool if you build one that can comprehend multiple brands of bikes.

    0
    saintkazu
    saintkazu

    1 year ago

    Hi, I'm currently conceptualizing a framework for my undergraduate thesis. Basically I'm thinking of a system also on the Raspberry pi that makes use of the car's real-time speed and the distance between the car and the one in front of it using a distance-measuring sensor to create an output that tells the driver how much acceleration or braking they need in order to maintain a safe distance. From this, may I ask if you know any way to extract the real-time speed data from the OBD-II connection so that the system I have in mind can use it? Thanks!

    0
    CandyO3
    CandyO3

    2 years ago on Introduction

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