I am using Atmega328P to read temperature from LM35 and display it on the LCD (along with few several things it does).

I want to understand the capacitor and connections for the AVR itself and AVcc.

I read stuff online, about decoupling, bursts, under-power and such, but I did not understand what I should connect to do it right.

Some said I need to connect 10uF electrolytic cap to Vcc and ground, and to AVcc and ground.

Others said I need to connect ceramic 0.1uF to Vcc and GND and AVcc and GND. Some said both.

I am confused, really confused :)

Also, I am starting to think I need to recheck my LM1117 3.3V regulator caps, I am using 2 10uF caps (Input V and GND, and 3.3V and GND).

Can you help please?

  • \$\begingroup\$ I'm also confused. Do you need help with understanding how to properly decouple and filter your AVcc and Vcc? Are you also having problem reading your LM35? \$\endgroup\$ – Dejvid_no1 Apr 8 '14 at 19:51
  • \$\begingroup\$ It looks like the LM35 reading a bit low than the actual temperature, But I also want to understand the capacitors needs and what is needed to get better "guerd" of the AVR and ADC stable reading.. Thanks. \$\endgroup\$ – gabi Apr 8 '14 at 20:00
  • \$\begingroup\$ follow manufacturer guidelines.....there are lots of app notes regarding decoupling capacitor selection and placement in web... \$\endgroup\$ – user19579 Apr 9 '14 at 5:22

I will first talk about decoupling capacitors, and then specifically the options the Atmel 328P has for it's AVCC and AREF pins.

Decoupling capacitors are used to provide short bursts of energy during digital switching circuits (they go from zero to full voltage in a very short amount of time, they need energy and available current source nearby to do this) and as a general value everybody just puts 100nF (0.1uF) capacitors at the power pins of every single IC used in their boards. This is a safe and good strategy. It is not, however, strictly needed unless your system is large and complex. If you have a regulator (with it's own capacitors) very close to your Atmega you will be fine with out them.

Your regulator is fine with a 10uF capacitor on the input and output, you do not need to change those. In the future though, you should ALWAYS consult your regulator's datasheet. Some regulators cannot use high "ESR" capacitors as they can cause unstable operation, and likewise some regulators cannot handle ultra-low ESR capacitors like Ceramic capacitors because they will "ring" and ripple uncontrollably (overshoot constantly) among other hilarious power control system challenges.

AVCC is the analog voltage supply used internally by the ADC and is most commonly internally connected to the AREF pin, used directly as the reference for ADC readings. You can either filter and decouple AREF, or VCC, but the one that matters most depends on what you actually want for your ADC. The Atmel328P has internal Vref (2.56V or other ones) you can select, for exampl. You can also provide your own reference voltage at the AREF pin, and other than power supply ripple your AVCC becomes less important in terms of filtering. You might have bought a precision 3V reference IC, and followed it's datasheet guidelines for suggested circuit, and then put the Vout into the AREF pin of the AVR. In this case, AVCC can be left with either:

  • direct connection to VCC
  • or a simple decouple 0.1uF cap to help with local noise filtering
  • with an inductor or ferrite bead in series from VCC into the AVCC for AC current ripples, and if you put a capacitor to ground here as well (AFTER the inductor), it becomes a current AND voltage ripple filter - nice and clean!

AREF could be left unconnected, and merely filter VCC. Often if the AREF pin is un-used and AVCC And AREF are internally connected, you can put a 0.1uF capacitor on the AREF pin, which will have the same effect as putting the capacitor on AVCC due to the internal connection. Maybe this can assist with circuit layout?

If you have a slow, steady state error on your temperature sensor, I bet you it's not related at all to ADC or power supply filtering - I bet that the error is within tolerances given by the datasheet (usually +-15% which is quite a lot!). You almost always need to (usually only once) 'calibrate' your ADC readings by getting a known (working) thermometer at ambient temperature nearby, and adjust the offset of readings to make it line up with expectations. The sensor's rate of change (mV/Degrees celcius) should still be fine, it's just the 'steady state error' inherent to low tolerance manufacturing.

  • \$\begingroup\$ Sorry to comment this old post, but i have one question: If we use the inductor for AVCC does we also need power analog devices from filtered AVCC or doesn't matter if we use the 5V for analog devices? I heard somewhere if not use AVCC we can introduce noise into analog circuit but we also missing a AGND on MCU... \$\endgroup\$ – Tiago Conceição Jul 17 '19 at 22:30
  • 1
    \$\begingroup\$ hello @TiagoConceição, it's okay to ask questions in the comment. If you use the inductor (or ferrite bead) and capacitors and filter the 5V supply (VCC) to create a cleaner supply (AVCC), you should power your low-power analogue devices from that if you can. Power supply noise is a big problem for sensitive analogue devices, and often shows up in the analogue outputs. Having only AVCC for your microcontroller just means the -readings- will be clean, but the data is still coming from a noisy source if you only power it from VCC. Use AVCC if you can! I hope that helps. \$\endgroup\$ – KyranF Jul 18 '19 at 8:08
  • 1
    \$\begingroup\$ if you need high quality readings, you should also supply any resistor dividers and potentiometers circuits with AVCC instead of VCC. The MAX6675 should be given the filtered AVCC input, because internally it will be using it as a reference and to power its internal ADC.. there is something called "PSRR" or power supply rejection ratio - this is how good a chip is at rejecting/filtering noise out of its supply voltage rail and not having supply noise end up in the output signal. \$\endgroup\$ – KyranF Jul 18 '19 at 20:41
  • 1
    \$\begingroup\$ Go for a ferrite bead, they are usually smaller, cheaper, and low-power enough to do the job. They behave a little less 'aggressively' than a real inductor. just resistive at high freq. They don't store as much magnetic field so they are less likely to have the inductive voltage spike which happens when supply is suddenly taken away from them from stored magnetic field. A ferrite bead is a better choice for filtering out power supply noise, whereas an inductor is better for larger scale filtering and power circuits (from my experience) \$\endgroup\$ – KyranF Jul 19 '19 at 19:53
  • 1
    \$\begingroup\$ Why would you want 10uH? that seems like a lot for a filter. The ferrite beads act as resistors to signals/power noise which has 'high frequency'. The resistance absorbs the energy and reduces the filtered circuitry from seeing the noise as strongly. Calculate a low pass filter with cut-off band at maybe 10Khz, using the ferrite bead resistance at 10khz from the part datasheet. then specify a capacitor to finish off the low-pass filter. E.g ferrite is 5ohm at 10khz, nearest standard capacitor value is 3.3uF to get a cut-off freq of 9.6Khz. It is even more powerful filter at high freq! \$\endgroup\$ – KyranF Jul 20 '19 at 12:23

The left side of the image shows how to interface ATmeaga664. However, the principle is the same for the 328 model, I believe:

enter image description here

If you do not have any other power consumption except your microcontroller, you might not need a 10uF cap. But I would suggest to use both 10uF and 100nF in parallel. I had a similar question here. Notice, that analog AVCC is connected to supply through an inductor. Do not know what it is for. Look at the datasheet, I they might have some examples.

Edit: According to LM1117 the datasheet, there should be a 10uF on the input and the output. Then do so.


I suggest that you head over to Atmels site and search for their application notes on ADC or power supply considerations. Although application note Atmel AVR32837 is for a totally different CPU it as some explanatory pictures of capacitor values and connections. Application not Atmel AVR042 might be good for you also.

Check your LM35 with a voltmeter and check if it there is a difference with your reading.


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.