Skip to content

CPU Temperature

The CPU Temperature sample demonstrates how to use the on-chip Temperature sensor to measure the internal die temperature.

Requirements

Before you start, check that you have the required hardware and software:

Running the code

To run the code, complete the following steps:

  1. Connect iMX RT1011 Nano Kit to your computer using the USB-C Cable.
  2. Start Mu Editor, click Load to open code.py in the CIRCUITPY drive.
  3. Copy and paste the following code into code.py and click Save:

    CIRCUITPY/code.py
    1
    2
    3
    4
    5
    6
    import time
    import microcontroller
    
    while True:
        print((microcontroller.cpu.temperature,))
        time.sleep(0.1)
    
  4. Your code will run as soon as the file is done saving. Click Serial on Mu Editor's Top Menu to open a serial console. You should see the console output, similar to what is shown in the following:

    Code stopped by auto-reload. Reloading soon.
    
    Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
    code.py output:
    (38.5484,)
    (38.5484,)
    (38.5484,)
    (39.1129,)
    (38.5484,)
    (38.5484,)
    (39.1129,)
    (39.1129,)
    (38.5484,)
    (39.1129,)
    ...
    
  5. You can also use the plotter for data inspection. Click Plotter on Mu Editor's Top Menu to open up a plotter pane: