Giter Club home page Giter Club logo

sensor_gateway's Introduction

Weather sensor interpolation & gateway

This repo contains code to receive data from weather sensors in a sensor network and bridge them to an InfluxDB database (see gateway, and create an interpolated heatmap from the measurements, to be displayed in a map (see genmap).

Requirements

  • Python and the requirements in requirements.txt
  • An InfluxDB database running on port 8086 of localhost.
  • A Grafana instance that can talk to the InfluxDB database, preferably on localhost to avoid CORS issues.
  • (Optional?) A reverse proxy to serve both port 5000 (the gateway, Python + Flask) and port 3000 (Grafana) on the same IP/domain.

Sensor network gateway

See the gateway readme for more information.

Interpolated map

The genmap_influx.py script generates an interpolated map from the latest measurements in the InfluxDB database. The resulting PNG can be used as an overlay to a map.

Requirements

The genmap_influx.py script uses the requirements on requirements.txt.

Installation

No installation is required. The genmap_influx.py script is expected to be invoked from the Flask server, but it can also be invoked manually.

Usage

Usage information is available by running python genmap.py --help, which outputs the following:

usage: genmap_influx.py [-h] [--host HOST] [-q] metric

positional arguments:
  metric       the metric to compute the map for

optional arguments:
  -h, --help   show this help message and exit
  --host HOST  the IP or hostname of the InfluxDB server (port is fixed to
               8086, dafault is localhost)
  -q, --quiet  if set, don't show plots, only save image

Call the script as python genmap_influx.py <metric>.

The database must have a sensors database which must contain a weather table, which must in turn contain measurements with tags sensor_id, latitude and longitude, and a value column with the same name as the provided metric.

There are optional arguments: to specify the IP or hostname of the InfluxDB server (default is localhost) and to run the script without user interaction (i.e. supressing the Matplotlib graphs and saving the map directly to disk, without opening windows). This last option is expected to be used when calling the script from the gateway server.

Results

The script creates a PNG image in false color. The coordinates of the limits of the PNG image (in the form min_lat, max_lat and min_lng, max_lng) are printed to standard output. The last two lines of the standard output, therefore, can be used to configure the bounds of the image when displayed in a map.

The image is expected to be served by a web server and used, for example, in the updated WorldMap panel for Grafana (see here for instructions).

sensor_gateway's People

Contributors

jreyesr avatar

Watchers

 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.