Monthly Archives: January 2014
While testing on it’s own, without any peripherals, the ATmega328P does a good job in temperature measurements. The question that comes to mind is, “What happens when this chip starts to source current?”.
For my little project, I am looking at 15mA pulse for the radio Tx and an occasional Tx LED blink of 13.6mA.
Since there are three LEDs on the board already, 40mA should be enough to test with.
Using the same sketch as the Hidden Response Accuracy in the ATMEGA328P, I commented out the LM35 measurements and added a Blink without Delay for the (3) LEDs.
Tests included were:
- Measure every second and toggle the LEDs every 10 seconds
- Measure every second and toggle the LEDs every 2 minutes
- Measure every second with the LEDs always ON
While there is an obvious bias with the “Always On” chip heating, the reduced duty cycles can help dissipate some of the heat generated internally. I would imagine 100mA total sourced current will make this a problem for a project requiring <3°C accuracy.
Out of curiosity and the difficulty in finding a decent Arduino IDE sketch for measuring the internal temperature sensor in the ATmega32U4, I decided to post it here. Pretty much the same behavior on the measurement as the ATmega328, just a little different in implementation based on the datasheet section 24.6.
The sketch below has three measurements; the internal ATmega32U4 sensor, the LM35DZ with a Ring Buffer smoothing and the same LM35DZ with no smoothing.
UPDATED – See Below
Some people may have known already about the temperature sensor built into the ATMEGA8, 168, 328 series microcontrollers, but the most serious enthusiast would write off the 1°C resolution as just a coarse sensor of no practical use. I would have to say I was part of that group, until I compared the response between the two sensors.
The TI LM35DZ is a simple temperature sensor that has an accuracy of +/-0.5°C at 25°C and with 0.08°C of self heating, this should be sufficient to demonstrate the rough nature of the ATMEGA328’s internal temperature when compared to dedicated external sensor. The TO-92’s have the best Thermal Reponses on the datasheets and are the cheapest. Connection is straight-forward, +5VDC, Vout and Gnd with Vout to the ATMEGA328’s PC0 (Arduino pin A0).
For the ATMEGA328 internal sensor, adjustment of the voltage offset can be used to calibrate to another sensor.
The Arduino IDE sketch is as follows: