15. IoT Case 06: Weather Station¶
Make a weather station which gets the values from the raindrop sensor, temperature and humidity sensor. The data will be sent to IoT platform - ThingSpeak.
What is Thingspeak?
ThingSpeak is an IoT analytics platform service which provides instant visualizations of data posted by your devices to ThingSpeak. In this case, we will use this platform to update our data to plot instant graphs.
Weather station operation
Collecting temperature, humidity and raindrop consistently and uploading the data by using Thingspeak. This can help us to do analytical work more conveniently as we can refer to the automatically plotted graphs.
15.3. Part List¶
15.4. Assembly step¶
Attach the raindrop sensor to F2 model.
Attach the temperature and humidity sensor to F2 model.
Put together all the cardboard parts (F1-F2).
15.5. Hardware connect¶
Connect the Raindrop Sensor to P0 port of IoT:bit
Connect the Temperature and humidity Sensor to P2 port of IoT:bit
Pull the buzzer switch ‘up’ to disconnect the buzzer in this execrise
15.6. IoT (ThingSpeak)¶
* For more details, please refer to Chapter 1: Upload Data to ThingSpeak
Go to https://thingspeak.com, Choose Channels -> My Channels -> New Channel
Input Channel name, Field1 and Field2 , then click “Save Channel”
Channel name: Smart Weather Station
Field 1: temperature
Field 2: humidity
Freld 3: raindrop
Select your channel > “API Keys” ，copy the API key as follows:
15.7. Programming (MakeCode)¶
Step 1. Initialize OLED, IoT:bit and connect to WiFi
Initialize OLED with width:128, height: 64to
Initialize IoT:bit TX P16 RX P8from
Set Wi-Fi to ssid pwdfrom
Enter your Wi-Fi name and password. Here we set
temperatureto 0 from
Step 2. Show icon “tick” after WiFi connection
On WiFi connectedand select icon
Step 3. Get temperature, humidity and raindrop values
if statementto block
WiFi is connected
read humidity from DHT11 at Pin P2
read temperature from DHT11
get raindrop value (percentage) at Pin P0
Step 4. Show values on OLED
clear OLED displayfrom
OLEDto avoid overlap
show stringand show value of variables
Step 5. Upload data to ThingSpeak
Send Thingspeak key...inside the
Fill in the
api keyfrom Thingspeak with temperature, humidity and raindrop value
pauseto the loop to wait 15 second
Step 6. Show ThingSpeak upload status
On Thingspeak Uploaded
Draw the variable
When micro:bit is connected to WiFi, it will check weather information (temperature, humidity from Temperature and humidity Sensor and raindrop value from raindrop sensor). Then, those data will be sent to ThingSpeak and pause for 15 seconds for another update.
We can find three graphs on Thingspeak including temperature, humidity and raindrop (field1, field2, field3) respectively by collecting data using different sensors.
Q1. How can we upload other module values (e.g. noise) to ThingSpeak?