Mini Weather Station (II)

Create a mini weather station that measures the
ambient environment. we will be using:

(1) the in-built temperature sensor to detect the current temperature in degrees Celsius and
(2) the in-built light sensor to measure the amount of light around the micro:bit


You'll need

  • 1 x micro:bit
  • 1 x USB cable

Step 1

Instructions

Drag in an on Button A pressed block from input drawer into the code area.

Then, from the Led category, drag a plot bar graph of _ to _ block and place it inside the on button A pressed event. The first parameter is the value of what you are measuring or trying to show. In this case, we are trying to show the light level, so from the Input drawer, drag a light level block into the first parameter text box.

The second parameter holds the maximum number that the first parameter can be. According to MakeCode’s documentation, the maximum reading of the in-built light sensor is 255, so type 255 into the second text box.


Step 2

Instructions

Next, we will use on Button B pressed to show the current’s temperature reading. Drag in an on Button B pressed event and insert a show number block in it. Complete the show number block by placing a temperature block in the empty space.

That’s it! Download to your micro:bit and use the project as your mini weather station at home!


Code and References

Completed this tutorial?

Spread the word! Let's get this trending on social media with #letsgethacking #MiniWeatherStation(II)