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.
The temperature sensor measures the temperature in Celsius.
while loop, create a variable called
temp_c and store the value of
temp_c = cpx.temperature
We also want to have the temperature in Fahrenheit.
The formula is the following:
Create a variable named
temp_f and store the value inside.
temp_c and the
Click the Download button to download the code.py file.
Drag and drop the downloaded file into the CIRCUITPY volume on your computer.
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.)