Eleftheria Karagiorgou
Published © CC BY

Mini Weather Station with Raspberry Pi

Teaching physical computing: Mini weather station with Raspberry Pi 3 and Sense HAT, programmed with Scratch and Python.

IntermediateFull instructions provided4 hours3,226
Mini Weather Station with Raspberry Pi

Things used in this project

Story

Read more

Schematics

Scratch full code

Code

Weather Station

Python
from sense_hat import SenseHat
sense = SenseHat()
# Define red and green color
red = (255, 0, 0)
green = (0, 255, 0)
# Take readings from the 3 sensors
humidity=sense.get_humidity()
temperature=sense.get_temperature()
pressure=sense.get_pressure()
# Round the values to one decimal place
humidity=round(humidity, 1)
temperature=round(temperature, 1)
pressure=round(pressure, 1)
# Create the message to show on SenseHat
message = "Temperature is " + str(temperature) + "Pressure is " + str(pressure) + "Humidity is " + str(humidity)
if temperature>18.3 and temperature<26: 
  bg = green
else:
  bg = red
# Rotate SenseHat screen if needed (0, 90, 180, 270)
sense.set_rotation(180)
# Display the message on SenseHat screen
sense.show_message(message, scroll_speed=0.1, back_color = bg)
#Clear SenseHat screen
sense.clear()

Credits

Eleftheria Karagiorgou

Eleftheria Karagiorgou

6 projects • 8 followers
Computer Science and Robotics teacher in K-12 Education, Code Girls Educator, Maker, eSafety Ambassador https://padlet.com/kareri

Comments