I’m new into the esphome/HA-thing, but I’m totally in it after a few days
I want to build multiple sensors and automations for my home and want to doi on my own, without buying expensive plug&play stuff (ok some of these things are quite practical :D)
I managed to build an easy PIRmotion sensor using an esp8266 wemos D1 mini and managed to automate, that it turning a light and sends me a notification via WhatsApp and HA-App.
It was not difficult, because I used mostly things, I copies from the internet.
But now a want to power the sensor with a Lipo battery. I ordered a battery shield to recharge the battery, but I have no clue, how to monitor the remaining battery level from Home assistant.
For batteries, I would certainly advise that you get a charger / system that can handle this for you, and talk to that. Batteries can be a bit finicky, and chargers are not something I would encourage DIY. Easy way to start a fire.
That being said, if you’re just trying to measure battery level, voltage is a fairly safe method, but be aware that adding anything to your battery can be a risk, and may drain it more than not having monitoring. The easy way is to measure voltage and compare against expected. A 2.4V battery may measure 2.46 at full, and 2.12 at empty, for example. Then you’d just have a linear regression from 100% at 2.46 and 0% at 2.12. Most typically, you’d set 0% to somewhere above the “limit” so as to protect your battery from discharging too much.
That showcases a fairly easy walkthrough of how you could use a battery to power ESP Home devices. Seems reasonable, and you’d probably just swap out new batteries, and/or charge them separately. Keeps any battery charging separate.
Then for measuring voltage the ESP 8266 has an ADC Pin you can use:
Just need a voltage transducer or transformer to reduce the voltage range from 0-4.xV of the battery, to 0-1v. You could use a simple voltage divider circuit to divide by 5, and you’d be safe. Just depends on the accuracy of the ADC. I’m sure you can google an answer to how to measure higher voltages on this pin. You’ll want some diodes, capacitors, resistors, etc. Best to find an example from someone unless you have small circuit knowledge.
Oh ya! I can tell when someone has the esphome itch… You’re hooked now. I know someone already mentioned it but, messing with Li ion especially is quite risky if you don’t understand how to charge and care for them properly. Many people have not taken the warning seriously or they didn’t bother learning first and they burnt their homes down. Dealing with batteries is 100% doable but you need to know what your dealing with.