my setup is ESP8266 - 02 Wroom lipo (16850 battery charged) + DS18B20 temperature sensor. I would like to see, how much battery is still available in % if this is possible with my setup. I did try some other solutions from other topics, but with no luck for me.
In ESPhome am using this code for temperature reading:
In Hassio I have temperature card, where I can see temperature, but like I said, I would like to observe also battery charge… To complicate things a little more, I would like to see temperature and battery charge in the same card, like this:
Can anyone help, but please be aware, that am newbie in Hassio system and coding.
Use the analogue input to measure the battery voltage. You will need a voltage divider to do this as it exceeds 3.3V.
16K For R1 and 47K for R2 would allow you to measure up to 4.42V and use a scaling factor in ESPHome of A0*1.34 to get the true battery voltage. You want to aim for a total series resistance somewhere in the ballpark of 100K to not draw too much current from the battery but still allow a reasonable input current into the ADC.
Then use the following lookup chart to convert to (a very rough) percentage in ESPhome:
I will try both proposals, but I must say, that second proposal is a little bit science fiction for me and my knowledge at the moment.
Before I open new topic,… I would like to put my ESP8266 to deep sleep. I uploaded code to ESP and seems, that code works well, but…ESP doesnt wake up by himself - I need to press RST button.
I googled, that GPIO16 and RST pin on ESP should be wired, on my Wemos ESP8266 - 02 wroom this is already factory done.
ESP goes to deep sleep, but after 30 min, nothing happens (blue light on ESP starts to glow). After pressing the RST button, the ESP wakes up, take a measurement and go back to deep sleep.
Don’t get me wrong, but I really don’t know, where to put 16 and 47 K resistor… I thought that the ESP8266 could read the voltage on itself without any additional wiring…?
It can read up to 3.3v. Your battery can be as high as 4.2v if properly charged.
If you only read the internal 3.3V supply (Vcc) this will tell you nothing about the state of the battery as it is held at a constant voltage by a voltage regulator.
Ok, I understand (hope so) now, I need to connect + / - on battery via 4,7K and 10K resistor. Then I need to conect pin AD with exit from the devider between the two resistors.
Ok, now I have properly wired directly across the battery and I am measuring the voltage in Hassio. The shown voltage is too small and needs to be multiplied…
I have one more question related to this topic. I have another same ESP8266 and I would like to connect it with soil humidity sensor which have analog output (I assume, that sensor in this case must be connected to A0 pin). In this case, I cannot measure battery level, because analog A0 pin is taken by sensor…Is there any workaround for this?