The Raspberry Pi Weather Station not only shows you how to get started in IoT, but also gives you an end product that’s useful as well. This project uses the Raspberry Pi Sense HAT in conjunction with the Pi3 and Initial state’s cloud service to build a weather station using the Sense HAT’s sensors to measure the external environment and send it to the cloud where you can view it on any web browser.
Step by Step Guide
For this project, you will need:
Raspberry Pi 3
SenseHAT Add-on board
Micro SD card with Rasbian OS
Raspberry Pi Power Supply
Insert the pre-programmed micro SD into Raspberry Pi 3 micro SD card slot
Connect the SenseHAT add-on board on top of the RPi GPIO pin header
Connect the RPI to the monitor, keyboard & mouse
Now connect the power supply and turn it ON
Wait for RPi to bootup
Initialstate Cloud Account Registration
Go to www.initialstate.com and sign up for a free account
Once logged into your account, go to my account.
Click on “Create a New Key” to generate your key which will be used to stream the data. Write down your access key information.
Initialstate ISStreamer Installation
In order to install ISStreamer, open the Terminal window and type in the following commands:
\curl -sSL https://get.initialstate.com/python -o - | sudo bash
If asked, you may need to enter your Initialstate account credential password to proceed.
In Terminal window type in the following commands:
sudo apt-get update sudo apt-get install sense-hat
Python Coding - Weather Station Code
Open a python editor and save the following code as pi_weather.py (or you can download the
pi_weather.pyfile from below)
from sense_hat import SenseHat from ISStreamer.Streamer import Streamer logger = Streamer(bucket_name="Sense Hat Environment Stream", access_key="YOUR_KEY_HERE") import time import sys sense = SenseHat() sense.clear() var = 30 while var > 0: temp = sense.get_temperature() temp = round(temp, 1) logger.log("Teperature C",temp) humidity = sense.get_humidity() humidity = round(humidity, 1) logger.log("Humidity :",humidity) pressure = sense.get_pressure() pressure = round(pressure, 1) logger.log("Pressure:",pressure) var = var -1 time.sleep(30) if var == 0: sys.exit()
Replace the text “ENTER YOUR KEY” with your Access Key you wrote down from www.initialstate.com
pi_weather.pyto a USB drive
To run the weather station, type in the following into your terminal window:
sudo python pi_weather.py
To monitor your weather data on your web browser, log in to your Initial State account and start monitoring the data.