Adafruit Trinket M0
CircuitPython or Arduino IDE on this tiny little microcontroller board
- Overview
- Guided Tour
- Pinouts
- Windows Driver Installation
- What is CircuitPython?
- CircuitPython
- CircuitPython Essentials
- CircuitPython Pins and Modules
- CircuitPython Built-Ins
- CircuitPython Digital In & Out
- CircuitPython Analog In
- CircuitPython Analog Out
- CircuitPython PWM
- CircuitPython Servo
- CircuitPython Cap Touch
- CircuitPython Internal RGB LED
- CircuitPython NeoPixel
- CircuitPython DotStar
- CircuitPython UART Serial
- CircuitPython I2C
- CircuitPython HID Keyboard and Mouse
- CircuitPython CPU Temp
- CircuitPython Storage
- CircuitPython Expectations
- MakeCode
- Arduino IDE Setup
- UF2 Bootloader Details
- Downloads
CircuitPython CPU Temp
There is a CPU temperature sensor built into every ATSAMD21, ATSAMD51 and nRF52840 chips. CircuitPython makes it really simple to read the data from this sensor. This works on the Adafruit CircuitPython boards it's built into the microcontroller used for these boards.
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, andenter the REPL. Then, enter the following commands into the REPL:
import microcontrollermicrocontroller.cpu.temperature
import microcontrollermicrocontroller.cpu.temperature
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!
Page last edited March 08, 2024
Text editor powered bytinymce.

















