Rain and Snow Sensor

This might be the silliest sensor available given that the only valuable part here is the PCB with the winding traces and that all the controller does is to pass a weak current (for the sake of efficiency) through the two poles of the PCB and hopefully make contact between the two intertwined traces if there is some water or snow on top of the traces to make contact.

In principle, you could create a such a sensor or even better just using copper wires and literally just passing current through and draining the current into a GPIO pin ($3.3V$ or $5V$ depending on the voltage tolerance of the controller); then, iff. the GPIO pin measures any non-zero value, then the circuit is connected and there must be some rain or snow between the wires, or otherwise, if the GPIO does not measure any value there is no rain or snow.

Like many other cases, this is one sensor that does have an analog output but the actual analog value being read does not really have any special meaning. In fact, the higher the value, "the lesser the contact", but that does not necessary imply that there is "more rain" or "more snow" - it could just as well be a large pigeon dropping on top of the circuit that makes great contact. On the other hand, it is a good "learning sensor" and one that can be reproduced easily, as mentioned before, without even having to buy anything special.

Corrosion

This sensor is perhaps concomitantly both the cheapest and the crappiest solution for soil moisture measurements. First, the sensor is not scientifically calibrated so the value measured is just a short-resistance between two electrodes using an analog pin of a controller. Second, well, traces on a PCB are never a good choice to be stuck inside water or even a corrosive medium such as soil or enriched soil because the traces corrode extremely fast.

Initially when looking around for how this sensor is supposed to be used, we stumbled onto a project that claimed that the sensor was hooked up with a feedback circuit that decoupled the current from the sensor in the hopes of reducing the potential differential between the two electrodes of the probe because by running the sensor hot all the time, the slow process of electrolysis would end up destroying the sensor.

However, even before electrolytic decay of the electrodes takes place, the actual tin within the PCB pathways just ends up corroding just from the moisture alone and even wiping off. As an example, here is the probe of a soil moisture sensor that was used for the hydroponics project:

And, as can be observed, the electrodes are corroded on both sides with one of them even having been digested completely. Given the green corrosion, the traces seem to have been made out of copper, which is funny, for such a simple and cheap sensor. Aluminum is more resistant to corrosion so instead of the more expensive copper, the probe could have been made out of aluminum. To add to the irony, the sensor was not even used because we were waiting for other components and focusing on other projects, such that what you can see is just he result of sticking the probe into the soil and leaving it there for about a month.

Damage Repair

Given that we mentioned that the sensor is more or less a sophisticated resistor, or variable resistor with two wires going into the ground and with no scientific calibration, repairing the damage is fairly easy and we chose to just pass some thick aluminum wire across the length of where the PCB traces used to be.

In order to do so, some of the trace was exposed right next to the connector and then a hole was drilled through the PCB. After that an aluminum wire was stitched around the sensor and then soldered onto itself and the top part of the PCB.

There is no real loss of performance here and at worst the repair will require a new calibration to be able to tell what value corresponds to the state "the soil is moist" and the value that should be considered the "dry soil" value.

Of course, the lesson learned here is that it is just a matter of time till the sensor corrodes completely and that over time there will be a resistance drift as the rods or PCB traces get partially corroded. With that being said, one should always make sure to have backup systems that do not depend on the values reported by this sensor and disengage any watering that could lead to a flood or other potentially hazardous operation.

Otherwise, it is actually an extremely cheap and effective solution to determine the presence of moisture, in general.

Code

Pretty trivial, so, something like this should work:

integer v = analogRead(D0);

where:

  • D0 is the pin name (or number) connected to the analog output of the sensor,
  • v is the value currently reported by the sensor

On an ESP32 with $5V$ tolerant pins, the possible reported range is between 0 (full contact) and 4095 (no contact at all).


iot/sensors_rundown/rain_and_snow_sensor.txt ยท Last modified: 2025/05/02 05:34 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.