Building your weather station using a RaspberryPi Zero

Guilherme Souza
3 min readJan 31, 2021

--

Assembled RaspberryPi Zero with Breakout Garden, screen and sensor

When I moved to Germany from South America, I had no idea that I had to monitor or even control the humidity inside my apartment.
I had a few options, buying a thermometer with a humidity sensor or building my own, so I chose the latter, because why not?

Since this was my first project using sensors on a RaspberryPi, I went for Pimoroni, they sell a Breakout garden that helped me overcome my lack of soldering skills.

The project is published on https://github.com/guilhermef/pi_weatherstation

Pimoroni components

It arrived after 1 week, on antistatic bags and cute stickers, it was time to start coding the project.

Both the BME680 sensor and the LCD screen have a Python library to interact with it.
* https://github.com/pimoroni/bme680-python
* https://github.com/pimoroni/st7789-python

I've tried my best to draw on the screen using nothing but the python Pillow interface, but everything seemed ugly at the end, so I had an idea.

I know a little bit of HTML and CSS, so I could use Jinja2 to render the HTML template with the data, slap some CSS and convert it to an image and read on Pillow.

I was already using Python's AsyncIO on the project, and then I found a library to interface with wkhtmltopdf(I know it says PDF, but it can convert to image also).
The
imgkit library seemed perfect, but it had only one issue, it didn't support AsyncIO, so during the render it would block everything.

To avoid this issue, I've created an async wrapper, named async-imgkit.

With the screen setup, it was time to fetch the data from the sensor.

The solution was pretty straight forward, the async task will fetch the sensor data, setting and clearing an event to trigger the screen render.
All the sensor implementation was based on Pimoroni library examples.

The project is on: https://github.com/guilhermef/pi_weatherstation
On the README, you can find all the steps to install and run it.

Grafana dashboard showing the sensor's data
pi_weatherstation dashboard

Since I would like to track the environment data over time, I've added a Prometheus interface to export the data, then I just had to create a free account on Grafana Cloud and that's it, I have the last 15 days of environment data.

The dasboard source can be found on the examples folder on the project repository

It was a fun experience to develop with physical sensors, I still need to learn a lot about how to properly interpret this data, but this was a nice way to start.

The next steps are:
* Create a 3D model case
* Finally learn how to solder
* Improve the dashboard and the data based on the feedback

--

--