# \[Solved\] How to read internal temperature sensor of RP2040 in circuitpython

**URL:** <https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318>\
**Category:** Nano RP2040 Connect\
**Created:** [August 13, 2021, 12:56pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318 "2021-08-13T12:56:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ck3951](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@ck3951](https://forum.arduino.cc/u/ck3951)\
**Post date:** [August 13, 2021, 12:56pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/1 "2021-08-13T12:56:19Z")

</div>

According to the datasheet, an RP2040 has an internal temperature sensor, measuring the temperature of the chip. How can one read this sensor of the Nano RP2040 using circuitpython?

---

<div class="post-metadata">

**Author:** ![galloups](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@galloups](https://forum.arduino.cc/u/galloups)\
**Post date:** [August 14, 2021, 8:52am UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/2 "2021-08-14T08:52:38Z")

</div>

Hello ck3951. I also wanted to know about this for quite some time. It seems Arduino Nano RP2040 Connect has **2** onboard temperature sensors, one from RP2040 that you described, and one other from its ST LSM6DSOXTR 6-axis IMU.

I did not find a way to access those yet ☹

---

<div class="post-metadata">

**Author:** ![ck3951](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@ck3951](https://forum.arduino.cc/u/ck3951)\
**Post date:** [August 14, 2021, 5:51pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/4 "2021-08-14T17:51:07Z")

</div>

The following script shows how to read the temperature of the IMU (as well):

```cpp
import time
import board
from adafruit_lsm6ds.lsm6dsox import LSM6DSOX

i2c= board.I2C()
sensor= LSM6DSOX( i2c )

for i in range(10):
  print( 'Acceleration: X:{:6.3f}, Y:{:6.3f}, Z:{:6.3f} [m/s^2]'.format(*sensor.acceleration) )
  print( 'Gyro : X:{:6.3f}, Y:{:6.3f}, Z:{:6.3f} [radian/s]'.format(*sensor.gyro) )
  print( 'Temperature : {:6.3f} [C]'.format(sensor.temperature) )
  print()
  time.sleep( 1 )

```

---

<div class="post-metadata">

**Author:** ![galloups](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@galloups](https://forum.arduino.cc/u/galloups)\
**Post date:** [August 15, 2021, 6:02pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/5 "2021-08-15T18:02:01Z")

</div>

Thank you ck3951! This looks good for circuit python.  
For Arduino language, which i prefer to use, It seems that we still can't do it using the official [Arduino library](https://www.arduino.cc/en/Reference/Arduino_LSM6DSOX) sadly ☹

Does anybody know if we can suggest change to the Arduino Team and if yes, how? I find the [github repository](https://github.com/arduino-libraries/Arduino_LSM6DSOX) for this library, and would like to suggest this new functionality in order to be able to get temperature from the onboard LSM6DSOX of the Nano Connect. I don't think i can ask for this in the issue category.

It might be possible to use Adafruit **LSM6DS** library, but i would prefer to use an Arduino one 😄

To go back to your initial request, i also would like to know if there is a way of getting temperature directly from RP2040, on the Pico we can get it from the **internal RP2040 A4** , but looking at Nano Connect schematics it seems we can't access this pin

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [August 15, 2021, 10:35pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/6 "2021-08-15T22:35:42Z")

</div>

> [@galloups](#):
>
> I don't think i can ask for this in the issue category.

It's true that there are specific appropriate uses of the issue trackers in Arduino's GitHub repositories. However, those appropriate uses are both bug reports and feature requests. So you are welcome to submit a feature request for this. Just make sure to do a search of the issue tracker for existing requests for the same feature so you don't submit a duplicate. Check both the open and closed issues.

You can see a similar request for the Arduino\_LSM6DS3 library here:

> <https://github.com/arduino-libraries/Arduino_LSM6DS3/issues/9>
>
> Requesting an enhancement to include access to the on-chip temperature sensor av…ailable on the LSM6DS3 device which can be accessed from the OUT\_TEMP\_L (0x20) and OUT\_TEMP\_H (0x21) registers.

That's a different library, so the same request for the Arduino\_LSM6DSOX would not be considered a duplicate, but I mention the Arduino\_LSM6DS3 request because it is somewhat related to this subject and so might be interesting to you.

---

<div class="post-metadata">

**Author:** ![ck3951](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@ck3951](https://forum.arduino.cc/u/ck3951)\
**Post date:** [August 17, 2021, 7:34am UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/7 "2021-08-17T07:34:12Z")

</div>

Page 137 in PDF document entitled 'CircuitPython Documentation Release 7.0.0-alpha.6' contains the answer to my question. It is demonstrated in the script below:

```cpp
import microcontroller

for attr in dir(microcontroller.cpu):
    if attr.startswith('_'): continue
    print( '{:12s} : {}'.format(attr,getattr(microcontroller.cpu,attr)) )

```

The output of this script is:

```cpp
frequency : 125000000
reset_reason : microcontroller.ResetReason.UNKNOWN
temperature : 24.7977
uid : bytearray(b'P1P376\x00\x01')
voltage : 3.3

```

Thus the temperature can be retrieved in circuitpython using property microcontroller.cpu.temperature.

---

<div class="post-metadata">

**Author:** ![galloups](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@galloups](https://forum.arduino.cc/u/galloups)\
**Post date:** [August 21, 2021, 10:47am UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/8 "2021-08-21T10:47:38Z")

</div>

Congrats **ck3951** , looks like you have everything now!  
I don't want to use CircuitPython, so i will have to wait for an Arduino library update.

Thank you **pert** for the information, i created an enhancement query [here](https://github.com/arduino-libraries/Arduino_LSM6DSOX/issues/7)  
If this end up being done, we will be able to access the embedded temperature sensor of the ST LSM6DSOXTR, which will add yet another feature to this board!

I wonder if there is a way to also access the internal cpu temperature sensor with an Arduino library 🤔

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [August 21, 2021, 11:37am UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/9 "2021-08-21T11:37:25Z")

</div>

> [@galloups](#):
>
> i created an enhancement query [here](https://github.com/arduino-libraries/Arduino_LSM6DSOX/issues/7)

Thanks! Thanks also for taking the time to link to it from the discussion here. I think that can be very helpful for the people who are interested in this subject by allowing them to easily access any valuable information that might evolve from the GitHub issue, which is not an uncommon occurrence.

---

<div class="post-metadata">

**Author:** ![galloups](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@galloups](https://forum.arduino.cc/u/galloups)\
**Post date:** [September 11, 2021, 3:42pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/10 "2021-09-11T15:42:51Z")

</div>

@pert : the library sources has been updated soon after my query and it is now possible to retrieve the temperature, which is amazing! But there have been no new release of the library. So unless you manually retrieve the sources, and only use the Arduino IDE manager to get it, you won't have the last modification that includes the temperature, and still use release v1.0.0 🤔

The [reference page](https://www.arduino.cc/reference/en/libraries/arduino_lsm6dsox/) is also not updated

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 9, 2022, 3:43pm UTC](https://forum.arduino.cc/t/solved-how-to-read-internal-temperature-sensor-of-rp2040-in-circuitpython/895318/11 "2022-01-09T15:43:41Z")

</div>

Closed on January 9, 2022, 3:43pm UTC

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
