← Back

ofxAutomobile

github.com/haradama/ofxAutomobile · @haradama
OF 0.11 Hardware Interface

openFrameworks addon for reading vehicle information using OBD2-PID

3 0 Last commit 3y ago Created 6y ago

README

ofxAutomobile



ofxAutomobile is an openFrameworks add-on for communicating with vehicles using the OBD2 (On-Board Diagnostics) protocol. It provides a simple interface for connecting to OBD2 adapters (such as ELM327) over a serial connection and sending OBD2 commands to query various vehicle parameters, such as engine speed, coolant temperature, and throttle position.

Usage



MethodDescription
bool setup(const std::string& port_name, int baud_rate = 115200)Initializes the OBD2 connection with the specified serial port and optional baud rate. Returns true on success, false otherwise.
bool query(const std::string& command, std::string& response)Sends an OBD2 command and reads the response. Returns true on success, false otherwise.


Simulate your application



tools/obd2_simulator.py simulates an OBD2 adapter using the ELM327 command set. It listens for OBD2 commands on a specified serial port and sends random responses for a few common OBD2 PIDs.

Requirements



Installation



1. Install the required pyserial library:

$ pip install pyserial


Usage



Run the OBD2 simulator by specifying the port and baud rate as command-line arguments:

$ python tools/obd2_simulator.py --port /dev/ttyVUSB2 --baudrate 115200


Replace /dev/ttyVUSB2 with the desired virtual serial port and 115200 with the desired baud rate.

Command-line Arguments



Supported OBD2 Commands



The simulator currently supports the following OBD2 commands:

You can expand the handle_command method in the obd2_simulator.py script to support more OBD2 commands as needed.

Get this addon

HTTPS
SSH