Touch GPIO of ESP32 as soil moisture sensor

Zeni241
Posts: 86
Joined: Tue Nov 20, 2018 4:28 am

Touch GPIO of ESP32 as soil moisture sensor

Postby Zeni241 » Tue Jan 07, 2020 6:22 am

I am contemplating the idea of using one of touch GPIO of ESP32 as soil moisture sensor. I connected one touch GPIO with a wire and dipped the wire in water gradually. Surely the reading changes as more and more wire is dipped. Also no need to connect anything to ground, just single wire to touch pin.
But most of the capacitive soil moisture sensors I have seen use analog output to be fed to one of ADCs (and not to touch GPIO).
Thus before incorporating it in my project I would very much appreciate any opinion or experience about its Pros and Cons.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby ESP_Angus » Tue Jan 07, 2020 7:07 am

I have also experimented with this and it worked well for me, too.

Normally you would have two parallel traces or wires (with a constant gap in between), one connected to ground and one to the captouch channel. If you just have one wire, it will pick up noise - having a nearby ground reference will largely cancel this out.

The ESP IoT Solution has an app note how to design capacitive touch trace & reference layouts (for touch applications, but it's the same general concept):
https://github.com/espressif/esp-iot-so ... sign_en.md

Probably the main consideration is capacitance range, and input protection for the MCU. Capacitance range you can tweak with the probe design (see above link), but something that works in a vessel of water sounds like a good start. For input protect, easiest way to do this is to electrically insulate the probe "wires" (using insulated wire for the probes and making sure the end is covered would probably be enough).

That may not be enough protection for a consumer product, but I think it would be as robust as buying one of the cheap DIY capacitive PCB touch soil sensors. Those are doing something very similar to the ESP32 touch feature, only the capacitance detection circuitry is on the sensor PCB and the output is an analog voltage sent to the MCU ADC pin. The cheap sensors they don't have any protection circuitry either, so from that perspective they're not any better (and kind of worse because some of the circuit is sitting out in the "great outdoors").

Zeni241
Posts: 86
Joined: Tue Nov 20, 2018 4:28 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby Zeni241 » Tue Jan 07, 2020 8:10 am

Thanks a lot ESP_Angus, your reply gave me much needed confidence for this path. I will experiment more and post my observations here. BTW what you mean by captouch channel.

ESP_Sprite
Posts: 8996
Joined: Thu Nov 26, 2015 4:08 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby ESP_Sprite » Tue Jan 07, 2020 8:37 am

Also, note that if you want to do moisture detection, you may be better off with some solution or hack that senses using an AC current; if you do not, your electrodes probably will erode away doubleplusquick in a hurry. On the ESP32, you may be able to get away with using two touch-capable electrodes and alternatingly grounding one and sensing on the other GPIO.

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby boarchuz » Tue Jan 07, 2020 9:40 am

Zeni241 wrote:
Tue Jan 07, 2020 8:10 am
captouch channel.
Touch pin, touch pad. Don't overthink it.
ESP_Sprite wrote:
Tue Jan 07, 2020 8:37 am
your electrodes probably will erode away
Isn't that only a concern for resistive moisture sensors? A benefit of capacitive is that he can insulate the entire probe.

ESP_Sprite
Posts: 8996
Joined: Thu Nov 26, 2015 4:08 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby ESP_Sprite » Tue Jan 07, 2020 10:19 am

boarchuz wrote:
Tue Jan 07, 2020 9:40 am
Isn't that only a concern for resistive moisture sensors? A benefit of capacitive is that he can insulate the entire probe.
Ah, good point, that indeed would solve that issue, seems my mind didn't quite get the fact that this is capacitive sensing.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Touch GPIO of ESP32 as soil moisture sensor

Postby ESP_Angus » Tue Jan 07, 2020 10:58 pm

boarchuz wrote:
Tue Jan 07, 2020 9:40 am
Zeni241 wrote:
Tue Jan 07, 2020 8:10 am
captouch channel.
Touch pin, touch pad. Don't overthink it.
Yes, sorry. Many words for the same thing!

Who is online

Users browsing this forum: No registered users and 42 guests