PayPal provides a safe and secure way to purchase online. We never see your credit card number or store it on our server. You can use your PayPal account or major credit card to process your order online safely. 

Featured Project
Raspberry Pi with Speaker and Microphon

This project walks through the steps we followed to get the AI framework PyTorch to run on a Raspberry Pi 4 

Weather Display with Sense HAT
Weather Display with Sense HAT

Weather Display with Sense HAT


With the new Sense Hat, you no longer need extra parts, all sensors are included! Simply attach the Sense Hat atop your Raspberry Pi 3 and you are all set!


- Gyroscope                  - Temperature


- Accelerometer           - Barometric Pressure


- Magnetometer           - Humidity


Follow along with this simple tutorial and discover the weather around you.


We will be using the Temperature, Humidity and Pressure sensors for this project.


Step 1: Gather Components

Sense HAT in Case

The following components are used for this project:

Raspberry Pi 3

Sense Hat

Sense Hat case New! See-through enclosure protects your LED screen without obstructing visibility.

HDMI Cable




Looking for a great introduction to Raspberry Pi? Try the Zagros Raspberry Pi 3 Starter Kit which has everything you need to begin discovering Raspberry Pi.

Step 2: Update and Upgrade


Make sure your system is updated and upgraded with the latest version by running the following commands in the Terminal. (Terminal is the computer icon on the Raspberry Pi menu bar)

1) Type this command and press enter.

sudo apt-get update

2) Type this command and press enter.

sudo apt-get dist-upgrade


Step 3: Open Python editor

Open Python

1) Press Menu button.

2) Navigate to Programming >> Python-3 (IDLE).

You have now opened the Python Shell.

3) Click File.

4) Click New File.


Step 4: Import modules for your project

Type or copy into editor:

from sense_hat import SenseHat

import time


Step 5: Set variables
Set Variables

Pi was created in England, so the temperature output is in Celsius. The conversion to Fahrenheit is included below.

Type or copy into editor:

sense = SenseHat()

temp = round(sense.get_temperature()*1.8 +32)

humidity = round(sense.get_humidity())

pressure = round(sense.get_pressure())

message = 'Temperature is %d F Humidity is %d percent Pressure is %d mbars' %(temp,humidity,pressure)


Step 6: Display weather on Sense Hat!

Display Weather

The show_message() command displays your message like a banner across the LED screen. Scroll_speed allows you to control how fast the message rolls across. I've set the text_colour to pink and the back_colour to blue. Find your favorite contrast and change your colors.

Type or copy into editor:

sense.show_message(message, scroll_speed=(0.08),text_colour=[200,0,200], back_colour= [0,0,200])

To clear the screen after the message is complete. Type:


To run your program, press F5.

(The Python file for the project is attached)


Step 7: Keep a weather log

Weather Picture

Great! You created a weather banner!

Now you can amend your program to save your weather data in a text file.

At the very top of the file add this module:

from time import asctime


Step 8: Create text file

Create Text File

At the very bottom of the file add a while statement:

while True:

log = open("weather.txt", "a")

The second argument indicates how the file is to be opened "a"= append and "w" will write over anything that was was already in the file.

now = str(asctime())

Asctime() outputs a time-stamp in an easy to read form.

log.write(now + " " + message + "\n")




Waits 30 seconds before continuing with the loop.

You can adjust this time however you like. If you have a portable battery pack you can take samples of weather in different rooms, the basement, garage, inside your car, and outside!

To run your program press F5 while the cursor is in your program file.


Step 9: Alternate loop

Alternate Loop

Your program will continue to run without end unless you kill it in the Shell by typing Ctrl + C.

You can set the amount of times it will run by using a for loop to set the range:

for i in range(10):

log = open("weather.txt", "a")

now = str(asctime())

log.write(now + " " + message + "\n")





Step 10: Weather.txt sample

Weather.txt Sample

Open the weather.txt file and it should look something like this.

With the current setting, each time you run the program the new data will be appended after the last line.

Step 11: ## Commenting tip
Commenting Tip

As a note, the message will display completely before the weather is logged to the text file.

If you would like to skip the message displaying on your Sense Hat, make it a comment:

1) Highlight text.

2) Click Format.

3) Click Comment Out Region.


1) Highlight text.

2) Alt + 3.



A project to discover the weather around you.

Copyright 2022 - Zagros Robotics, All Rights Reserved - Please send webpage comments or corrections to - Zagros Robotics,PO Box 460342, St. Louis, MO 63146, for answers to any questions.