What I did to keep track of the humidity and temperature of the archive

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.

What you have prepared

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. image.png

assembly

①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 ⑦. image.png

Prepared sample program

https://www.indoorcorgielec.com/products/rpz-ir-sensor/ I unzipped the sample program rzp-sensor.zip and used it as it is. image.png

The log output method is described at the end of readme.txt. image.png

Testing the sample program

$ 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 ⑨.

Create a shell script to test log output

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

Scheduled execution settings

$ 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

Directory structure

I tried it with the following configuration. image.png

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

Reference books

Razpai Zero Work Book

What I want to do after this

-Automation of graph display based on log data ・ Alert to LINE Bot when the humidity exceeds a certain level

Recommended Posts

What I did to keep track of the humidity and temperature of the archive
Ventilation is important. What I did to keep track of the C02 concentration in the room
What I did to ssh to the VPS Ubuntu environment
What I did to welcome the Python2 EOL with confidence
I want to know the features of Python and pip
H29.2.27 ~ 3.5 Summary of what I did
I want to record the execution time and keep a log.
[Introduction to Python] I compared the naming conventions of C # and Python.
I summarized how to change the boot parameters of GRUB and GRUB2
What I did to save Python memory
I tried to visualize the age group and rate distribution of Atcoder
I tried to extract and illustrate the stage of the story using COTOHA
I tried to verify and analyze the acceleration of Python by Cython
I want to analyze the emotions of people who want to meet and tremble
I connected the thermo sensor to the Raspberry Pi and measured the temperature (Python)
[At Coder] What I did to reach the green rank in Python
What I did when I couldn't find the feature point with the optical flow of opencv and when I lost it
I want to visualize the transfer status of the 2020 J League, what should I do?
How to keep track of work in Powershell
The story of IPv6 address that I want to keep at a minimum
[Python] What I did to do Unit Test
I tried to touch the API of ebay
I tried to correct the keystone of the image
What I did when updating from Python 2.6 to 2.7
I read and implemented the Variants of UKR
I want to customize the appearance of zabbix
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
[Linux] I learned LPIC lv1 in 10 days and tried to understand the mechanism of Linux.
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I tried to automate the article update of Livedoor blog with Python and selenium.
real-time-Personal-estimation (What should I do to prevent the estimation of images outside the category) * Failure.
What I did when I was angry to put it in with the enable-shared option
I just wanted to extract the data of the desired date and time with Django
I tried to compare the processing speed with dplyr of R and pandas of Python
I want to grep the execution result of strace
I tried to summarize the basic form of GPLVM
I checked out the versions of Blender and Python
I want to fully understand the basics of Bokeh
I checked the default OS and shell of docker-machine
I tried to visualize the spacha information of VTuber
I tried to erase the negative part of Meros
What I did to get started with Linux commands
I tried to classify the voices of voice actors
I want to increase the security of ssh connections
I tried to summarize the string operations of Python
I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I want to find the intersection of a Bezier curve and a straight line (Bezier Clipping method)
I tried to verify the yin and yang classification of Hololive members by machine learning
I tried to find the entropy of the image with python
[Python] Visualize Arashi's lyrics with WordCloud and try to understand what I wanted to convey to fans in the 20th year of formation.
I tried to get the location information of Odakyu Bus
I tried to find the average of the sequence with TensorFlow
What I'm glad I studied in 2015 and what I'm thinking of learning in 2016
I want to use only the normalization process of SudachiPy
I want to get the operation information of yahoo route
I made a function to check the model of DCGAN
I tried to illustrate the time and time in C language
I tried to display the time and today's weather w
Hook to the first import of the module and print the module path