Raspberry Pi Environmental Monitoring

From Michael's Information Zone
Revision as of 13:08, 20 December 2019 by Michael.mast (talk | contribs) (Created page with "==Purpose== To monitor air temperature, humidity, and air quality. ===Air Quality=== A friend sent me a Nova PM Sensor. I do not know python yet, but looking over the script...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

To monitor air temperature, humidity, and air quality.

Air Quality

A friend sent me a Nova PM Sensor. I do not know python yet, but looking over the script that is readily available[1][2] I should be able to modify this to work for my needs.

mkdir -p /home/pi/build/air && cd /home/pi/build/air
sudo apt install git-core python-serial python-enum mariadb-server
wget -O aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py
echo [] > aqi.json
sed -i 's|/var/www/html/aqi.json|/home/pi/build/air/aqi.json|' aqi.py

At this point we can run the script, see output on the screen, and see the history written to the json file.

./aqi.py 
Y: 18, M: 1, D: 18, ID: 0xbc2d, CRC=OK
PM2.5:  0.0 , PM10:  0.0
PM2.5:  0.7 , PM10:  0.7
PM2.5:  0.6 , PM10:  0.6
PM2.5:  0.7 , PM10:  0.7

However, I want the history written to a database. Configure mariadb anyway you want, if you have credentials keep them on hand.

Now we edit the script to work with mysql[3]