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.
- Pi sensor collector
OR
- Arduino sensor collector (not written yet)
-
MQTT server
-
MQTT subscriber
-
Redis server
-
Node.js web server
-
(Optional, not included) MySQL server
OR
OR
-
- Recommended. DHT22s are much more accurate, for only a tiny bit more.
-
Breadboard
-
Jumper wires
-
10k ohm resistor (pull-up)
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.
The server must be running first, or the collector won't be able to make a connection to the MQTT server.
Server:
-
Clone and enter this repository on your server
-
If you have a firewall, two TCP ports need to be opened: 1883 for receiving collector messages, and 8080 for the web server.
-
Run
docker-compose up --build
-
Server is ready to accept new connections from collectors, and the web server should be visible at
http://server_ip:8080
Collector:
-
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)
-
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.
-
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.
-
You should get temperature and humidity values as output, and the data will be published via MQTT for the listening server.
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?