illuzn / esphome-april-soil-moisture-sensor

ESPHome Configuration for April Soil Moisture Sensor
GNU Affero General Public License v3.0
5 stars 2 forks source link

Short battery life #6

Open tabascoz opened 1 month ago

tabascoz commented 1 month ago

Hi there,

I am unable to get the sensor to work over a week. even with 12h deep sleep. how much time do you get yours running?

Do you think the device could be defective? mine came with 600mah battery. I updated to esphome 2024.7.1 and your latest code and will see how it goes. I'm running with default global values, removed temperature sensor routine as it looks the device doesn't have temp sensor.

Screenshot from 2024-07-30 11-40-56

illuzn commented 1 month ago

That is very bad, looks like your run time is very short too... I assume this is a new unit (as noted in the readme, especially when exposed outdoors to large temperature swings - the battery capacity degrades significantly).

If you have a multimeter at home you can test the current draw against the new figures I posted in the readme.

Alternatively, to further diagnose the issue try setting the run_time to 7 days and the sleep_time to 1s (this effectively makes it always on). You should have a run time of around 4-5 hours (this is why deep sleeping the device with short run times makes mine last 6 months (at least when brand new)).

tabascoz commented 1 month ago

thanks for the ideas! Mine is indoor and almost no temp fluctuations. Device is 4 months. I have a clamp dc multimeter, will need to buy another to read reliably in miliamps range. will check my runtime with always on and see if it might be a battery issue before purchasing the multimeter. will post the results. thanks!

illuzn commented 1 month ago

Only other thing I can think of is a short circuit. You might want to inspect the circuit for any signs of corrosion. I had this happen to one of my units which I put too deep into the ground.

tabascoz commented 1 month ago

Hi illuzn,

sorry for the delay in answering, i was out (summertime). So yesterday i tried the runtime and the battery is fine (great) Screenshot from 2024-08-13 12-36-56

It ran from 5:20pm to 6:15am, so more than 12 hours.

I am suspecting that it is something with deep_sleep. I have ordered a multimeter and i am waiting for it to arrive. In the meantime, could you please let me know which version of esphome youŕe using? I am suspecting there's something not right with deep sleep current in recent versions. I recall when first installed it it was fine, but i did an update and i suspect issues started after.

Please let me know the Esphome version you're running, i'll try to downgrade and see if it helps.

illuzn commented 1 month ago

Hi, that's a pretty typical voltage curve that I would expect.

Most of my units are using 2023.11 when I posted my 1 year update (and updated all of them).

My instant testing unit (which I use to test this codebase) is updated very frequently and is running 2024.7.2. I am noticing potentially unusually high deep_sleep power consumption (around 1% per day) but this is during that initial drop from 4.2V down to 3.8V on your graph where the drop tends to be more steep. In any event, that isn't even close to the 7 days runtime you are getting (I would expect around 3 months or maybe slightly less at this trajectory).

It's obviously not waking up from deep_sleep otherwise you would see it connecting to your network (and providing data to HA) during that time.

Did you change your OTA/update configuration for 2024.6? i.e. did you include:

ota:
  - platform: http_request

or

update:
  - platform: http_request

Actually, it might be useful for you to post your template.yaml and unit.yaml here so I can check and confirm.

tabascoz commented 1 month ago

HI there, please find below. I have not changed ota settings.

You can see some tweaks (commented) I've tried. Nothing really changed a thing. I have also disabled i2c as the board that i have does not have the sensor( i believe). Can post pictures of the board also.

Typical log (as of now) :esphome.log

Yaml: esphome_planta.yaml.txt

illuzn commented 1 month ago

Oops you've posted your fallback wifi, ota password and HA API key in clear text... highly recommend you change those now.

You have a lot of commented things which are completely unnecessary and come from the upstream which was the inspiration for my project. Given they are commented it shouldn't affect your battery.

What is interesting to me is this section

  on_shutdown:
    then:
      #- logger.log: Shutdown called
      #pinMode(4, OUTPUT);
      #digitalWrite(4, HIGH);
      #- lambda: |-
      #    gpio_deep_sleep_hold_en();
      #    adc_power_release(); 
      - lambda: "adc_power_release();"
      #-  output.turn_off: moisture_gen
      -  wifi.disable
  on_boot:
    then:
      - wifi.enable: 
      - lambda: "adc_power_acquire();"

In particular this adc_power_acquire() and adc_power_release() logic. To my mind it is completely unnecessary because if you look at how the code works:

interval:
  - interval: 5s

    then:
      - output.turn_on: moisture_gen
      - output.set_level:
          id: moisture_gen
          level: 34%
      - delay: 500ms
      - component.update: rMoisture
      - component.update: iMoisture
      - component.update: aMoisture
      - output.turn_off: moisture_gen

Every 5s the ADC is turned on for 500ms then immediately turned off. Your code block is redundant and I'm not sure that the ADC is actually being turned off correctly before shutdown (or in this case, deep_sleep). For more information see the priority referenced here: https://esphome.io/components/esphome#esphome-on-shutdown

I'd suggest downloading the template.yaml and test-unit.yaml and trying again without those customisations.

tabascoz commented 4 weeks ago

Yep i will!

I wrote an answer, git got down and it was never published :(. The attempts you saw commented were all tries after it started draining. What do you think about wifi.disable line?

I am still waiting the new multimeter to arrive from Al****ss and would definitely help. In meantime i am compiling now the 2023 latest version of esphome and will try with your code as baseline, no changes.

Will report in a while , thanks again for all the attention