The use of the ESP8266 in the world of IoT

User avatar
By dperezq
#33901 Thanks, that is what I need it to solve my doubts. So, if I change the 01 for the 12 could I measure and sent the voltage to thingspeak? Do you know the best way to measure the battery? Because I know that having the total V, I can measure the current V and make the maths, is this right?

And do you know the code for doing this? Because I only found the code for AT commands, but not using the Arduino IDE
User avatar
By Barnabybear
#33906 Hi, I've looked into measuring battery voltage & there is tonnes on the net about it. In the end it all comes back to the same problem - to measure the voltage you have to attach something to the battery & this just discharges it faster.
Easy example would be to have a 10K pot between your battery & ground. Connect a variable power supply set to the alarm voltage. Then adjust the pot until this gave a logic 0 & then you could look for a change from logic 1 to logic 0 to report your battery needed changing.
But the 10K pot is discharging @ in your case:
V = I * R I =V / R
I = 9V / 10,000 ohms = 0.9mA / Hour.
Also this is a bit hit & miss as a logic 1 is =>75% Vcc, & a logic 0 is =< 25% Vcc. So it's a bit of a moving target. As the supply reduces so do the logic detection voltages, with a big gap in the middle. The easy answer is to use an op amp to ensure you get a reliable "battery good" / "battery needs changing" logic level. Again that needs power.
So is there an answer - yes if you have an "always powered up" system the power needed to check the voltage is negligible.
If you have a system that “sleeps” then even 1mA during sleep is massive – I’ll assume you’re not sleeping at the moment.
Then you get into when do you check the voltage, before or after a transmit? The guys who “sleep” favour a “wake – check – transmit (with their data)”, I can see the logic in that. But depending on the battery age, does a wake up voltage mean you have the power to transmit, is it not better to check after you have transmitted – but that uses more power for a second transmit.
What a can of worms!
There is no easy answer, it depends on, how important the information is, how frequent it is & the proximity of the device to be able to change the battery when you get a warning.