Learn
Circuit Playground: Part 2
Temperature Sensor

But wait! There’s more — the Circuit Playground Express can also tell the temperature!

How, you ask? With a built-in thermistor. This little sensor is a thermally sensitive resistor, meaning its resistance changes based on temperature.

We can access its readings in CircuitPython by using cpx.temperature and also using the Mu Editor.

### Instructions

1.

The temperature sensor measures the temperature in Celsius.

Inside the while loop, create a variable called temp_c and store the value of cpx.temperature inside.

temp_c = cpx.temperature
2.

We also want to have the temperature in Fahrenheit.

The formula is the following:

$F = C * 1.8 + 32$

Create a variable named temp_f and store the value inside.

3.

Print the temp_c and the temp_f.

4.

5.

Open the Mu Editor on your computer.

And load the code from CIRCUITPY. Click the Serial button.

What is the current temperature in the room?

Put your finger over the sensor to watch it rise.

(Or put the Circuit Playground Express in the freezer for a minute and then plug it back in to see the difference.)