I have a TMP36 connected to an analog pin of an Atmega328p-pu on a breadboard (with Arduino bootloader), everything is powered w/+5V from an Arduino Uno R3 (which is used as a programmer).

The reading I get are steady, but when I connect a piezo buzzer to a pwm pin, the temperature reading jumps higher, when I disconnect the piezo jumper wire, the temperature drops down again.

What is going on? I suspect that the current is not sufficient for the atmega chip and the buzzer and the tmp36, but I don't know whether that's true... how would you solve this?


1 Answer 1


It sounds like you're missing decoupling capacitors. Put 100nF capacitors across the supplies of all ICs (not on the supply lines, right at the supply pins themselves), and a 100uF capacitor across the supply lines.

Additionally, you can characterize and calibrate the ADC, and use averaging or decimation if you find it still too noisy.

  • \$\begingroup\$ Thanks Ignacio, your suggestion did improve the reading a bit, now the temperature seems a bit closer to reality, but connecting the piezo buzzer still affects the temperature by as much as 1 degree. I do perform averaging but it's not just noise, but rather a completely different reading (a steady increase of 1.5 degrees) I used 2 x 0.1uF capacitor on the IC pins and 3 x 47uF across the supply lines at various places. \$\endgroup\$ Nov 20, 2013 at 16:22
  • \$\begingroup\$ @GetLastError: Try using one of the built-in references instead of Vdd, and use a voltage divider to reduce the analog voltage if required. That should firm up the value regardless of the drain on the supply (down to about 3V or so for the 2.56V reference). \$\endgroup\$ Nov 20, 2013 at 16:31
  • \$\begingroup\$ Can you please explain what do you mean by Vdd? and where to put the voltage divider exactly? I'm now using a single 470uF on the main power line and an additional 0.1uF on the output of the TMP36... I also reduced the voltage to 3V using a voltage divider, on +Vs (of the TMP36). \$\endgroup\$ Nov 20, 2013 at 17:02
  • \$\begingroup\$ Hrm. It looks like the '328P doesn't have an internal 2.56V reference, or allow Vdd as a reference (but uses AVcc instead). The reference is chosen via REFS[1:0] in ADMUX, p.134 of the datasheet. You need a voltage divider on Vout of the TMP36 in order to reduce the voltage to within the reference voltage. I recommend using a shunt regulator such as a TL431 on Aref so that you get a stable reference voltage. \$\endgroup\$ Nov 20, 2013 at 17:47
  • \$\begingroup\$ Well, I have another 5V voltage regulator, but doesn't it need a slightly higher voltage to function properly? I tried now to put a P2N2222A transistor on the buzzer but still with no luck... :( \$\endgroup\$ Nov 20, 2013 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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