Coder Social home page Coder Social logo

bme280-backend's Introduction

BME280-backend

Python Flask backend microservice for Bosch BME280 sensor data and calculated meteorogical metrics (https://www.bosch-sensortec.com/bst/products/all_products/bme280)

BME280 is an affordable and accurate digital pressure, temperature and humidity sensor, than can be easily connected to any Raspberry Pi using I2C, therebefore making it ideal for remote temperature/humidity monitoring.

Thanks to Matt Hawkins library (https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/bme280.py), I just had to implement the endpoints and upgrade a few line to Python 3 syntaxis to make it work, also added atmospheric metrics that are calculated using BME280 metrics. I'm not a weather professional, so please double check the formulas. PRs are welcome for fixes/additions.

Configuration and runtime

Edit bme280.py and set sensor BUS and ID properly (tool i2cdetect can help with that)

After ID and BUS are set you can use the included Dockerfile to build the container and then run it with the following commands:

$ sudo docker build -t bme280-backend . $ sudo docker run -p 8000:8000 --privileged bme280-backend

This will expose the service port 8000. Like http://localhost:8000/metrics

After the endpoint is exposed could be easily attached to a metric collector like Telegraf (https://www.influxdata.com/time-series-platform/telegraf/)

This backend implements 3 endpoints

  • /metrics (sensor data in JSON) {"temperature": 20.67, "pressure": 1009.4834511590609, "humidity": 60.5365803099204}

  • /ids (sensor ID info) {"chip_id": 96, "chip_version": 0}

  • /atmos (calculated meteorological metrics/KPI) {"altitude": 0.03168493302340608, "precipitable_water": 2.3728284551975314, "dew_point": 12.898732023314297, "frost_point": 10.110273017462305, "cloud_base": 3124.5071906742814, "humidity_index": 23.40544603781366, "heat_index": 20.71}

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.