Very odd. While I have also observed that the calculated temperature doesn't match the actual ambient, is quite a lot lower, I don't have any test equipment to check things out fully, determine where the issue may be.
If one works through it for 48C ...
Temperature sensor voltage as stated in RP2020 documentation -
- voltage = ( ( T - 27 ) * -0.001721 ) + 0.706
- voltage = ( ( 48 - 27 ) * -0.001721 ) + 0.706
- voltage = 0.669859
Temperature sensor ADC reading with 3V3 Vref-
- adc = voltage * 65535 / Vref
- adc = 0.669859 * 65535 / 3.3
- adc = 13303
Determining temperature from ADC reading -
- T = 27 - ( ( machine.ADC(4).read_u16() * 3.3 / 65535 ) - 0.706) / 0.001721
- T = 27 - ( ( 13303 * 3.3 / 65535 ) - 0.706) / 0.001721
- T = 48
Of course this all depends on the very first equation being an accurate representation of the hardware. If that's not right then the reversing equation won't be right either.
What we really need is someone with test equipment to produce graphs of ADC readings against various calibrated temperatures so we can compare those to the stated straight-line function. And ideally over a range of RP2040 devices so we can determine what the variance is.
One thing which can affect readings is the Vref used. If Vref isn't exactly 3V3 then the reversing equation which assumes it is will show significant errors -
Code: Select all
3.20V Vref : 48C calculated to be 35.9C
3.25V Vref : 48C calculated to be 42.0C
3.30V Vref : 48C calculated to be 48.0C
3.35V Vref : 48C calculated to be 53.8C
3.40V Vref : 48C calculated to be 59.5C
In most cases a Vref which isn't an exact 3V3 won't have much of an impact on analogue inputs using equations which assume Vref is 3V3. It is only because the temperature sensor voltage is so low and changes so little over its range that discrepancies are magnified far greater than they normally would be.