Voltage divider with over 100k values for reading a 7.4V battery voltage (Attiny

Hi!

I'll use a voltage divider with two 100k resistors to analogread the 7.4V batttery's voltage with an Digispark Attiny85 (that's also powered by this battery).

I can't find anymore the post that said something about having to add a capacitor to "stabilize" the readings when using high values of resistors in this Voltage Divider.

So, If I want to keep current draw at minimum (using this 100k + 100K resistors), which capacitor and how should I connect it? Apart from adding this capacitor, are there any other reasons I shouldn't use resistors in this 100k range? And adding this capacitor then things are as normal (in terms of measuring voltage) as using for instance two 10k resistors?

Thanks!

I presume you won't need to take ADC readings very frequently so you may find that you get perfectly good readings without any capacitor.

...R

Robin2:
I presume you won't need to take ADC readings very frequently so you may find that you get perfectly good readings without any capacitor.

...R

Indeed. One reading each 5 seconds... but for each reading a mean of 5-10 analogreads sequentially.

Thanks!

You can use 1 Meg resistors to further reduce the current draw. Most people use a 10 to 100 nF capacitor.

With that capacitor in place, there is probably no advantage in reading the ADC value more that once.

What are you using as your voltage reference?

Rimbaldo:
but for each reading a mean of 5-10 analogreads sequentially.

Leave 50 or 100 msecs between the sequential readings?

...R

You could use a FET to turn off the voltage divider between reads to save a bit of power.

jremington:
You can use 1 Meg resistors to further reduce the current draw. Most people use a 10 to 100 nF capacitor.

With that capacitor in place, there is probably no advantage in reading the ADC value more that once.

Thanks! The capacitor goes between input pin and gnd, right?

Thanks!

johnerrington:
What are you using as your voltage reference?

Well, i just did the math for the voltage divider, with no other reference. Is there a reference in the attiny85 that requires no extra pin to compare with?

Thanks!

For voltage measurements you should use one of the internal references of the Attiny85.
It has a ~2.56volt reference and a ~1.1volt reference.
For the 2.56volt one you could use a 10:22 divider (10k + 22k or 100k + 220k).
And set Aref to 2.56volt in setup.
Leo..

hammy:
You could use a FET to turn off the voltage divider between reads to save a bit of power.

I have no spare pins left to control the FET....

The capacitor to smooth the voltage would go between the joint in the voltage divider (input pin) and GND, correct? Could it be a Ceramic SMD capacitor, not electrolytic?

Johnerrington said 10-100nF is a good value. Does it change (the capacitor value) if the voltage divider is in the 100k range, or 1M range?

Thanks!

"I have no spare pins left to control the FET...."

Are your analog input pins used? Those can also be used as digital pins to drive a FET.

Anything between 10-100n ceramic (pin to ground) is fine, also if you use high value resistors.
A double read of the analogue pin, and use the second reading, also helps stabilise things when high resistor values are used.
Do use one of the internal Aref voltages for stability.
Leo..

The internal sampling cap of the Arduino ADC is about 14pF according to the datasheet. You can make the calculations. If the filtering cap is 1000 times larger the error is 1/1000 of full scale in the worst case. In other words ADC it will be negligible for the cap > 10nF. Size of the capacitor and resistors determine response speed and may be important if your application have short bursts of large current draw and you want to measure the battery voltage under load.

CrossRoads:
"I have no spare pins left to control the FET...."

Are your analog input pins used? Those can also be used as digital pins to drive a FET.

Unfortunately all Attiny 85 pins are used in this project... no other left.... Two For I2C, one for PWM a 3W led, two for a red/green led (battery level led), one for reading voltage.. all 6 are used...

Sounds like it is time for a bigger chip.

Wawa:
Anything between 10-100n ceramic (pin to ground) is fine, also if you use high value resistors.
A double read of the analogue pin, and use the second reading, also helps stabilise things when high resistor values are used.
Do use one of the internal Aref voltages for stability.
Leo..

Could I use the DEFAULT reference, or it must be an internal one? There are the 1.1 and 2.56V internal ones in the Attiny85.

Smajdalf:
The internal sampling cap of the Arduino ADC is about 14pF according to the datasheet. You can make the calculations. If the filtering cap is 1000 times larger the error is 1/1000 of full scale in the worst case. In other words ADC it will be negligible for the cap > 10nF. Size of the capacitor and resistors determine response speed and may be important if your application have short bursts of large current draw and you want to measure the battery voltage under load.

There's indeed variation in load, when the 3W led is turned on and off. It changes the voltage readings. I have done a " "correction" array so that the red/green bat level indicator gives the same output as when the 3W led is on and off. And the "correction" is different for different levels of PWM on the 3W LED. I used 6 levels of intensity, and each one shows a different voltage reading. I used a multimeter to measure each level when on and off.

As for the resistors, if using the 100K + 100K or 1M + 1M, the capacitor value would be the same? Or is there a "formula to calculate it ?

I'll take readings from 5 to 5 seconds only, and there's no need for great precision. I'll have six bat levels only to display.

Rimbaldo:
Could I use the DEFAULT reference, or it must be an internal one? There are the 1.1 and 2.56V internal ones in the Attiny85.

The default reference (the supply) is unstable, as you have experienced.
The internal ones are stable.

Switching to one of the internal ones only requires one line of code in setup(), and the right voltage divider ratio.
No code change.

analogReference(INTERNAL); // for the 1.1volt reference
or
analogReference(INTERNAL2V56); // for the 2.56volt reference

Leo..