I’m having an issue with calculating a correct temperature for a reading from ADC_INTERNAL_TEMP on a Redboard Artemis. Example4_analogRead shows the same issue (as it should - that’s where I grabbed the code from!). I found one other thread on the board that discusses an issue with analogReads involving ADC_INTERNAL_TEMP, but it looks like the OP there got his issue fixed by updating to board library version 1.0.30 (viewtopic.php?f=169&t=52451&p=213396&hi … MP#p213396).
I’m using 1.0.30, and still having this issue - and honestly, I can’t see how the OP on the other thread wasn’t also having this issue with Example4, even after the board update. Here’s what I’m seeing:
Example4 returns a line like this:
A3: 16383 VCC/3: 9140 VCC: 3.35V internalTemp: 443.43 vss: 0
The chip is obviously not 443.43 degrees C, or my desk would be on fire! LOL. I added some code to try to ascertain how the math is getting to that point, so I have it print out internalTempVoltage (raw read off the ADC), and then I save aside internalTemp after the raw read is converted to voltage, but before converting voltage to degrees C. I get the following (note, for the same data line I posted above):
Internal temp voltage: 8248 internal temp voltage: 1.69
If the right conversion truly is 3.8mV per degree, something is really, really off in this value. It’s 72 degrees F in my office right now, which is 22.2C. That should be 84mV, not a value 20 times larger (give or take).
Reading the other thread, the OP there reported seeing values of 514 when reading with 10-bit resolution - if his calculations were based on using the 14-bit resolution, that’d yield 81 degrees F, but he says his office was 68F. If he used 1024 for the calculation, he ends up about where I am, at 435 degrees C.
It’s entirely possible that I’m missing something - so, please correct me, if so! Otherwise, can someone confirm this is a bug in the Example (my guess is the conversion from voltage to temp), and maybe provide the correction?