## internal temperature offset on 3rd party boards?

jbeale
Posts: 3855
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

### internal temperature offset on 3rd party boards?

I'm using the code below to read out the internal temperature:

Code: Select all

``````sensor_temp = machine.ADC(4)       # Pico internal temperature sensor
conversion_factor = 3.3 / (65535)  # ADC scaling
degC = 27 - (reading - 0.706)/0.001721  # RP2040 internal temp``````
With an ambient temperature of 23.6 C, I find that two different Raspberry Pi Pico boards read 24.3 and 22.4 C.
I just got two Adafruit Feather RP2040 boards, and using this same code at the same ambient temperature, they read 34.5 and 32.7 C.

I know Raspberry Pi has no control over 3rd party boards, but I had the impression the temperature sensor was internal to the RP2040 chip.
It doesn't seem just chance that the different boards would be so far apart, when each pair of boards of the same type is that close.
Maybe the Adafruit layout is not connecting the chip's bottom thermal pad to a ground plane (?)

cleverca22
Posts: 3518
Joined: Sat Aug 18, 2012 2:33 pm

### Re: internal temperature offset on 3rd party boards?

the 3.3 figure in your formula may need correcting
use a volt meter to measure the actual 3.3v rail, and enter the correct voltage

on my pico, it was 3.27v

hippy
Posts: 9666
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

### Re: internal temperature offset on 3rd party boards?

I too would guess that presuming Vref to be 3V3 is the main issue. The temperature sensor output is quite low voltage and only changes slightly per whole degree C so small discrepancies in the conversion equation can cause quite significant divergence in reported values against actual.

The Adafruit Feather RP2040 circuit diagram is here -

As can be observed; it connects leg 43, ADC_IOVDD / ADC_AVDD, direct to 3V3, where the Pico connects it via a 200R + 1R to 3V3. This means the Arduino Feather RP2040 should have a slightly higher Vref than the Pico.

But that would mean the Adafruit Feather RP2040 should be reporting its internal temperature more accurately than the Pico with 3V3 Vref presumed. So perhaps there is something else going on. I have always found on-chip temperature sensors more trouble than they are worth.

It can be beneficial to convert the fudged 16-bit ADC reading back to its native 12-bit so that fudging is taken out of play -

Code: Select all

``````VREF = 3.3

voltage = adc12 * VREF / 4095
degreeC = 27 - (voltage - 0.706) / 0.001721
return degreeC
``````

jbeale
Posts: 3855
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

### Re: internal temperature offset on 3rd party boards?

Your points are well taken, and I found there is some variation between each of the boards. However, the pattern of variation does not exactly match the pattern of the temperature differences I found. For example, the voltage rail on Pico #1 and Feather #1 are closer together than the two Pico boards, yet the reported temperatures are not. I used the same meter for each measurement, and it reports consistent values on re-tests.

Pi Pico #1: V = 3.294
Pi Pico #2: V = 3.259
Feather #1: V = 3.297
Feather #2: V = 3.300

To make it more clear, here is code (running on a Pico, in this case) to use both the max and min measured Vref number (2.249 and 3.300) to see how much that affects reported temperature:

Code: Select all

``````sensor_temp = machine.ADC(4)       # Pico internal temperature sensor

f1 = 3.300 / (65535)  # ADC scaling assuming 3.300 V
f2 = 3.259 / (65535)  # ADC scaling assuming 3.259 V

degC1 = 27 - ((raw*f1) - 0.706)/0.001721  # RP2040 internal temp
degC2 = 27 - ((raw*f2) - 0.706)/0.001721  # RP2040 internal temp

print("Temp: %5.3f %5.3f" % (degC1,degC2))``````
Result: Temp: 20.959 26.130
So worst-case error among my four boards should be 5.17 C, based only on the variation in Vref, and yet I observe twice that.
Last edited by jbeale on Sun Apr 18, 2021 4:39 pm, edited 1 time in total.

davidcoton
Posts: 6109
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

### Re: internal temperature offset on 3rd party boards?

hippy wrote:
Sun Apr 18, 2021 1:42 pm
So perhaps there is something else going on.
I'm not sure that there needs to be. At least one of the original RPT board readings is almost certainly "wrong", how can the chip temp be below ambient? Does it help to measure and correct the Vref on the RPT board -- does that bring it closer in line with Adafruit?

If there is another factor, it might be how each board is engineered to dissipate heat. We know RPT have some experience of using what's on the board to keep it cool, though this will be less significant on a Pico.
Location: 345th cell on the right of the 210th row of L2 cache

jbeale
Posts: 3855
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

### Re: internal temperature offset on 3rd party boards?

Certainly there is an expected error tolerance, and the various Vref values are a significant contribution, accounting for a total difference of 5 degrees C among my specific four boards, as I found in my previous note. However I observed 12 degrees C variation among those 4 boards, and with each board from the same mfr (RPi Pico vs Adafruit Feather) reporting a temperature closer to its sibling, even though the measured Vref values were not. That suggests to me something aligned with the design and manufacturing of the boards is actually the dominant factor.

Another possibility is the calibration factor of the Vbe junction voltage (?) used as the temperature sensor, maybe there is per-lot process variation and the different mfrs. used parts from different lots. Still, a delta of 12 C seems pretty big for that kind of variation.

I wasn't able to tell much with my "FLIR 1" mini thermal-IR camera. There's a parallax offset between its low-res thermal, and visible image when you have it close to small objects. Waving around to try to measure where the top of the RP2040 chip is-- maybe-- suggests there's only about 1 deg. C difference between the two boards, at least on top of the chip package, with both running the same uPython code.

(The USB connectors look hot, but smooth metal surfaces are mostly reflectors, showing what is in front of them, in this case my hand.)
thermal image of Pico & Feather
flir_20210418T110655.jpg (142.95 KiB) Viewed 356 times
Pico & Feather
Pico-Feather_20210418.jpg (106.46 KiB) Viewed 347 times

fdufnews
Posts: 321
Joined: Fri Oct 07, 2011 5:37 pm

### Re: internal temperature offset on 3rd party boards?

As said in the datasheet, the result is not guaranteed.
As the Vbe and the Vbe slope can vary over the temperature range, and from device to device, some user calibration may be required if accurate measurements are required.
I have not find, in the datasheet, any tolerance on the value of Vbe @ambiant.

jbeale
Posts: 3855
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

### Re: internal temperature offset on 3rd party boards?

fdufnews wrote:
Sun Apr 18, 2021 7:43 pm
As said in the datasheet, the result is not guaranteed.
That is true, but I am confident there are some bounds on the performance of working parts, though the datasheet may not specify exactly what that is.
I'm just presenting what observations I have, from my limited dataset.

hippy
Posts: 9666
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

### Re: internal temperature offset on 3rd party boards?

If we assume a perfect world, one thing were reporting 22.4C with 3V3 Vref and another thing were reporting 34.5C with the same 3V3 Vref - which are the extremes of the readings being seen, we can determine what the sensor voltage must have been for both -

34.5 C = 714 mV
22.4 C = 693 mV

An 11 mV A 21 mV change produces around an 11 C change.

With the nominal sensor voltage of 706 mV at 27 C, that 11 mV 21 mV would represent about 1.6%, +/-0.8% 3%, +/-1.5%

I don't know what manufacturing tolerance should be expected from a silicon etched diode but that sort of discrepancy fits with my experience of on-chip temperature sensors.
Last edited by hippy on Tue Apr 20, 2021 2:45 pm, edited 2 times in total.

jbeale
Posts: 3855
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

### Re: internal temperature offset on 3rd party boards?

Thanks for making that point; indeed, the actual voltage difference seems less noteworthy than the calculated temperature difference. So perhaps it is just random chance, given I only measured 4 boards.

It also reminds me of another thing: the Pico brings out 8 separate ground pins to the board edges (9 if you count the debug pins). The Feather board presents only one ground pin, in addition to its onboard connectors. Unavoidably there will be differences in trace routing on the two boards, which may well affect what the chip sees as (Vref-Ground) vs what I see on the board pins, at the 11 mV level.

FWIW the Feather uses a USB3 connector, and its shell is not grounded (maybe that's the standard USB3 thing, I don't know). The two plated-through mounting holes to either side of the USB connector are not grounded either.

hippy
Posts: 9666
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

### Re: internal temperature offset on 3rd party boards?

Not sure how I calculated 714 - 693 as being 11. Have updated the post.