New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-)
-
@Yveaux said:
@ServiceXp So you want to connect VCC of the ATMega to ana analog input pin to read the supply level?
If this is your idea, then the ATMega will measure the voltage on an analog input relative to the supply voltage. If the supply voltage of the ATMega starts to drop, the relative voltage measured on the analog input will not change w.r.t. VCC.
By using a voltage divider you bring the voltage to be measured within 0,..,1.1V range (roughly). The ATMega has an internal 1.1V voltage reference which will remain stable when VCC drops, and thus can be used to meaure the supply level using a voltage divider.-
No; vBatt to AO; MCU will be powered by Step Up Reg. vOut.
-
The MCU supply voltage will never be lower then vBatt. (in the case of 2 AA Batteries). vBatt will always be lower then MCU VCC, In all reality MCU VCC will never change in a significant way, until Step Up Reg drops out.
-
think it's this v1.1 ref. that may be confusing me, but it just seems like this method should work with out the V div for sensors using 2 AA batteries or any <3.3v power source. ;-)
@ServiceXp OK, I didn't really get your description in the previous post them.
When VCC is stable due to to the step up converter then it should also work to just reference analog input to vcc. This way your measuring range is 0,..,vcc, which is a lot more then 0,..,1.1v -
-
Thread revival.
I have a sensor powered by 2 AA batteries, does this still stand as a simple way to obtain their status? It was super easy to implement!
-
Would this library also work on a WEMOS D1, which is powered by a esp8266?
Paai
-
Would this library also work on a WEMOS D1, which is powered by a esp8266?
Paai
-
@MiKa use hwCPUVoltage(), this works for AVR, SAMD and ESP8266. ESP8266 requires defining MY_SPECIAL_DEBUG though.
@mfalkvidd said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@MiKa use hwCPUVoltage() this works for AVR, SAMD and ESP8266. ESP8266 requires defining MY_SPECIAL_DEBUG though.
Thanks ! It works on SAMD21E board :)
-
@mfalkvidd said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@MiKa use hwCPUVoltage() this works for AVR, SAMD and ESP8266. ESP8266 requires defining MY_SPECIAL_DEBUG though.
Thanks ! It works on SAMD21E board :)
It looks, its working also on NRF5 platform, tested with NRF51822 MCU ;) :+1:
-
@Yveaux Hi, thanks for your work. Maybe I´m going over something that was covered before, but I need some help, I´m using this code in a door sensor with 2 aa battery, and reporting if battery changes, when the door opens or closes. My problem is that I always get diferent readings from close to open, so I´m always reporting battery level and using more power than needed. Thanks
-
@Yveaux Hi, thanks for your work. Maybe I´m going over something that was covered before, but I need some help, I´m using this code in a door sensor with 2 aa battery, and reporting if battery changes, when the door opens or closes. My problem is that I always get diferent readings from close to open, so I´m always reporting battery level and using more power than needed. Thanks
@andredts the voltage reference only has limited accuracy, therefore the reported battery voltage might vary slightly. Also the load on the battery can change, causing a variation in battery level reported. Not a lot you can do about that I'm afraid.
I experimented with sending all decreases in battery level wrt the previous value, and only large increases (eg 10% or more to detect change of batteries). Works quite well. -
@andredts the voltage reference only has limited accuracy, therefore the reported battery voltage might vary slightly. Also the load on the battery can change, causing a variation in battery level reported. Not a lot you can do about that I'm afraid.
I experimented with sending all decreases in battery level wrt the previous value, and only large increases (eg 10% or more to detect change of batteries). Works quite well. -
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
@andredts cr2032 is a totally different story. The voltage level fluctuates significantly when sending messages compared to AA powered sensors.
The 10% is only an example value and used for an increasing voltage level (that normally should only happen when replacing batteries). For a decreasing voltage (regular battery usage) you can just report the level and get much higher resolution. Question is if it will really be useful for cr2032 though... -
How about storing last 10 values and send an average every time?
-
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
@andredts said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
For having consistent measurements with a CR2032 you should measure voltage as first action after waking up from sleep.
I keep the value in a variable and process it after "action" message of the node.If possible, run at 1Mhz on internal oscillator so the power consumption of the atmega stays very low (around 1mA instead of 3 at 8MHz/3V).
-
@andredts cr2032 is a totally different story. The voltage level fluctuates significantly when sending messages compared to AA powered sensors.
The 10% is only an example value and used for an increasing voltage level (that normally should only happen when replacing batteries). For a decreasing voltage (regular battery usage) you can just report the level and get much higher resolution. Question is if it will really be useful for cr2032 though...@Yveaux I know about that fluctuation, but for my use in a scene controller I would be happy just to know the battery is low. I have it running with a multi-button, were I have click, duble-click and click and hold, I only check battery at one click, because of its fluctuation, but if you use it more than 4 times e a short period that fluctuation is noted, and that is why a added to the 10% increase a 10% decrease gap on battery sent information. Thanks
-
@andredts said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
For having consistent measurements with a CR2032 you should measure voltage as first action after waking up from sleep.
I keep the value in a variable and process it after "action" message of the node.If possible, run at 1Mhz on internal oscillator so the power consumption of the atmega stays very low (around 1mA instead of 3 at 8MHz/3V).
@Nca78 said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@andredts said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
For having consistent measurements with a CR2032 you should measure voltage as first action after waking up from sleep.
I keep the value in a variable and process it after "action" message of the node.If possible, run at 1Mhz on internal oscillator so the power consumption of the atmega stays very low (around 1mA instead of 3 at 8MHz/3V).
Hi, I do read the battery first thing after wake up, my problem was when a had various click too close together. It`s good now that I only send battery values that a 10% higher or lower than my last stored value. I will take a look on the 1Mhz bootloader. Thanks
-
@Nca78 said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@andredts said in New library to read Arduino VCC supply level without resistors for battery powered sensor nodes that do not use a voltage regulator but connect directly to the batteries ;-):
@Yveaux Thanks, that was exactly the insight I was looking, for my door sensor with 2aa battery, your way worked great. For a scene controller with a CR2032 a had to not send also decreases greater then 10%, but hey, 10 steps is more enough.
For having consistent measurements with a CR2032 you should measure voltage as first action after waking up from sleep.
I keep the value in a variable and process it after "action" message of the node.If possible, run at 1Mhz on internal oscillator so the power consumption of the atmega stays very low (around 1mA instead of 3 at 8MHz/3V).
Hi, I do read the battery first thing after wake up, my problem was when a had various click too close together. It`s good now that I only send battery values that a 10% higher or lower than my last stored value. I will take a look on the 1Mhz bootloader. Thanks