I'm using an inbuilt temperature sensor in my NUC220VE3AN(Cortex M0). It is read through an Analog channel and shows 840 as reading at 24 degree Celsius. The ADC is 12 bit with value between 0 to 4095 and the temperature sensor has rating, -40℃ ~ +125℃ as per datasheet. How can I map the ADC value to get negative a temperature reading?

  • \$\begingroup\$ Nitpick: 12 bits does not give you 0-4096. It gives you 4096 possible values, 0-4095. It's such a small difference that given the other errors involved it's completely irrelevant to the question at hand (in fact I think I made the exact same error in the equations in my answer). But in some situations this sort of thing can cause problems so keep an eye out for it. \$\endgroup\$ – Andrew Jan 11 '17 at 15:59

The temperature sensor readings are given in section 6.4.2 of the datasheet (in the future please give links to manufacturers pages or datasheets rather than just a part number).

The datasheet indicates that:
Vtemp = 720 - 1.76*C
where C is the temperature in Celsius and Vtemp is the output of the temperature sensor in mV.

That voltage is then passed to the ADC which will output 0 for 0 V and 4095 for VDDA

So assuming VDDA = 3.3V and the ADC output is 840:
3.3*840/4096 = 677mV
C = (677-720)/-1.76 = 24.5

Keep in mind that the sensor has an accuracy of 1C so a slight error on VDDA isn't going to have much impact on your overall accuracy.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.