# What is the purpose of the diode in this peak detector?

I was reading about a capacitive soil moisture sensor circuit today, and came across the following diagram:

(Diagram taken from the Cave Pearl Project, https://thecavepearlproject.org/2020/10/27/hacking-a-capacitive-soil-moisture-sensor-for-frequency-output/)

As the peak detector section of this circuit uses the filtered output of a 555 timer, which I believe should never be a negative voltage, what is the purpose of diode T4? Is it really necessary in this circuit?

Any insight would be much appreciated!

C4 will be charged to a voltage representing the previous peak voltage. That means that C4 voltage higher than probe output. Diode will prevent this higher voltage from being drawn down to probe's voltage level.

Current would flow "backwards" toward the probe, if there was no diode. But with the diode C4 remains in the peak voltage until it's pulled lower by current through R4.

The diode will cause a voltage drop though, so you need to take that into account or replace it with an "ideal diode circuit". Or the whole peak detector with a more sophisticated design such as this:

(Image source: Analog Devices - LTC6244 High Speed Peak Detector)

• Beware of op amp circuits with no clear DC path for bias currents. In this case, if C1 charges up too high, D2 is permanently reverse biased, and your output hangs at the positive rail with no means fo discharge the cap. Jan 23 at 20:17

The 10K resistor and probes form a voltage divider. The more moisture in the soil, the more current through the probes and the lower the voltage going to the diode.
The diode will conduct when the voltage across the probes is higher than the voltage on capacitor C4 by the voltage drop of the diode (approx 0.7V for silicon). As the triangle wave voltage gets high enough to cause the diode to conduct it will charge the capacitor. When the triangle wave voltage drops below the voltage need to forward bias the diode, the diode prevents the charge from being drained off by the probes, so it stays near the peak voltage.
The 1M resistor R4 will slowly drain the capacitor so that as the soil conductivity goes down the voltage on the cap will be able to go down as well.

It is necessary to convert the strength of the 1.5 MHz AC conducted thru the moisture into DC. Dry soil will be a higher DC since the probe will not conduct as much attenuation.

Here the signal is series AC to DC converted and the probe in-between shunts the series R Vac if there is sufficient moisture.

DC probes are more problematic with galvanic corrosion, which is why AC is used. The sensitivity increases with frequency, while moisture has a dielectric constant of 80 compared to air, so the change is pretty significant and does not need much precision.