Monitor Temperature and Humidity by Raspberry Pi
In order to find out performance of my dehumidifier, I use Raspberry Pi to detect temperature and humidity in my room and generate interactive plot for monitoring. Here is the step-by-step tutorials.
- Components to prepare
Raspberry pi 3 Model B (link)
DHT22 (link)
Dupont Cable Jumper Wire (F-M) (link) x 3
10k Ω resistor x 1
breadboard
2. Wiring the components
Follow the illustration in https://www.rototron.info/wp-content/uploads/DHT22_02.jpg
3. Install packages on Pi
4. Starter program to test DHT22
Run on Pi by python starter.py
, you should be able to get output like 83.80000305175781,25.600000381469727
5. The final program that writes results to a csv file for record
6. Use crontab
on Pi to automatically trigger script in step 5 for monitor
chmod +x /abs/path/to/dht/cron.py
crontab -e # edit crontab on pi
*/5 * * * * /abs/path/to/dht/cron.py # add this line to crontab
7. Write a simple service to generate interactive plot for the history records. Thanks to plotly!
8. Make sure you got similar project structure like this and launch web service at the project folder
project/
cron.py
monitor.html
record/
dht.csv
python -m http.server # Launch a http server
9. Open the web page by browser (in any machine that can access to Pi)
http://x.x.x.x:8000/monitor.html
Now I know my dehumidifier is working well!