Raspberry Pi Sense HAT: a Simple Weather Station



Weather station - Raspberry Pi Sense HAT

In this article we have discovered the Sense HAT. Now let’s see how we can program it. In this article, we will see how to get data from the environmental sensors (temperature, pressure, humidity) to create a simple weather station.

The Sense HAT comes with a Python library developed by the Raspberry Pi team. This Python library, called sense_hat, is available HERE. The API reference guide is available HERE.




The weather station is based on the reading of the environmental sensors. Fetching the value of environmental sensors is very simple. Just create a sense HAT object and get the value of sensors as follows:

from sense_hat import SenseHat

sense = SenseHat()
temperature = sense.get_temperature_from_humidity()
humidity = sense.get_humidity()
pressure = sense.get_pressure()

The temperature is in degrees celcius, the humidity is in percent and the pressure in millibars.

I coded a simple weather station demo with GeeXLab. The standalone demo can be downloaded here:

 
Weather Station 0.1.0 – OpenGL 2.1 (Raspbian Jessie)

 
Weather Station 0.1.0 – OpenGL ES 2.0

A thread is available HERE for any feedback or bug-report.

 
To launch the weather station, unzip the archive and start GeeXLab. The weather station demo will be automatically loaded. The source code (Python) of the weather station can be found in the weather_station_src/ folder.


Weather station - Raspberry Pi Sense HAT

 
The weather station demo is also available in the gl-21/rpi/sense_hat_python/weather_station_src/ folder of GeeXLab’s code sample pack.


Weather station - Raspberry Pi Sense HAT

 
The temperature / humidity sensor is located on the Sense HAT board and will display an higher value than the real one if the Sense HAT is directly connected to the GPIO connector of the Raspberry Pi.


Raspberry Pi Sense HAT - Humidity sensor

 
For example, in my lab, the temperature is around 20°C and the temperature sensor value is around 30°C…
This wrong value is caused by the heat produced by the Raspberry Pi board. To fix this issue, I separated the Sense HAT from the RPi with cables (40-pin connector + 40-pin male-male 300mm jumper):


Weather station - Raspberry Pi Sense HAT
Weather station - Raspberry Pi Sense HAT

 
With that patch, the temperature is correct.


Weather station - Raspberry Pi Sense HAT



One comment

  • This project creates a simple DIY Weather Station, thanks for your helpful information.
    One more question:
    Can I use Sense HAT and PI to track weather in a different room, this method seems like can only track weather for current room, and is hard to monitor than other budgets La Crosse weather stations.

Leave a Reply

Your email address will not be published. Required fields are marked *