Arduino Uno R3 OBD2 Project: Crafting a Custom Car Performance Monitor

The enthusiastic reception to my previous Raspberry Pi OBD-II Carputer project was truly unexpected. The project sparked numerous discussions and inquiries, highlighting a significant interest in the intersection of OBD-II technology and DIY electronics. Inspired by engaging conversations at tech conferences about OBD-II hacking, I connected with fellow enthusiasts equally excited about the potential of combining OBD-II with platforms like Raspberry Pi.

Initially, the obdPi project using Raspberry Pi showed promise, but further development stalled due to critical limitations, primarily concerning boot time and power management, essential factors for an in-car computer system.

Raspberry Pi: Addressing the Boot Time Bottleneck

The primary hurdle with the initial Raspberry Pi-based obdPi was the extended boot time upon vehicle ignition. Even with a streamlined Raspbian setup, the system required a considerable 20-30 seconds to become fully operational from a cold start. The complexity of running necessary services like Bluetooth, OLED displays, and wireless connectivity exacerbated this issue, making it challenging to achieve a quicker boot. Exploring solutions like simulated standby hardware, such as Sleepy Pi, still didn’t circumvent the fundamental boot time constraint of the Raspberry Pi itself.

The more I analyzed the requirements, the clearer it became that the Raspberry Pi might be an over-engineered solution for my primary objective: replicating the real-time performance monitoring capabilities of systems like the Subaru WRX multifunction display.

Further research led me to the vibrant Arduino community. Delving into the Arduino platform, its simplicity and rapid boot times quickly positioned it as a compelling alternative to the Raspberry Pi, particularly for this application.

Raspberry Pi vs. Arduino Uno R3: Selecting the Right Tool

When comparing the Raspberry Pi and the Arduino Uno R3 for in-car projects, their distinct strengths and weaknesses become apparent. The Raspberry Pi, designed to host a complete operating system, offers robust processing power and multitasking capabilities but lacks native sensors and demands a consistent power supply. Conversely, the Arduino Uno R3 excels in simplicity, expandability, and remarkably fast boot times. However, it doesn’t match the Pi’s raw processing muscle or multitasking efficiency.

For the obdPi project, while expanding functionality beyond basic monitoring was appealing, the trade-off with prolonged boot times was a significant concern for a car-integrated system. The Arduino Uno R3, with its focus on real-time responsiveness and simplicity, appeared to be a more fitting choice for my immediate needs.

Investigating Arduino Uno R3 for OBD2 Integration

To explore the Arduino option, I acquired an Arduino Uno R3 from Amazon. With just a standard USB 2.0 cable and the Arduino IDE on my laptop, I had the Uno R3 operational swiftly.

The user-friendliness of the Arduino platform was immediately striking. Coming from the often more complex Raspberry Pi environment, the Arduino IDE’s intuitive nature and the abundance of clear, concise tutorials were refreshing. Within minutes, I had basic programs running and even managed to connect my obdPi 16×2 OLED screen to the Arduino!

While researching existing Arduino OBD-II projects, I discovered Freematics, a company specializing in open-source OBD-II Arduino hardware. They offer various wired and wireless OBD-II adapters, and I opted for their V2 UART Adapter to streamline the connection process.

Simplifying OBD2 Connection with Freematics

The Freematics V2 UART adapter simplified the OBD2 interface, providing both power and OBD-II data through a single cable. Designed for compatibility with Freematics’ ArduinoOBD library, setting up basic OBD-II data reading became remarkably straightforward.

A fundamental sketch to read engine RPM is concise and easy to understand:

#include <wire.h>
#include <obd.h>

COBDI2C obd;

void setup() {
  // Use the debug LED as output
  pinMode(13, OUTPUT);
  // Start communication with OBD-II adapter
  obd.begin();
  // Initiate OBD-II connection until success
  while (!obd.init());
}

void loop() {
  int value;
  // Save engine RPM in variable 'value', return true on success
  if (obd.read(PID_RPM, value)) {
    // Turn on LED on Arduino when RPM exceeds 3000
    digitalWrite(13, value > 3000 ? HIGH : LOW);
  }
}

This code snippet exemplifies the simplicity of using Arduino Uno R3 with OBD-II, especially compared to the more complex Bluetooth OBD-II setup on a Raspberry Pi. The single-cable solution further simplifies the hardware aspect, making it ideal for in-car applications.

With basic OBD-II data access established, the next step was to implement a suitable display. Initially, I considered reusing the 16×2 OLED from the Raspberry Pi project. However, this would necessitate additional cabling within the car’s interior.

Enhancing Display with an LCD Shield

Revisiting the Freematics website, I discovered a 3.5″ Touch LCD Shield designed for the Arduino Mega.

This DFRobot shield is engineered for seamless integration with the V2 UART cable, featuring pre-wired male connectors at the display’s base, perfectly suited for my project’s needs. I promptly ordered one to enhance the visual output of the Arduino OBD2 monitor.

While awaiting the LCD shield, I sourced a generic Arduino Mega from a local Microcenter. (Megas are also available on Amazon).

Note: Freematics also offers a kit that includes the LCD Shield, Mega, and V2 Cable, but purchasing the Mega separately proved slightly more economical.

Upon the LCD shield’s arrival, I assembled the components:

Leveraging example sketches from the Freematics Github, I quickly had the LCD shield displaying OBD-II data.

Freematics’ hardware and software provided a solid foundation, resulting in a functional Arduino OBD-II performance monitor. However, to personalize the project further, I decided to delve into the Freematics code to customize the display and create a more visually appealing GUI layout.

Inspired by COBB Accessport: Designing a Custom GUI

My original obdPi concept aimed for seamless dashboard integration. With the Freematics LCD shield, the project evolved towards a standalone performance monitor, drawing inspiration from devices like the COBB Tuning Accessport.

The COBB Accessport is a popular tool for ECU tuning, allowing users to manage and monitor vehicle performance. Its real-time data display and logging capabilities are highly valued in the automotive enthusiast community.

While ECU tuning wasn’t my focus, the Accessport’s real-time performance data visualization and logging features were highly relevant to my Arduino OBD2 project. I aimed to replicate a similar user experience using the Arduino platform.

Having addressed the hardware components, my attention shifted to software development. While Freematics’ Arduino libraries provided essential OBD-II data, the default display and GUI lacked the visual appeal and customization I desired.

Crafting a Custom GUI for Arduino OBD2

I began by examining the Freematics example code, identifying and removing unnecessary sections to streamline the libraries for my specific needs. The original code, while robust, wasn’t easily adaptable for features like screen rotation or page-based layouts.

Consequently, I dedicated considerable time to refactoring and optimizing the core libraries. After successfully implementing a portrait-oriented display, I proceeded to design and implement custom gauges and menus.

Initial progress was incremental.

However, I gained a newfound respect for early GUI developers as I tackled the challenges of graphical interface programming. Through experimentation and iteration, I successfully created rotating gauges. Calculating endpoints and positioning labels and shapes involved revisiting geometric principles, proving surprisingly engaging.

Ultimately, I developed functional gauges and implemented touch screen navigation to cycle through different gauge displays. With the software and display functional, it was time for in-car testing, but first, a suitable mounting solution was needed.

Inspired by the Accessport’s form factor, I found a case for the Arduino Mega that accommodated the LCD shield. The SunFounder Mega 2560 case on Amazon appeared to be a perfect fit.

The case provided a snug fit and exposed the necessary pin headers for the LCD shield, allowing for seamless reassembly.

For in-car mounting, I opted for an Anker air vent magnetic phone mount. This offered flexibility in positioning and, combined with the new case, provided a suitable surface for attaching the magnetic patch.

Power Management and In-Car Integration

The Freematics adapter draws power from the OBD-II 12V pin, a constant power source. To prevent battery drain when the car was off, I needed a way to switch off the Arduino. Choosing a hardware solution over software-based power management, I created an inline kill switch using LED inline power switches. I modified the switches, extending the Freematics data lines and using 1×4 connector housings for easy integration.

With the kill switch completed, the Arduino OBD2 performance monitor was ready for in-car installation. The Freematics adapter’s single cable simplified routing, allowing for a clean setup. I connected the kill switch, mounted the Arduino using the magnetic mount, and initiated a test run.

The video demonstration showcased the operational boost and RPM gauges. The successful in-car integration was a significant milestone, leaving only code refinement and the addition of more gauges as remaining tasks.

Project Status and Community Engagement

Unfortunately, a house move interrupted the project, placing it on hold for several months. Upon resuming work, I transitioned to a Subaru WRX, a vehicle already equipped with performance monitoring features, diminishing the immediate need for the Arduino carputer. Details of this transition are available on my other blog.

Despite the project’s pause, I wanted to share the progress and insights gained. The working code is available on my Github here.

While future applications for the Arduino carputer are yet to be determined, the experience and knowledge gained are invaluable. I hope this project inspires others and provides helpful resources. For questions or discussions about the project, please feel free to reach out via email. I welcome collaboration and look forward to seeing how others might expand upon this foundation!

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 *