The following explanation is written in the National Diet Library Temperature and Humidity Control Page.
========== The library of the National Diet Library is equipped with an air conditioner that can control the temperature and humidity. We aim to prevent sudden fluctuations in temperature and humidity throughout the year and even during the day. We also try to make the temperature / humidity difference from the reading room as small as possible. ==========
It also states that the higher the temperature, the greater the saturated water vapor content, so it is necessary to optimally adjust the temperature in order to control the humidity.
I'd like to create an alert when the humidity exceeds 65%, but before that, I thought I'd keep a record of the hourly humidity and temperature in my environment, and then the barometric pressure.
I will write down what I did for that.
Raspberry Pi Zero W I purchased a pin header separately and soldered it. Infrared + environmental sensor for Raspberry Pi Zero "RPZ-IR-Sensor" Rev2.0 (terminal mounted + external sensor)
OS Debian GNU/Linux Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l
Keep I2C enabled in Raspberry Pi Settings-Interface.
①Raspberry Pi Zero W ② Power supply ③ To mouse and keyboard ④ To the display ⑤ Infrared + environmental sensor for Raspberry Pi Zero ⑥ Temperature / humidity / barometric pressure sensor ⑦ Terminal mounted + external sensor temperature / humidity / barometric pressure sensor ⑧ Infrared communication terminal (not used this time) ⑨ Light (illuminance) sensor (not used this time) Note: ⑥ also detects the heat generated by the Raspberry Pi Zero, so use the measured value of ⑦.
https://www.indoorcorgielec.com/products/rpz-ir-sensor/ I unzipped the sample program rzp-sensor.zip and used it as it is.
The log output method is described at the end of readme.txt.
$ python3 rpz_sensor.py
BME280 0x76
Temp : 19.9C
Pressure : 1006.0hPa
Humidity : 38.6%
BME280 0x77
Temp : 23.0C
Pressure : 1005.6hPa
Humidity : 35.0%
TSL2572
Lux : 176.3lux
BME280 0x76 is the measured value of assembly ⑦. BME280 0x77 is the measured value of assembly ⑥. The temperature about 3 ° C higher than ⑦ seems to be due to the heat generated by RaspberryPy Zero. Since the temperature is higher than ⑦, the humidity value is low. TSL2572 is the measured value of assembly ⑨.
do.sh
#!/bin/sh
date +"%Y/%m/%d %T"
cd rpz-sensor/python3
python3 ./rpz_sensor.py -l ./log/logfile.csv
Put the shell script into executable mode.
$ chmod +x do.sh
I will try it.
$ rpz-sensor/do.sh
2020/04/14 18:37:07
BME280 0x76
Temp : 21.9C
Pressure : 1008.8hPa
Humidity : 45.7%
BME280 0x77
Temp : 22.7C
Pressure : 1008.4hPa
Humidity : 44.8%
TSL2572
Lux : 170.7lux
The log is being output.
$ cat logfile.csv
Time,Temp ch1,Temp ch2,Pressure ch1,Pressure ch2,Humidity ch1,Humidity ch2,Lux
2020/04/14 18:37,21.9,22.7,1008.8,1008.4,45.7,44.8,170.7
$ crontab -e
The editor will start, so set it to measure at zero minutes every hour and output the log.
# m h dom mon dow command
00 * * * * rpz-sensor/do.sh
Restart cron for the settings to take effect.
$ sudo /etc/init.d/cron restart
[ ok ] Restarting cron (via systemctl): cron.service.
When I checked it a few hours later, the log was output according to the scenario.
cat logfile.csv
Time,Temp ch1,Temp ch2,Pressure ch1,Pressure ch2,Humidity ch1,Humidity ch2,Lux
2020/04/14 18:37,21.9,22.7,1008.8,1008.4,45.7,44.8,170.7
2020/04/14 19:00,21.6,22.8,1009.6,1009.2,47.5,45.7,15.6
2020/04/14 20:00,18.7,22.4,1010.8,1010.3,60.6,50.2,87.9
2020/04/14 21:00,18.7,22.3,1011.3,1010.9,57.5,48.3,88.9
I tried it with the following configuration.
pi@raspberrypi:/home $ ls
pi
pi@raspberrypi:/home $ cd pi
pi@raspberrypi:~ $ ls
Desktop Downloads Music Public Videos
Documents MagPi Pictures Templates rpz-sensor
pi@raspberrypi:~ $ cd rpz-sensor
pi@raspberrypi:~/rpz-sensor $ ls
do.sh python3 readme.txt
pi@raspberrypi:~/rpz-sensor $ cd python3
pi@raspberrypi:~/rpz-sensor/python3 $ ls
__pycache__ bme280i2c.py log rpz_sensor.py tsl2561.py tsl2572.py
pi@raspberrypi:~/rpz-sensor/python3 $ cd log
pi@raspberrypi:~/rpz-sensor/python3/log $ ls
logfile.csv
-Automation of graph display based on log data ・ Alert to LINE Bot when the humidity exceeds a certain level