Moisture sensor, using PWM-signal and A0

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Ton_vN
Normal user
Posts: 212
Joined: 21 Oct 2016, 15:20
Location: Hengelo (Ov)/ NL
Contact:

Moisture sensor, using PWM-signal and A0

#1 Post by Ton_vN » 29 Dec 2020, 23:25

T&H-sensors for soil measurements with long endurance & good quality are not cheap.
The simple moisture sensors with fork or pen have no quality in data, but may be useful to generate a very rough indication and for thresholding aimed at a alert.
The downside for the very simple resistive moisture-sensors is that they use DC to sense the earth's resistance between the legs of the fork, resulting in heavy/quick corrosion of the legs. The slightly positive side is that a fork-setup survives drowning without fatal consequences.
The capacitive moisture sensors are better related to corrosion, applying an AC-signal, but drowning is fatal.

Throwing away the resistive devices is easy, but recycling of the setup would be nice,
and ;) a 'useful' passing of time during the present crisis and/or rainy days .......
2 'Usual' frontends for the WEMOS' A0-pin to interface to array (for Rain/Wetness-sensing) or to fork (for Soil-sensing).
Soil-Frontend
Soil-Frontend
humgrondprobe [320x200].jpg (13.02 KiB) Viewed 6932 times
Rain-Frontend
Rain-Frontend
regensensor [320x200].jpg (18.21 KiB) Viewed 6932 times
Triggered by the need to replace a 'fork'-sensor of a Soil-sensor lost by corrosion, came to revisit an idea suggested by a meteo-buddy.

:idea: The WEMOS/ESP8266 has an onboard AC-signal in the form of PWM.
This PWM-signal can have a max. level of 3V3 at 10mA.
Combining various infos, seems that it can be set as follows in ESPEasy
-- Basic command = PWM,<GPIO>,<state> or PWM,<GPIO>,<state>,<duration> or PWM,<GPIO>,<state>,<duration>,<frequency>
-- with <GPIO> 0...15, <state> & <duration> 0...1024, and <frequency> set between 100 and 40000 [Hz]
-- <state> = level/duty-cycle, alternating at standard 1kHz, unless <frequency> inserted
-- <duration> = causes fading expressed in ms (and 'no fading' if deleted or set to 0)
-- Example layout for command = http://<espeasyip>/control?cmd=PWM,13,500
Feeding the PWM-signal to Leg A of the Fork-sensor, if sensing on the Leg B of the fork, then the signal from Leg B must be a portion of the original signal, reduced by the resistance between the legs. For the Rain/Wetness-sensor similarly port A as input and port B as output.
Pictures from my antique oscilloscope provide evidence that the operation of the loop ESP to Sensor & back is OK, when the sensor is wet.
Signal from ESP to sensor
Signal from ESP to sensor
Output_signal_to_sensor [50%].jpg (13.93 KiB) Viewed 4664 times
Signal from wet sensor
Signal from wet sensor
Input_signal_from_sensor [50%].jpg (13.99 KiB) Viewed 4664 times
For a dry sensor the Input_signal is just noise & hum (as could be expected) collected between the wires and at the sensor.

The ADC of the Wemos/ESP8266 at pin A0 seems an available tool to measure the signal from Leg B of the fork or port B of the Rain/Wetness-sensor.

Now the question how to interface between Leg B and pin A0 at (almost) no cost:
1) apply the PCB (as shown above) normally used as frontend to A0?
[Probably not, because the PCB and A0 'behind it' will have problems to digest a PWM-signal of variable amplitude]
2) instead of the PCB some DIY-construction of diode, capacitor(s) and resistor for direct connection to A0?
[with the DIY-construction rectifying & smoothing the PWM-signal from Leg/port B into a semi-DC-signal]
3) = DIY-construction 2) as front for 1)?
[with the DIY-construction smoothing the PWM-signal for the entrance of the PCB, and the PCB amplifying/leveling that input signal]

Have fiddled with 2) and 3), but not yet a working result, suspecting that the signal from Leg B is too weak to trigger the PCB.

;) ;) Consider this just as a teaser/challenge/playground aimed at better life cycle of the setup.
Somebody with experience/ideas for best DIY-construction for the frontend?
With PWM-signal set to constant/1000Hz/symmetric
Last edited by Ton_vN on 15 Mar 2021, 15:15, edited 3 times in total.

Ton_vN
Normal user
Posts: 212
Joined: 21 Oct 2016, 15:20
Location: Hengelo (Ov)/ NL
Contact:

Re: Moisture sensor, using PWM-signal and A0

#2 Post by Ton_vN » 08 Mar 2021, 21:04

Testing results for Rain/Wetness-sensor

Pictures from experiment inserted into the previous message.
Looking at the signal coming from the Rain/Wetness-sensor, it not really has a level with proportional characteristic related to resistance:
- dry => much noise & hum, with some minimal 1000Hz squarewave 'ripple' [apparently picking up 'environmental' transmission]
- wet => almost the original 1000Hz-output [due to low resistance between the 2 legs or the 2 array-segments]
- intermediate = not really distinctive.
First conclusion: perhaps usable as 'rough-level'-indicator, but not as measuring device .......
For that application must find a very simple setup enabling ESP8266 to read the signal from the sensor.

Addidtion of some basic components yields a working setup.
PWM_Moisture_sensor
PWM_Moisture_sensor
PWM_Moistsetup [50%].jpg (11.45 KiB) Viewed 4551 times
'Simplicity' rules, while 'Sensitivity' and 'Accuracy' are terms to be forgotten.
Components empirically choosen from available supply.

Functional flow:
- GPIO13 is output of a 3V squarewavesignal to leg A of the sensor-grid/fork
- The sensor-grid/fork attenuates the signal dependent on moisture (= resistance) on the grid or between the legs of the fork
- Signal from leg B rectified and 'cleaned/smoothed' by diode + C2 + C1
- A0 reads the 'cleaned' signal.
- In ESPEasy the formula for ADC scales the data [after some testing set to %value% * 10 ]
Present result: with this simple setup the feasability has been demonstrated,
but not for a sensitive dew-detector, more for a downpour-indicator.
Rainsensor_heavyshowers
Rainsensor_heavyshowers
Rainsensor_showers.jpeg (41 KiB) Viewed 4546 times
Is also a dillemma: if increasing the sensitivity by adding linear amplification of the signal from leg B, a downpour will clip the signal at the ceiling before it arrives at A0
;-) linear amplification already luxury, logarithmic amplification seems overdone ......

;-) Because the crisis still provides plenty of time to spend on the playground, perhaps worth trying this concept also as soil-sensor.
At least one bonus: this setup does not eat the legs of the fork by electro-corrosion.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests