Skip to content

Collect, process, and view temperature and humidity data on various hardware platforms using DHT sensors. Dockerized, and will work with Arduino, Raspberry Pi, Orange Pi, etc.

Notifications You must be signed in to change notification settings

vincebel7/temperature-data-collector

Repository files navigation

temperature-data-collector

An application enabling a custom-built IoT device to collect, process, and display temperature and humidity data from a digital temperature and humidity sensor (DHT)

This is an all-in-one project which includes: collectors for various hardware platforms, an MQTT system (server, subscribers, publishers), Redis server, the ability to write to MySQL, and a web server to monitor live data.

There are two components: Collector, and Server.

Collector

  • Pi sensor collector

OR

  • Arduino sensor collector (not written yet)

Server

  • MQTT server

  • MQTT subscriber

  • Redis server

  • Node.js web server

  • (Optional, not included) MySQL server

Container diagram

Hardware

Board

OR

Sensor

OR

  • DHT22 sensor

    • Recommended. DHT22s are much more accurate, for only a tiny bit more.

Miscellaneous

  • Breadboard

  • Jumper wires

  • 10k ohm resistor (pull-up)

DHT circuit diagram

DHT circuit

Image source

How it runs

Collector code is in the collector directory. This is just a Python script.

Server is everything else (web, redis, etc) and can be run via docker-compose (or each component standalone).

Collectors send data via MQTT to the server. The MQTT subscriber then adds to redis and exports to MySQL (optional). The web server will read from redis.

Getting started

The server must be running first, or the collector won't be able to make a connection to the MQTT server.

Server:

  1. Clone and enter this repository on your server

  2. If you have a firewall, two TCP ports need to be opened: 1883 for receiving collector messages, and 8080 for the web server.

  3. Run docker-compose up --build

  4. Server is ready to accept new connections from collectors, and the web server should be visible at http://server_ip:8080

Collector:

  1. Build the circuit in the "Circuit diagram" section above, with a 10k ohm resistor, DHT sensor, and Orange Pi. Have the data pin going to the proper GPIO port (the collector defaults to PA6)

  2. Connect the Orange Pi to a network. WiFi makes the device more useful, you can use a wifi config tool such as nmtui. For first-time setup, or if your device doesn't have nmtui installed yet, connect via Ethernet first.

  3. On the Orange Pi, clone this repository and run collector/collector.py. Edit the script if you would like to change the sensor model, GPIO port, sample rate, etc.

  4. You should get temperature and humidity values as output, and the data will be published via MQTT for the listening server.

Development notes

For V1:

  • Server: finish credential management (.env files, and their usage in docker-compose)

  • Server: finish setup script

  • Collector: unit tests for Python collector

  • Server: MySQL export functionality in MQTT subscriber

For V2:

  • Collector: Finish Arduino platform

  • Arduino + setup script? Board setup via wifi?

About

Collect, process, and view temperature and humidity data on various hardware platforms using DHT sensors. Dockerized, and will work with Arduino, Raspberry Pi, Orange Pi, etc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published