This lesson is a treasure hunt game. Students program sensors and send sensor data to an online dashboard that displays the data in real time. Half of them will then try to hide their sensors somewhere within the range of internet connection in the school, and the other half will use the information from the live dashboard to locate the sensors that their classmates hid.
WioLink board, router that’s already connected to the Internet, temperature sensor, light sensor, live dashboard (link), rechargeable batteries, Reading Material
In this lesson the students will mainly be playing a treasure hunt game. They will program their WioLink boards to send data to a live dashboard (found here). Using the information from the dashboard, they will try to find the boards hidden by other students.
In your composition notebook, quickly write code that displays information from a temperature sensor onto an OLED screen with os.show_sensor_data()
.
Before the students start coding, they need to use the “File Manager” button to view the files on the board. Make sure that they delete the “main.py” file written by other students before they start coding.
The students connect their boards to the Internet and send data from their temperature sensor with the following code:
from iot import WiFi, BcServer
wifi = WiFi("GrowThings", "Grow2018")
wifi.connect()
from sensors import TemperatureSensorPro
import time
tsp = TemperatureSensorPro()
server = BcServer(team = "wa1") #use your own team name, lower case
while True:
server.send_sensor_data(tsp)
time.sleep(20)
The students can feel free to use a light sensor too. Apart from importing the LightSensor name, they also need to use the code as follows:
from iot import WiFi, BcServer
wifi = WiFi("GrowThings", "Grow2018")
wifi.connect()
from sensors import TemperatureSensorPro
import time
tsp = TemperatureSensorPro(port=3)
ls = LightSensor(port=6)
server = BcServer(team = "wa1") #use your own team name, lower case
while True:
server.send_sensor_data([tsp, ls])
time.sleep(20)
The teacher needs to go to the live dashboard and use the correct tab for his/her class (there is one dashboard for each block).
If everything works correctly, the students will receive a “data sent” message every 20 seconds (we recommend that the sample rate is at least 20 seconds so as not to overwhelm the server). Their team name will show up on the live dashboard.
Make sure that each board has a rechargeable battery attached to the battery port. After the students have programed their board, they can rename their board to main.py
and upload the code to the board using the “upload” button. Now the students will have their code working on their board without having to be connected to a computer.
Now, half of the students are going to hide their boards (the other half need to turn off their boards). Before they do so, they need to write on a cue card where they are going to hide their boards so their classmates can easily locate them and why they made these decisions. The teacher can reset the dashboard before they start.
Switch the groups after 15 minutes.
Give some time for the students to reflect on their experience. Ask students why they chose to hide their boards the way they did, and did the data support their scientific hypothesis? Do they think this process is scientific inquiry? Why or why not? They can also write their answers on their composition notebook too.
Please upload your final code to Google Classroom. Save your file in the format of wa1-0529.py
.
The students can write their reflection as exit slip.