CircuitPython CPU Temp
There is a CPU temperature sensor built into every ATSAMD21 chip. CircuitPython makes it really simple to read the
data from this sensor. This works on the M0, M0 Express and Circuit Playground Express boards, because it's built into
the microcontroller used for these boards. It does not work on the ESP8266 as this uses a different chip.
The data is read using two simple commands. We're going to enter them in the REPL. Plug in your board,
connect to
the serial console
(https://adafru.it/Bec)
, and
enter the REPL
(https://adafru.it/Awz)
. Then, enter the following commands
into the REPL:
That's it! You've printed the temperature in Celsius to the REPL. Note that it's not exactly the ambient temperature and
it's not super precise. But it's close!
If you'd like to print it out in Fahrenheit, use this simple formula: Celsius * (9/5) + 32. It's super easy to do math using
CircuitPython. Check it out!
import microcontroller
microcontroller.cpu.temperature
© Adafruit Industries
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
Page 170 of 183