Direct sunlight and shade experiment
Watch this video about an experiment using the temperature sensor to see what effect a sun shade has on keeping your car cooler.
What environment will the data be collected in? Does the micro:bit need to be protected in a ziplock bag? What is the purpose of the experiment?
Program the micro:bits. Experiment with different data collection scenarios.
This project will start with one micro:bit and program it to use the micro:bit’s temperature sensor to collect and display the current temperature in Celsius on the micro:bit’s LED display. The data collected can be recorded manually on a paper with a pencil.
||basic:on start||
event will display the title and purpose of the micro:bit in all caps, "TEMPERATURE"
. The text is put in the ||basic:show string||
block (the title is put in the ||basic:on start||
event so when the micro:bit is started up it will show what it is programmed to do. It is done in all CAPS because it is easier to read as it is displayed in the LED display).basic.showString("TEMPERATURE COLLECTION")
In the ||basic:forever||
event temperature data can be continually collected from the micro:bit’s temperature sensor. The data can be sent to the display on the LEDs using a ||basic:show number||
block from the ||basic:Basic||
toolbox.
basic.forever(() => {
basic.showNumber(input.temperature())
});
As data is displayed it can then be recorded on paper for further analysis.
Data can also be displayed graphically using the ||led:plot bar graph of||
block from the ||led:LED||
toolbox.
basic.forever(() => {
led.plotBarGraph(
input.temperature(), 0
)
});
Variation: Instead of using a ||basic:forever||
loop, the A and B buttons could be programmed to display the temperature in either Celsius or Fahrenheit.
MakeCode allows data to directly read serial data from your micro:bit for data logging and other fun experiments. This allow the collection of data in real time which can be downloaded in a CSV file for additional analysis in a spreadsheet.
With the program downloaded from MakeCode to the micro:bit and the USB cable left connected and using the ||serial:serial write value||
block from the |serial:Serial||
toolbox in the Advanced tool section.
basic.forever(() => {
serial.writeValue("Celsius", input.temperature())
});
When the program is running, a purple Show data Device button shows up under the Simulator. By clicking on the button the data being observed can monitored and graphed in the Show data Device window.
The graph is highlighted with the blue box. The Download button in the red highlighted box allows the downloading of the recorded data as a CSV file which can be opened in a spreadsheet and analyzed.
Two micro:bits can be used to collect and record data using the radio commands. One micro:bit can be setup remotely and the other micro:bit can be used to observe the data. The first micro:bit can send the data it observes to the second micro:bit for the observer to record. To set up two micro:bits so they can communicate over the radio they need to be on the same radio group.
In the starting of the code the title is displayed, radio group 99
is setup, and the initial temperature
variable is set to 0
.
In the ||basic:forever||
loop the temperature is collected from the micro:bit sensor and stored in the temperature
variable. The temperature is displayed on the LED display. A radio signal is sent to all micro:bit radios in group 99. The program pauses for 1000
milliseconds and then loops again.
let temperature = 0
basic.showString("TEMPERATURE RADIO REMOTE")
radio.setGroup(99)
basic.forever(() => {
temperature = input.temperature()
basic.showNumber(temperature)
radio.sendNumber(temperature)
basic.pause(1000)
})
In the starting of the code the title is displayed, radio group 99
is setup, and the initial temperature
variable is set to 0
.
In the ||radio:on received number||
event, the temperature is received from sending the micro:bit radio. The received temperature is then displayed on the LED display. This is repeated whenever a radio signal is received.
let temperature = 0
basic.showString("TEMPERATURE RADIO RECEIVER")
radio.setGroup(99)
radio.onReceivedNumber( function(receivedNumber) {
basic.showNumber(receivedNumber)
})
This code is the same as above but one additional line of code is added to write to the word “Celisus” and the temperature to the MakeCode app to the USB serial connection. This is the same as described in the Project 2 section above.
let temperature = 0
basic.showString("TEMPERATURE RADIO RECEIVER SERIAL")
radio.setGroup(99)
radio.onReceivedNumber( function(receivedNumber) {
basic.showNumber(receivedNumber)
serial.writeValue("Celisus", receivedNumber)
})
Modify the code so it returns temperature values in Fahrenheit. Formula: C = (F - 32) / (9/5)
.
Use a radio connection to collect and record the outside temperature.
Use a radio connection to collect and record the outside temperature. It could be set up so it only detects and reports the temperature every minute or a few times an hour. It could be setup to sound an alarm (play a musical sound) if the temperature were to rise above a certain level.
Several students could use micorbits to observe the temperature at different elevations where the live at set times to see if there are patterns in temperatures at different elevations or regions.
Adapted from “Temperature Data“ by C Lyman |
radio