Vehicle OBD-II data logger based on Arduino
1). How to acces vehicle speed in real time ?
2). Engine error codes ? EFI issues ???
Interesting Applications
Hardware Requirements
- Arduino MEGA main board
- Arduino MEGA IO extension board by DFRobot (with MicroSD socket)
- LCD4884 shield for Arduino
- MTK3389 GPS receiver (with 5Hz update speed)
- OBD-II UART adapter
The Arduino OBD-II Kit consists of an OBD-II UART adapter which provides an OBD-II to UART data bridge, and a dedicated library for Arduino. The adapter outputs realtime vehicle data retrieved from OBD-II port as well as regulated power supply sufficent for Arduino and attached devices. The adapter can be integrated into other MCU or embedded systems in additon to Arduino.
The Arduino library is now supporting retrieving
The Arduino library is now supporting retrieving
- Vehicle speed
- Engine RPM
- Throttle position
- Calculated/absolute Engine load
- Engine coolant temperature
- Intake temperature
- Intake pressure
- MAF flow pressure
- Fuel pressure
- Barometric pressure
- Ignition timing advance
- Engine running time
- Vehicle running distance
Power Lines:
- Red: VCC (connecting to Arduino’s VCC)
- Black: GND (connecting to Arduino’s GND)
Data Lines (Model A):
- Blue: Rx (wired to Arduino’s serial Tx)
- Yellow: Tx (wired to Arduino’s serial Rx)
Data Lines (model B):
- Blue: SDA
- Yellow: SCL
The Library
A dedicated Arduino library is developed and maintained regularly, providing a set of easy-to-use APIs to retrieve real-time data from a vehicle.
Here is an example code of a simplest engine RPM indicator, which uses the pin 13 LED (built in every Arduino board) to indicate whether the engine is above 3000 rpm.
#include <Wire.h> #include <OBD.h> COBD obd; /* for Model A (UART version) */ void setup() { // we'll 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)) { // light on LED on Arduino board when the RPM exceeds 3000 digitalWrite(13, value > 3000 ? HIGH : LOW); } }
Most commonly use PIDs are defined in OBD library as followings.
Engine
- PID_RPM – Engine RPM (rpm)
- PID_ENGINE_LOAD – Calculated engine load (%)
- PID_COOLANT_TEMP – Engine coolant temperature (°C)
- PID_ENGINE_LOAD – Calculated Engine load (%)
- PID_ABSOLUTE_ENGINE_LOAD – Absolute Engine load (%)
- PID_TIMING_ADVANCE – Ignition timing advance (°)
- PID_ENGINE_OIL_TEMP – Engine oil temperature (°C)
- PID_ENGINE_TORQUE_PERCENTAGE – Engine torque percentage (%)
- PID_ENGINE_REF_TORQUE – Engine reference torque (Nm)
Intake/Exhaust
- PID_INTAKE_TEMP – Intake temperature (°C)
- PID_INTAKE_PRESSURE – Intake manifold absolute pressure (kPa)
- PID_MAF_FLOW – MAF flow pressure (grams/s)
- PID_BAROMETRIC – Barometric pressure (kPa)
Speed/Time
- PID_SPEED – Vehicle speed (km/h)
- PID_RUNTIME – Engine running time (second)
- PID_DISTANCE – Vehicle running distance (km)
Driver
- PID_THROTTLE – Throttle position (%)
- PID_AMBIENT_TEMP – Ambient temperature (°C)
Electric Systems
- PID_CONTROL_MODULE_VOLTAGE – vehicle control module voltage (V)
- PID_HYBRID_BATTERY_PERCENTAGE – Hybrid battery pack remaining life (%)
Additional defines can be added to access all OBD-II PIDs which the car’s ECU provides. The complete source code of the library and examples is hosted on GitHub.
Comments
Post a Comment