Name Last Update
FreematicsOBD Loading commit data...
Daemon Task.png Loading commit data...
PID_SPEED.png Loading commit data...
README.md Loading commit data...
guide_compilation.mp4 Loading commit data...
path.png Loading commit data...
script_gps.py Loading commit data...

README.md

Carrying out a vehicle datalogger

Introduction

The goal of this project is to develop a kind of datalogger collecting different pieces of information from OBD-II (On-board diagnostics), GPS, and IMU (Inertial measurement unit) and to store them into a CSV file in an SD card. The developped datalogger has to meet certain requirements to operate. These are:

How to run the project ?

Once you fulfill all the needs above, you clone the depository then you load the ./FreematicsOBD/datalogger/simple_obd_test.ino using the Freematics Arduino Builder. You choose the appropirate target board. Tick Rebuild Core and Rebuild Libs. Finally, connect your board to the computer, click on refresh then click on the last added serial port to upload the project. Now, you can connect the device to the OBD port of the vehicle. Turn on the engine and wait until you hear a beep from the board buzzer. At this time, the board is ready to collect information. If the buzzer does not work, you just reconnect the board and wait again. If you want to see the data written in SD card in real time and visualize them on your screen. You may need a longer USB wire. However, you need to set USE_SERIAL to 1 (otherwise 0) which exists in the ./FreematicsOBD/datalogger/simple_obd_test.h. If you want to collect just GPS and IMU data while cycling you can power the board with a power bank. You will need to set USE_OBD to 1 (otherwise 0) which exists in the same header file. In order to avoid collecting data during traffic jumps you can set SLEEP_STOP to 1 (otherwise 0). This makes the board go to deep sleep for 5s.

How to visualize the collected data ?

To plot some magnitudes or the path, you can use the python script. This script needs two arguments. The first one is the name of the CSV file. The second one is HTML file which can be opened with a navigator and see the journey path. You can also reduce the number of points drawn on the map by uncommenting the call of rdp function. This one has a parameter called epsilon. The bigger epsilon is the lesser points you get.

To plot a magnitude you can follow the examples given in the script file. Example of launching the python script: python3 script_gps.py 27.CSV Trajet.html.

Example of visualized GPS points

Example of visualized GPS points

Example of plotting OBD Speed

Example of plotting OBD Speed

Gettig started with code

The project uses the operating system FreeRTOS. It contains 4 tasks as showing the table below:

Task Priority Role
Task1 1 Collecting the OBD data with 1 sample/90ms
Task2 1 Collecting GPS data(longitude, latitude, altitude, GPS speed) and IMU data (accelerometer, gyroscope and magnetometer along the 3 axes (X, Y, Z))
Task3 1 Collecting the OBD data with 1 sample/60s
Daemon Task 3 Writing data in SD card

Below is a table representing the various OBD data required, as well as how often they are taken:

Data description OBD-II PID 1 sample/90ms 1 sample/60s
SPEED 0x0D x
AMBIENT_TEMP 0x46 x
PID_RPM 0x0C x
ENGINE_REF_TORQUE 0x63 x
PID_RUNTIME 0x1F x
BAROMETRIC 0x33 x
FUEL_LEVEL 0x2F x
HYBRID_BATTERY_PERCENTAGE 0x5B x

Daemon Task

Daemon Task concept

The daemon task is structured as shown in the diagram above. Each data collected is subsequently placed in a queue, before being written in the SD card.