Coder Social home page Coder Social logo

obd-json-logger's Introduction

obd-json-logger

Scripts to capture OBD-II data into JSON format for analytics.

Additional scripts and service examples are provided for JSON logging from gpsd/gpspipe (gpspipe.py) and accelerometer data (9dof.py) using Adafruit 9-DOF ACCEL/MAG/GYRO+TEMP BREAKOUT BOARD - LSM9DS1 from https://www.adafruit.com/product/3387

prerequisites

You'll need an OBD-II to USB serial interface to read the data. I'm using a Scantool OBDLink SX.

The scripts are developed and tested on Raspberry Pi platform. It should work with any model Pi, though you'll need a car USB charger for power.

If you'd also like to collect GPS data to complement the OBD-II readout, there's a service and script to collect data from a USB GPS device supported by gpsd. I'm using a u-Blox 7 GPS/GLONASS receiver.

installation

Install Python 3 and the obd package (pip3 install obd)

Plug in the OBD-II connector and try running the script with "python3 obd2json.py". It should start outputting JSON data to a log file in the /home/pi directory.

To start the script automatically, copy the obdii.service file to /lib/systemd/system and run:

sudo systemctl enable obdii

You can also start it immediately with sudo systemctl start obdii

If you have a GPS device attached, you can add the included gpspipe service and script to collect GPS data. The GPS and OBD data will be logged as JSON to separate files currently.

output

The obd library will scan for valid codes, and the script will read all Mode 1 diagnostic codes continuously (or, as fast as the interface can supply them, plus a short delay).

The library is documented at https://python-obd.readthedocs.io/en/latest/

The JSON output can be read by any engine that supports JSON input. For example, load the data into Vertica (http://www.vertica.com/) with:

CREATE FLEX TABLE obd();

COPY obd FROM LOCAL 'obd-file' PARSER FJSONPARSER();

SELECT COMPUTE_FLEXTABLE_KEYS_AND_BUILD_VIEW('obd');

-- If using vsql, you may wish to set \x to read the OBD fields more easily

SELECT * FROM obd_view LIMIT 10;

obd-json-logger's People

Contributors

bryanherger avatar

Stargazers

 avatar Pedro Batista avatar Nick Penney avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.