Member-only story
Raspberry Pi Weather Station
Measuring the temperature and humidity of my room and saving them in a database
A few years ago I created an indoor weather station with my Raspberry Pi. I bought a bunch of temperature sensors on amazon, which were really cheap, like 20 sensors for 2€, and another slightly more expensive sensor that can get temperature and humidity data. Combined with a few resistors, cables and breadboards I managed to assemble them into a working circuit and hook them up to the GPIO ports of the Raspberry. Most tutorials on the internet were using python to read the data from the sensors and while I am not a big fan of python, I was able to adapt the scripts to my needs and get accurate temperature and humidity readings. However, rather than looking into how to use mysql with python, I created a php script that calls the python script and then inserts the data into a database. The php script itself is called every two minutes via a cronjob.
I had my Raspberry set up as a webserver only accessable from the local network, so I created a small website on there that shows the weather data in a more visually appealing way. There is an overview over the last seven days with their average, minimum and maximum temperature and humidity, as well as a detailed daily page, which includes plots of all data points gathered during that day. I…