OBD-Pi

375,351

1,533

98

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

    • Potato Speed Challenge

      Potato Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest

    98 Discussions

    0
    pixelbend
    pixelbend

    9 days 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
    eltonkoehn999
    eltonkoehn999

    Question 7 weeks 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
    tajer.wrd
    tajer.wrd

    2 months 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
    nchrisvw
    nchrisvw

    Question 5 months 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

    8 months 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 6 months 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
    nelson.osnayo.c
    nelson.osnayo.c

    8 months 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
    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

    1 year ago on Introduction

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

    0
    JasperT10
    JasperT10

    1 year 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
    EricH307
    EricH307

    Question 2 years 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

    0
    Project D
    Project D

    Answer 1 year 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
    lesincostan
    lesincostan

    4 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
    0
    HenrryC
    HenrryC

    Reply 1 year 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
    CowFish
    CowFish

    Reply 4 years ago

    Hi lesincostan,


    No problem, love your setup!


    Cheers,

    1
    michaelpko
    michaelpko

    3 years 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??

    0
    HenrryC
    HenrryC

    Reply 1 year ago

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

    0
    michaelpko
    michaelpko

    Reply 1 year ago

    Hi. No sorry.

    0
    mfarooqgul
    mfarooqgul

    1 year 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
    DavidH1076
    DavidH1076

    2 years 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.