Using the Sensors

The SenseHat is loaded with a bunch of sensors that can detect all sorts of things, including temperature, pressure, humidity, acceleration and magnetic fields. In this project, we’re going to use the temperature and humidity sensors to determine fire risk.

First, we’ll assign the temperature and humidity measured by the SenseHat to variables so that we can use them later.

We should check to make sure that we’re getting the right values.
Let’s print out the values for temperature and humidity.

Run your program.
A console should appear at the bottom right of your window that will output the results of the program.The first number is the temperature and the second is the humidity.

Change the temperature and humidity sliders.

Run your program again. You should get the new reading.

It’s a bit of a pain to have to run the program every time we want to get a new reading. Let’s put it in a loop to constantly get new readings instead.

Note: the lines that are being looped through (lines 8-10) have been shifted forward by two spaces. This is called indenting and it tells python that these lines belong inside the loop. You can indent these lines by highlighting them all (lines 8-10) and pressing the Tab key.