Can a Raspberry Pi Output OBD2 Data? Building a DIY Car Computer

PLEASE NOTE: This blog post is a conceptual overview of creating a Raspberry Pi car computer project. For technical details on setting up your own Raspberry Pi carputer, please refer to the official obdPi documentation here.

Introduction

Back in the summer of 2015, my quest for a boost gauge for my Fiesta ST led me to an interesting review of the 2016 Subaru WRX. The review highlighted the WRX’s central multi-function display, showcasing real-time vehicle data such as boost pressure and fuel economy. This feature, along with the functionality of the COBB AccessPort, sparked an idea: could I build my own custom gauge using a spare Raspberry Pi? This thought experiment quickly turned into a hands-on project exploring if a Raspberry Pi output in OBD2 was feasible and practical for displaying car diagnostics.

Inspired by the WRX and devices like the AccessPort, I envisioned a learning experience that would involve building my own boost gauge. My initial plan involved several key areas of learning and development:

  • Python programming fundamentals
  • Wiring a 16×2 OLED display to the Raspberry Pi
  • Retrieving OBD-II (On-Board Diagnostics II) data from my car via Bluetooth
  • Designing an ignition-dependent power supply for in-car use
  • Configuring a lightweight, headless Raspbian OS for efficient operation

With a basic plan in mind, I sought feedback from online forums and communities. Some responses were encouraging, while others offered alternative perspectives:

Why not just use Torque Pro? It’s already a well-developed app.

While I had experimented with Torque Pro on my phone, I found it to be somewhat cluttered for my liking. Moreover, using my phone as a display in the car wasn’t ideal. My 5-inch Nexus, if mounted on the windshield, would obstruct a significant portion of my view, and I preferred to keep my phone free for calls and music while driving.

You could interface a pressure transducer and create a digital display…

While intriguing, projects using pressure transducers often focused solely on boost pressure. My aim was broader. I wanted to leverage the OBD-II interface to access a wider range of standardized vehicle data, going beyond just boost readings. The question was, Can Raspberry Pi Output In Obd2 and display this richer dataset effectively?

Researching Raspberry Pi OBD2 Interfaces

My research led me to several online projects that aimed to create in-car computers displaying vehicle diagnostics. The most prominent and well-documented project was from CowFish Studios. Their project, named “obdPi,” utilized a Raspberry Pi to display car diagnostics on an aftermarket head unit. However, it used a multi-color LCD and an older Python OBD-II library, which I felt could be improved upon. While it confirmed that Raspberry Pi can output OBD2 data, I was looking for something more streamlined and modern.

Another promising project was CarBerry. They offered a polished-looking system designed to output to an LCD head unit. Unfortunately, the cost, including shipping and accessories, was higher than my budget allowed. Like obdPi, CarBerry also demonstrated the concept of Raspberry Pi output in OBD2, but I was aiming for a more cost-effective and DIY approach.

Several other projects appeared to be either outdated or lacked sufficient documentation. Taking inspiration from the best aspects of these projects, I decided to forge ahead and develop my own solution, focusing on answering the question: how can a Raspberry Pi output OBD2 data in a practical and user-friendly way?

Essential Supplies for a Raspberry Pi Car Computer

Just as I was starting this project, the Raspberry Pi 2 was released. I opted for a Vilros Raspberry Pi 2 Ultimate Starter Kit (link now points to a newer Pi 3 kit). Being new to electrical wiring, I felt the starter kit provided almost everything I needed to begin wiring the Raspberry Pi’s GPIO (General Purpose Input/Output) pins.

In addition to the Vilros kit, I purchased the following components to enable Raspberry Pi output in OBD2:

  • Adafruit 16×2 Character OLED Display – For displaying OBD2 data.
  • OBD-II Bluetooth Adapter – To wirelessly interface with the car’s OBD2 port.
  • Bluetooth USB Adapter – To enable Bluetooth connectivity on the Raspberry Pi.
  • Mausberry Car Power Supply (Initially) – For safe power management in the car.
  • UPS PIco (Later) – As a replacement power solution.
  • 12V to 5V Voltage Regulator – To step down car voltage for the Raspberry Pi.
  • Various wires, connectors, and fuse taps – For electrical connections.

NOTE: When selecting an OBD-II Bluetooth adapter, prioritize quality. My first adapter was a cheap knock-off and proved unreliable.

Wiring the OLED Display for OBD2 Output

With the basics of Raspberry Pi wiring learned from tutorials included in the starter kit, I moved on to connecting an LCD. While numerous LCD options exist for the Raspberry Pi, I chose the Adafruit 16×2 character OLED display for several reasons. Firstly, being an OLED, it required less wiring by eliminating the need for a backlight. Secondly, OLED displays are significantly more readable in direct sunlight – crucial for in-car use. Finally, the display’s color closely matched the gauge screen in my Fiesta ST, aiming for a factory-integrated look. This OLED display would be the primary interface for the Raspberry Pi output in OBD2 project.

The main challenge with this OLED display was the limited online wiring documentation specifically for it. While Adafruit provides excellent tutorials for their other LCDs, support for this particular OLED seemed scarce. Undeterred, I proceeded with wiring, using the LCD documentation as a general guide.

Unfortunately, my initial wiring attempt resulted in a fried display. After contacting Amazon, a replacement was promptly shipped. While waiting, I discovered a helpful forum post on raspberrypi.org regarding wiring this specific OLED display. Following the suggestions there, my second attempt was successful. The Raspberry Pi output in OBD2 was now visually accessible!

For a detailed walkthrough and wiring diagrams for the OLED display, please consult the obdPi documentation.

Establishing Bluetooth and Serial Connections for OBD2 Data

With a working display in place to visualize the Raspberry Pi output in OBD2, the next step was configuring Raspbian to communicate with the Bluetooth OBD-II adapter. This process involved considerable trial and error due to the lack of specific documentation for my exact setup: a Bluetooth OBD-II adapter connecting via a Bluetooth USB adapter to a Python script in a headless Raspbian environment. However, I eventually achieved a functional configuration. (Detailed instructions are available in the “Bluetooth Setup” and “Serial Connection” sections of the documentation.)

In essence, the Bluetooth OBD-II adapter is paired with the Bluetooth USB adapter using the Raspberry Pi’s Bluetooth utilities. This Bluetooth connection is then mapped to a virtual serial port, accessible in Python through the pyserial library. To automate this process on startup, entries were added to the /etc/rc.local startup file, ensuring a seamless connection each time the system booted. This serial connection is crucial for the Raspberry Pi output in OBD2 data stream.

Python Scripts for OBD2 Data Retrieval and Display

Having established display and communication pathways, the next critical component was writing Python scripts to retrieve OBD-II data from the car and display it. Initially, I (perhaps optimistically) started from scratch, attempting to learn the intricacies of the OBD-II interface directly. While I made some progress, my scripts were rudimentary and inefficient. Fortunately, I discovered the python-OBD library, a game-changer for simplifying Raspberry Pi output in OBD2 projects.

The python-OBD library is exceptionally well-structured, actively maintained with continuous updates, and supported by a responsive author. Leveraging this library, I quickly developed a functional script that successfully output OBD-II data to the OLED display. The Raspberry Pi output in OBD2 was now a reality, showing real-time data on the small screen!

While functional, the flashing display in the video indicated that the code was still under development. However, this success allowed me to move on to the next challenge: powering the Raspberry Pi reliably in the car environment.

Powering the Raspberry Pi Car Computer

For powering the Raspberry Pi in a car, I had come across recommendations for Mausberry Circuits in various Raspberry Pi tutorials. I ordered one of their 2A car-based power supplies. Mausberry car switches are designed to draw power from both ignition-switched and constant 12V sources in a car. They are supposed to provide power to the Raspberry Pi when the car is on and initiate a safe shutdown sequence when the ignition is turned off. In theory, these switches seemed ideal for this project, ensuring clean and safe Raspberry Pi output in OBD2 operation in a vehicle.

After installing the Mausberry car switch, using fuse taps to connect to the car’s fuse box, initial tests seemed promising.

However, after approximately 30 seconds of operation, the switch would abruptly cut power to the Pi, forcing an unsafe shutdown. Extensive troubleshooting, including trying different fuse combinations, wiring configurations, USB cables, and even direct battery connection, yielded no improvement. Suspecting a faulty switch, I used a multimeter (after sacrificing a USB cable) and confirmed that the Mausberry switch itself appeared to be the problem. This was a setback in ensuring stable Raspberry Pi output in OBD2.

Despite reaching out to Mausberry, I received no response after weeks of waiting. Giving them the benefit of the doubt, I ordered a second switch, this time the 3A version. After another period of silence, the new switch arrived.

Unfortunately, the new switch exhibited the same issues. Further testing with various cables, power sources, and fuses again proved fruitless. Frustrated by the lack of communication and the persistent power problems, I sought an alternative. Fortunately, I discovered the UPS PIco from Pimodules. I contacted Pimodules directly to inquire about its suitability for car applications. They responded quickly, expressing confidence in its performance in a car environment. I promptly ordered a UPS PIco, hoping it would solve the power issues and ensure reliable Raspberry Pi output in OBD2.

Despite the wait due to customs and international shipping, the UPS PIco arrived and immediately impressed me.

The setup guide was exceptionally clear and easy to follow. The UPS PIco utilizes a small 450mAh LiPo battery to provide backup power to the Pi in case of power loss (e.g., when the car is turned off). It employs scripts to trigger a safe shutdown a few seconds after battery power kicks in. The UPS also offers optional cooling fan integration and provides easy access to voltage and battery level information via status LEDs. Thanks to the excellent documentation, I had the UPS PIco configured and working flawlessly within an hour. After months of power-related frustrations, I finally had a stable power solution, essential for reliable Raspberry Pi output in OBD2!

Integrating into the Car for OBD2 Data Display

Since the UPS PIco replaced the Mausberry circuit, I needed a separate voltage regulator to step down the car’s 12V power to the Raspberry Pi’s required 5V. I found this regulator on Amazon and wired it into the system.

With all components ready, I began the in-car installation. First, I routed the OLED display cable through the dashboard from the glove compartment.

I decided to position the OLED display just below the instrument gauges, simplifying cable routing.

Finally, it was time for a test drive! The system worked as intended, successfully demonstrating Raspberry Pi output in OBD2 within the car environment. After several weeks of testing, while minor bugs remained to be addressed, no major issues surfaced. The Raspberry Pi car computer was operational!

Creating an OLED Housing for a Finished Look

With the core functionality achieved, I focused on refining the aesthetics. The exposed green OLED PCB against the car’s black dashboard was visually unappealing. I decided to fabricate a simple housing from perspex plastic purchased from Home Depot. This also provided an opportunity to finally use a Dremel.

Future Enhancements for the Raspberry Pi Car Computer

This project, born from a simple afternoon idea, evolved into a challenging and time-consuming endeavor. There were countless late nights in the garage and at my laptop, navigating the complexities of Python and electronics. It was a significant learning experience, proving that answering the question “can Raspberry Pi output in OBD2?” with a working project is indeed achievable, though not without its hurdles.

Special thanks to my girlfriend for her unwavering patience and support throughout this project. Her encouragement was invaluable, even amidst the piles of electronics and wires that seemed to proliferate around the house.

While seemingly simple to some, this project became a lesson in perseverance. It highlighted the value of sticking with a project through numerous setbacks, as the final result is always worth the effort. The successful Raspberry Pi output in OBD2 car computer is a testament to this.

I am excited about the future possibilities for this project and have already compiled a substantial list of potential improvements and expansions.

Thank you for following along!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *