Member-only story

Raspberry Pi Weather Station

Measuring the temperature and humidity of my room and saving them in a database

Christian Behler
3 min readMay 24, 2020

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.

The circuit with the two sensors connected to the Raspberry Pi using power, ground and two data pins, image by author.

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…

--

--

Christian Behler
Christian Behler

Written by Christian Behler

M. Sc. Computer Science and Physics, Indie Game/Software/Web Developer, Writer, 3D Artist, and too many other interests. https://pingpoli.medium.com/membership

No responses yet