Git Product home page Git Product logo

sensorlog's Introduction

sensorlog

I've created this project to support a network of temperature and humidity sensors in my home.

The architecture uses one 'master' server to aggregate and display the logged data, and many clients place around a house to send log data back to the 'master'.

Graph with three temperature sensors and one humidity sensor

alt text

Components

It consists out of three parts:

Logger (python3)

This script does the actual reading of the temperature and humidity values from the supported sensors. It will scan all 1wire slaves and extract the temperature from DS18B20 sensors (maybe other sensors will work as well). It will look for DHT22 sensors as well and retrieve temperature and humitidy values from them. Depending on the configuration it is able to log these values directly into a sqlite database, send them to the included RESTful API or send them via MQTT.

When sending to the RESTful API is not possible (e.g. in case of no network connection or API down) the records will be cached locally in a sqlite database and sent when API is reachable again.

For accessing DHT22 sensors we are using Adafruit_Python_DHT and MQTT is done is with Eclipse Paho.

RESTful API

Built with nodejs and expressjs

Frontend (HTML + javascript)

Built with jquery and plotly.js

Get it running ๐Ÿ•

On the server (where the RESTful API and frontend should be running)

  1. checkout this repository git clone https://github.com/myxor/sensorlog.git
  2. configure api (in the api folder):
    • copy config.example.json file to config.json
    • open the file and adjust the values in the sensors section to your wishes
    • you need the sensor_ids from your 1wire sensors
    • remove or add sensors here as you need
    • give them names :)
  3. install node.js
  4. run npm install
  5. start api by running node api.js
  6. configure frontend (in the frontend folder):
    • copy config.example.json file to config.json
    • open the file and type in the URL where your RESTful API is reachable
  7. you need nginx, apache, lighttp or some other webserver to serve the frontend

On the client (where the sensors are attached and the logger should be running)

  1. configure logger (in the logger folder):
    • copy config.example.ini file to config.ini
    • open the file and replace the HOST and PORT values with the one from the machine your RESTful API is running on
  2. Install python3.6+
  3. Install python dependencies with pip install -r requirements.txt
  4. Run the logger by executing python3 log.py sqlite or python3 log.py restful

Run the RESTful API as systemd service

If you want the RESTful API run as a systemd service you can do the following:

sudo nano /etc/systemd/system/sensorlog-api.service

then insert the following:

[Unit]
Description=Sensorlog RESTful API

[Service]
ExecStart=/usr/bin/node /home/$user/sensorlog/api/api.js
User=$user
TimeoutSec=30

[Install]
WantedBy=multi-user.target

replace $user with the username the service should run as.

After you saved the file you can enable and start the service with:

sudo systemctl daemon-reload

sudo systemctl enable sensorlog-api

sudo systemctl start sensorlog-api

Periodic logging of temperatures and humidities

You can run the logger on your clients by crontab:

The following example will log sensor values every 10 minutes via rest request:

*/10 * * * * /usr/bin/python3 ~/sensorlog/logger/log.py restful

home-assistant compatible

When sending the data via MQTT this project can be used together with home-assistant.

Technology stack

  • Python3 for the data logger
  • Node for the RESTful API
  • jQuery, CSS, HTML for the frontend
  • SQLite for the database

License

MIT

Author

This project was created in 2018 by Marco Heiming

sensorlog's People

Contributors

dependabot[bot] avatar marcoatachelos avatar myxor avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sensorlog's Issues

Show tendencies in UI

  • Tendencies of last X minutes/hours (configurable?)
  • Visualize with arrow which points down or up

Unify language

Translate everything to English.
Even better: Make hard coded strings translatable.

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.