Skip main navigation

£199.99 £139.99 for one year of Unlimited learning. Offer ends on 28 February 2023 at 23:59 (UTC). T&Cs apply

Find out more

Challenge 2: Collect and display sensor data

Challenge 2: Collect and display sensor data
In our first challenge, the fruit piano, we were taking information from the physical world, a human touch, putting it into the Microbit, and then pulling it out straight away back into the physical world as sound. In this experiment, this new challenge, we’re going to be using a temperature sensor in the Microbit. So there’s going to be no human interaction this time. It’s going to sense the temperature of the room and then output that on the Microbit screen. We shouldn’t need to change the data, but as you’ll see, there are times when it is needed. Here’s our temperature experiment. So here’s the Microbit. When we first start it up, it should show us the temperature. So we have 31 degrees.
Now, this is very interesting. This is the UK. It is July, but I really don’t think it is 31 degrees in this room. I’ve also coded it to appear when I press A. So I’m going to give the Microbit a bit of second to settle down, maybe cool down a bit. I’m going to press A and see what we get– 31 degrees, OK. Let’s have a look at that. So I’ve got this temperature sensor thermometer. And it’s going to show me the temperature of the room, which is 21. That seems more likely than 31. Let’s check again– 30. OK, it is going down. Let’s leave that for 20 minutes and come back and see what happens.
After some time, I’ve left the Microbit to rest. And we’ll see when we press A, it’s still going quite high– 27 degrees. It just doesn’t feel like 27 degrees in this room. And this temperature sensor thermometer kind of confirms that.
That’s the time, 1:35. And it’s 22 degrees, which seems much more likely. So it seems like the Microbit is running hot. So what we’ll do is we will change that. We will allow that in the code. So we’re fixing– the reason the Microbit is running hot is because it’s an electronic device. It has electricity running through it, so it is running. If you hold it in your hand, you’ll notice that it is a warm device, so it’s naturally a thermometer. Because the thermometer is on the device and not a separate one, it’s going to run a bit hot. So that’s just a hardware problem.
But we can fix that with code because we have a reliable temperature sensor telling us the proper temperature. So they’re about five degrees out, so we’re going to fix that problem in code.
This article is from the free online

Build a Physical Computing Prototype

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education