Atmega decoupling AVcc and Vcc separately

Hi, I'm quite new to microcontrollers and I've encountered couple of things which are not clear to me.

I would like to design my own battery powered wireless sensor. The device should read temperature from i2c sensor read battery voltage using analog input and send the results to the server via nrf905 transceiver.

So I downloaded eagle and started drawing schema. However I'm not sure how to properly decouple Vcc and Analog Vcc.
In the AVR042: AVR Hardware Design Considerations appnote section 1.2 it says:

To be able to obtain good accuracy with the ADC the analog supply voltage must be decoupled separately, in the same
manner as the digital supply voltage. AREF must also be decoupled; a typical value for the capacitor is 100nF. If a
separate analog ground (AGND) is present, the analog ground should be separated from the digital ground, - so that the
analog and digital grounds are only connected at one point, - the origins of the GND i.e. at the power supply GND.

I'm not sure what decouple separately means. Does it mean I would connect power to Vcc and AVcc and then use two separate caps to ground it to different grounds as shown in the schema? And then what if the chip doesn't have separate analog ground pin (not in my case)?

And do I have to decouple AREF even if I would have to use internal voltage reference since I want to read supply voltage?

I would greatly appreciated if someone could throw some light on it. Thanks

attached schema (work in progress):

Don't worry about that.
You only use the analog inputs to read the battery voltage ? Take a few samples and use the average. That solves all the Vcc/Avcc noise.

You can connect all Vcc and AVcc and also all GNDs. No problem.

A 100nF at ARef is good. It reduces the noise of the internal voltage reference. But you probably won't see a difference when you don't have the 100nF.

Suppose in a non-Arduino environment, the analog signal is read with a high rate, using a timer interrupt. In that situation it is important to get the maximum accuracy of the 10-bits ADC, and all the guidelines should be followed.
You want to read the battery voltage, so you can ignore all the guidelines and use the average of a few samples.

Ok thanks a lot.

I rewired decoupling caps and fill up parts values. I also added voltage divider to feed the analog input.

The board should be as much energy efficient as possible. So I'm thinking about adding transistor to switch off i2c bus power when MCU is sleeping. This should prevent pull-ups from sucking energy all the time.

If anybody has some improvements or corrections I would be happy to hear it.

schema:

The rule of thumb is to use a maximum of 10k circuit impedance to read an analog voltage.
Your 3M9 and 1M are very high, I suggest to use 1nF parallel the 1M. And if you use the average of 25 samples and tune the value of the internal reference voltage in your sketch (it is never 1.100V), then an accuracy of 0.1V of the battery voltage should be possible.

In the schematic, you are not reading a 12V battery or so, but a battery in the 3..5V range ?
That makes it a lot easier. You can omit the 3M9 and 1M and read the Vcc internally in the chip.
Search for "secret voltmeter" or "readVcc".

Perhaps a resistor of 10k from RX to ground ? When nothing is connected, the input is floating, and the Serial library is reading the noise, thinking that data is coming in.

You don't have to switch off the pullup resistors of the I2C bus. When no one is active on the I2C, no one is pulling it low, and there is no current going through the pullup resistors, not even an micro-ampere.
Or do you mean the I2C 5V ? Try to find the current for the sensor first, they use often very little current in sleep mode.

The datasheet recommends a 10µH inductor and a 100nF capacitor. I’ve started including this in my circuits (here is one example). I haven’t gotten around to comparing the results from a circuit with the inductor to one without, but it’s somewhere on my things-to-do list :roll_eyes:

I used the 10µH inductor and a 100nF in my first circuits, because it was demanded by the datasheet.
But I don't use it anymore for a normal LDR, TMP36, or voltage reading. It doesn't make a big difference for slow changing signals. I always do some averaging in my sketch. All my accurate sensors are I2C anyway :wink:

The most success I have had to reduce noise in a noisy environment was to add a ferrite bead to the trace providing the power to the pin.