Git Product home page Git Product logo

obd-server-python's Introduction

obd-server-python

Lightweight server written in Python for storing OBD-II readings, similar to the obd-server by pires. This is designed for use with the android-obd-reader app, also by pires.

Pre-requisites

The server requires the following to read and store OBD data:

  • Python 2.7
  • PostgreSQL server

In addition, the server requires the installation of Flask and Psycopg2 for the web service and database connection. These may be installed with pip install -r requirements.txt.

Usage

Run server.py. That's it! You may now send your POST or PUT requests to the server.

You may also view all of the logs for a given vehicle ID by going to /view/<vehicleid>.

Configuration

By default, the server will bind to port 5000, or to a port specified by a PORT environment variable. The server will connect to a database through a URL given in the DATABASE_URL environment variable.

Docker

You can build and run this project using Docker.

docker build -t obdserver .

docker run -it --rm \
    -p "5000:5000" \
    -e DATABASE_URL="postgres://user:pass@host:port/db" \
    obdserver

Or, if that's one command too many, set the database URL in docker-compose.yml and run docker-compose up!

obd-server-python's People

Contributors

seanhold3n avatar

Stargazers

 avatar

Watchers

 avatar  avatar

obd-server-python's Issues

Add vehicleid links in /view/

Instead of just plaintext, make each vehicleid a hyperlink to /view/ to allow the user to view vehicle-specific readings.

KML export

Export sets of points, perhaps by time or geofence, into KML format. Line export with variable color based on speed? The possibilities are endless!

Vehicle overview page

Create view that contains metrics for total drive time, total estimated mileage, service history and upcoming events, etc.

Add details about Postgres installation to Readme

A few notes worth mentioning for setting up an environment to run the server:

  • The Postgres server itself can be in another location, but psycopg2 still requires some Postgres libraries to operate (on Linux, libpq-dev for a client-side application)
  • Maybe a note about DB admin through postgresql-client-9.5

Unknown internal database errors

Sample error message:

heroku[router]: at=info method=PUT path="/" host=.herokuapp.com request_id= fwd="***" dyno=web.1 connect=1ms service=4ms status=500 bytes=452
app[web.1]: Traceback (most recent call last):
...
app[web.1]: File "server.py", line 39, in home
app[web.1]: InternalError: current transaction is aborted, commands ignored until end of transaction block
app[web.1]: (json_data['vin'], json_data['timestamp'], json_data['latitude'], json_data['longitude'], json.dumps(json_data['readings'])))
app[web.1]: 10.97.206.141 - - [07/Nov/2016 22:20:12] "PUT / HTTP/1.1" 500 -

Keys out-of-date

New version of the app has the following changes for ObdReading:

  • Added altitude (type double)
  • vin is now vehicleid

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.