Setting up a battery powered soil moisture sensor

Hello everybody!

Following this idea I tried to modify the senors to be used in the earth: waterproof and battery-powered. Now the case is ready and thight and the sensors seem to work as they should: calibration was also successfull:


I used this ESP32, this capacitive sensor and this battery in accordance with this 3.3V LDO. This is the actual code:

substitutions:
  name: "gt_feuchtigkeitssensor_nord"
  friendly_name: "Garten Feuchtigkeitssensor Nord"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"

esp32:
  board: nodemcu-32s

api:

ota:

logger:

mdns:
  disabled: false

web_server:
  port: 80

wifi:
  ssid: 
  password: 
  ap:
    ap_timeout: 24h

sensor:
  - platform: adc
    pin: GPIO32
    name: "Garten Erdfeuchtigkeit Nord"
    id: gt_soil_north
    attenuation: auto
    update_interval: 1s
    unit_of_measurement: "%"
    icon: "mdi:water-percent"
    filters:
    - calibrate_linear:
      - 0.83 -> 100
      - 2.22 -> 0

Now my problem is that the ESP32 only occasionally comes up and gets connected when battery-powered. When connected to USB it works fine.

Any ideas? Help would really be appreciated! Text

Are you moving it when powered via USB versus the battery?

Why such a long timeout?

Is your wifi signal strong where you are using the ESP32 when powered by battery?
Also check the wifi channel in use and preferrable have it set to a channel with low congestion just in case there is interference from other nearby wifi networks.

You can also try the following wifi config to turn power saving off:

wifi:
  # ...
  power_save_mode: none

Bear in mind that using wifi is pretty power hungry so Iā€™m not sure how long the battery will last for you before it will need recharging.

An alternative would be something like the Ecowitt weather stuff like the following:
https://www.amazon.com.au/ECOWITT-Weather-Station-Powered-Outdoor/dp/B09N987PML/ref=sr_1_8?crid=1RWLZ103399FX&keywords=ecowitt&qid=1687910683&s=home-garden&sprefix=ecowitt%2Cgarden%2C421&sr=1-8&th=1

There is an Ecowitt integration to HA and you can then add more soil sensors or weather sensors and have them all integrated with HA.

So you are saying a WiFi sensor is power hungry and then suggest another WiFi sensor? :grinning:

ESPHome can be set to only report like 2 or 3 times a day to minimize power.
If you want more readings then a RF sensor is the best, because it just broadcasts and then hopes something is catching that.
No overhead, no connection hand shake and so on.

If you go with a WiFi sensor anyway, then limit the WiFi connection process as much as possible by using fixed IP.

What I was suggesting is a broader solution.
The wifi component is the Gateway to receive the RF signals from the sensors and is USB powered.
The USB powered wifi gateway allows all the Ecowitt RF sensors to be connected to HA.

Ok, that is RF based. I did not read the entire description. My bad. :slight_smile:
But it is a resistive sensor.

That doesnā€™t look like the case in your photo above.

1 Like

Where have you defined the sleep/wake intervals?

It will not last long on a battery. Especially sending readings every 1 second. Soil moisture does not warrant that fast update interval. It changes much more slowly.

Hello all,

and thank you very much for your many answers!

:slight_smile:

Based on your many feedbacks I would suggest I divide the problem into four areas:

1) Which radio technology?
2) Test setup
3) If ESP-WiFi, then how configured?
4) Other :wink:

1) Which radio technology?
It MUST be WiFi because - and this is not an exaggeration - there are 24 WiFi networks in the neighborhood beaming on ALL channels. In addition, every other radio signal (a mess of proprietary frequencies, Zigbee, BT, etc.) unfortunately also transmits in the same 2.4 GHz frequency range.

By the way: I discussed this before here too ā€¦:wink:

Now nearly everything other than WiFi transmits (just because it is more energy efficient!) with far less energy. So with the interference, I had to fight YEARS with failures. So about 1.5 years ago I switched completely to ESPHOME via WiFi and there are now about 78 ESPHome devices (mainly ESP32 athom lamps, coffee machine, door locks and so on) all of which have OBVIOUSLY NO reception problems. Even if this setup be battery powered: I think 3000mAh and an appropriate setup as you suggest (ESP32 deepsleep & only transmit 3-4 times per day) would work.

So this is certainly just more energy consuming but also a strong enough signal and just a few times a day. Especially when you consider that I have installed and optimized 8 APs (connected via Ethernet/ no MESH) throughout the house and garden so that I hardly have to ā€œfightā€ the neighboring WiFis anymore.

Now that being said: letā€™s get to the test setup. Because regardless of the reception strength at the final deployment site, the test conditions are optimal becauseā€¦

2) Test setup
In the test setup, the device is DIRECTLY next to one AP and, when plugged in via the 5V cable, ALWAYS has a connection immediately. Only with battery just none. So I doubt that signal strength is the problem.

3) If ESP-WiFi, then how configured?
So now in the context of ESPHome configuration: Possibly there are WiFi-specific configurations in ESPHome that would have to be optimized in battery mode to simplify, for example, the WiFi-handshake. So like the suggestion with the fixed IP. I will try that. Are there any other ideas?

4) Other :wink:
@all
Would a 5V battery voltage maybe solve the problem? Maybe with an additional 5V-step-up-converter and then connected to ESP32s VIN? So maybe more power to WiFi could help connecting?

@finity
Of course it is: the box can be completely modified. Look here!

@brooksben11
Sometimes (about 2 times a year) the neighboring WiFis randomly change all at the same time at night completely automated the WiFi channels on the unsuccessful desperate search for free channels that do not exist. :wink: With 78 WiFi ESPs in my house, fallback APs then pop up by the dozen and make the situation worse. So I make them wait a long time until they actually form their own APs.

Transmitting for 10 seconds every 15 minutes (96 times per day) should allow this sized battery to last about a month assuming an average of 260mA Tx current and neglecting sleep current.

Cool: so with about 4 times a day this will keep up to 2 years. Have you made experiences for deep sleep settings and timer-based or maybe value based wake up?

And what do you think about my WiFi connection issues?

Btw: the actual sending frequency (one value per second) is supposed only for testing ā€¦

Why not just share the actual stl file that you used so others donā€™t need to learn open scad to modify the base box? :man_shrugging:

1 Like

Donā€™t count on it.
I have a similar setup, but I have made a pure ESP-Now code (No WiFi fallback) to save more energy and with 2 post per day my sensor last about 3 months with such a battery.
There is an energy loss in deep sleep and there is the energy used to boot up, before the actual connection to the WiFi occur and the reading is done and transmitted.

1 Like

Hey @finity ,

Donā€™t worry - Sure I will! :slight_smile: When the project is finished and works.

But for now it isnā€™t ready as there are obviously still problems that need to be solved and that maybe involve more hardware (like the purposed step-up-converter). This again involves changing the boxā€™s dimensions over againā€¦ you see?

Hey @WallyR : would you mind to tell what do you mean by similar? Also ESP32 capacity based soil moisture sensor? Also with an 3000mAh battery?

And did you also use a step-up converter to 5V?

Not that I am expert enough to maybe solve the energy life problem, but sometimes a blind man may perchance hit the markā€¦
:wink:

I use Soil Moisture Sensors from April Brothers.

I see, thank you: so you use the provided 600 mAh LiIon Akku?

Btw: I never saw such open source based sensor - damn!! :face_with_symbols_over_mouth: If I knew I would never have never needed to build one myself!! :slight_smile: But funny, that it has nearly the same over-all design as mineā€¦ :wink: