For a long time I wanted to build a weather station at home because I like meteorology and for the fun of doing it. So I decided to stop waiting and just do it :-)
Connecting the sensors
I wanted something easy to attach to my old Pi, a Raspberry Pi 2 model B+, that would let me easily read the data from the sensors. The Pimoron's Weather HAT fit perfectly with what I wanted:
- Just connect it to the GPIO interface
- Download and install the Python library provided by Pimoroni
Pimoroni has a good tutorial that helps you build it and solve some of the common issues. There are also other articles from the community that are really helpful.
One good thing about this Weather HAT is that it is possible to connect a wind and a rain gauge. I don't have so much space in my balcony so I didn't get these sensors, but it is something that I would like to have in the future.
There is a good set of examples to read the data from the sensors and display it available in the Weather HAT's GitHub.
The Challenges
But it has an important downside, the sensor temperature is affected by the Pi's CPU as it is very close to the board. So the temperature needs to be compensated, which is not as simple as applying a fixed offset as stated in the Pimoroni's tutorial. Instead I tried to apply a linear regression by obtaining the temperature from another weather station that, luckily, is close to my home.
Apart of installing the Weather HAT and reading the data from the sensors, the most important challenge was finding the best place for it in the balcony and how to isolate it from the external conditions, while at the same time allowing enough ventilation to avoid heat accumulation inside.
Protecting the Weather Station from the Environment
Once I had the Weather HAT installed I used the following materials to place the station on the balcony:
- A transparent plastic lunchbox
- A base enclosure for the Pi
- Some adhesive protectors for furniture
- Some glue
Maybe a lunchbox is not the best solution but using a Stevenson Screen could be a bit overkill.
I used the furniture protectors to separate a little bit the Pi from the back of the lunchbox, this way the sensor has some additional separation from the wall.
At the same time I made some holes in the lunchbox to let the air flow inside to cool the Pi. I made some of the holes on the side where the sensors are located and the others on a lateral.
A few days later I noticed that, due to that holes, on windy days the measure of the temperature sensor can provide values a little bit lower than the real one. But I prefer this to having the Pi without this air cooling. I don't have the perfect materials, so I can't expect to have the perfect measures.
Calibrating The Temperature Sensor
As I mentioned above the readings of the temperature sensor need to be compensated as it is close to the Pi's CPU.
The Pimoroni Python library for the Weather HAT has an attribute to set an offset that is applied to the device temperature measure. So I tried comparing the Weather HAT sensor values with the temperature provided by a nearby weather station.
What I noticed was that the offset to apply can't be a fixed value. The difference between the real temperature and the values provided by the Weather HAT was always between 12º and 16º.
To solve this I create a small script to get temperature data from both stations at the same time. With this series of data I was able to create a linear regresssion model to calculate the offset that should be applied to the HAT's device temperature reading.
It is not still perfect. When the device temperature is close to 30º the difference is quite high, but for the moment, it seems a little bit better than applying a fixed offset as you can see below.
In the next article I'll describe my Python learnings implementing the software to gather the measures, display it and sending it to an external system.


Top comments (14)
Great work so far man! I can't wait to get my Raspberry PI 5! Any good project ideas using Raspberry Pi you had in mind (Obviously not your idea since you are doing it lol).
Great post and keep it up :D
Thanks a lot!
One thing that is in my mind is to use a Pi 5 to see if it is feasible to have a "personal" AI system to play with.
Another idea can be install a NextCloud to host your personal cloud. This is a good replacement of the private cloud providers for syncing the pictures from the mobile phone, calendar, contacts, ...
Privacy matters this times! :-)
Love this kind of project. I've been exploring what you can actually run on a Pi these days, turns out small AI models (like Llama 3 8B quantized) can run on a Pi 5 with 8GB RAM. Slow, but it works. Combining that with sensor data like yours could make for a pretty cool AI-powered weather predictor that runs entirely offline. Nice build!
funny part is this is kinda just piling errors on top of each other. biased sensor, regression, then a model. ive been there, ended up debugging why it predicts my radiator turning on
Nice idea, when I have enough data it can be an amazing next step! Thanks Joske!
Let me know how it goes ;)
Yay! I love it! I am also building a tiny weather station! I want to have custom data for my exact location too. I need to look into this! Here is what I have done so far! 😅
I like storms. I like the suspense of the storm rolling in.
Looks really cool!
It is curious that the header of your page is quite similar to the one I have in my web app. AI generated?
I request the AI to generate an static HTML template to display weather info as I'm really bad at web design xD. It is the only use of AI in this project.
Yes I used ai, I wanted a nice fast display for data as well. I will likely modify it haha!
So ill spill.. my app has secrets! If you click the top left where it says weather station. You can enter any location. I did not want this publicly visible, since there will be alot of passers-by this station and I didnt want children messing with it. Also, I display the live stream of my favorite tornado chaser team when they are "live" on YouTube. It pushes the air quality content out of the way. Ive been trying to get live captions working when the stream is up on my page. Still fighting with Javascript haha.
Seems that you are enjoying it! :-D
The calibration work is the part most people skip. They'd accept the fixed offset and call it done. You built a regression model because you wanted the data to actually mean something, that's the difference between a project that runs and one that reports truthfully.
Awesome work and good write-up!
Thanks!