F. W. <
me@home.com> wrote:
But: How can I calculate the real room-temperature better? The results
are not very accurate.
Often the problem with internal temperature sensors is they're affected by self-heating. If the microcontroller is running in a loop it can consume
some mA which raises its own temperature above ambient, at least until
heat-in is equilibrated with extra heat loss due to the raised temperature.
The solution to that is to go into low power suspend until the package has matched ambient temperature. Then take a measurement as the first thing you do, transmit it, and go back to sleep.
In your code you could try longer sleep() periods between readings, but
you'd have to check if that actually causes the device to go into suspend,
or just spins in a loop. The other approach is to set a timer interrupt for some time hence and then 'Wait For Interrupt' (WFI instruction) which should enter CPU power saving mode. Although you might also need to consider
whether any peripherals are also taking power.
As has been mentioned, using an external temperature sensor that's not right next to the MCU or other heat generating components avoids this problem.
Theo
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)