Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
jpiatt
 
Posts: 7
Joined: Wed Apr 18, 2012 4:38 am

Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by jpiatt »

I'm using a Feather ESP32 V2 to report soil sensor readings from the Monk Makes Plant Monitor to my Home Assistant. I'm also monitoring the level of my 3.7v LiPoly battery using GPIO35 but my readings are consistently 1/4 of the actual voltage level (not 1/2 as the docs say it should be). I should mention that the battery hasn't really discharged at all since I started my testing because I just took the board off the USB tether yesterday and I'm keeping it in a deep sleep, only waking every hour for 90 seconds to take readings and report them. The raw value I'm getting for a fully charged battery is about 1.045 volts, which X4 would be the correct value of about 4.2.

Anyway, I'm asking in case something changed in the board. Anyone else seeing this? I'm using the right pin, yeah?
Here's the sensor definition I've coded for it:

Code: Select all

  - platform: adc 
    id: battery_level
    name: "Battery Level"
    pin: GPIO35
    filters:
      - multiply: 4 # supplied value is 1/4 actual voltage (docs say 1/2 but ...)
    state_topic: ${io_username}/feeds/spike-batterylevel
    on_value:
      - then:
        - mqtt.publish: 
            topic: ${io_username}/feeds/spike-batterylevel
            payload: x
    update_interval: ${update_interval}

User avatar
mikeysklar
 
Posts: 14790
Joined: Mon Aug 01, 2016 8:10 pm

Re: Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by mikeysklar »

What code is running Feather V2?

If you remove the deep sleep do you still see the same 1/4 value instead of half value for the battery reading?

User avatar
jpiatt
 
Posts: 7
Joined: Wed Apr 18, 2012 4:38 am

Re: Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by jpiatt »

Sorry. I just saw this today as I forgot to tick the button for reply notifications. Anyway, the Feather is running ESPHome. I did finally try it without the sleep code and got the same result. However, until today I hadn't really had a chance to see what it reports for a partially discharged LiPoly. It reads the same value as a fully charged one (1.045V)! So something isn't right.

I'm gonna load some simple Arduino code and see what it shows then.

User avatar
mikeysklar
 
Posts: 14790
Joined: Mon Aug 01, 2016 8:10 pm

Re: Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by mikeysklar »

Good idea to try the Arduino code to compare. This could be an ESPHome specific issue.

User avatar
jpiatt
 
Posts: 7
Joined: Wed Apr 18, 2012 4:38 am

Re: Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by jpiatt »

So, it turns out the ADC on ESP32 is capped at ~1.1V for measuring input voltage. ESPHOME offers an "attenuation" keyword with several possible settings to compensate and, most helpfully one simply stated as "attenuation: auto". Once I implemented this change, I was indeed getting a reading that is one half the expected value.

User avatar
mikeysklar
 
Posts: 14790
Joined: Mon Aug 01, 2016 8:10 pm

Re: Anyone else getting a battery level reading on Feather ESP32 V2 GPIO35 that is 1/4 the actual value??

Post by mikeysklar »

GTK, Thank you for the followup on this.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”