A soil moisture sensor simulator that waters the plant
Mokxi is a free online soil moisture sensor simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno reads a capacitive soil moisture probe on A0, and when the soil is drier than 35 percent it runs a mini pump through a relay for three seconds, then waits for the water to soak in. Drag the probe’s moisture slider and watch it decide.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
What you can do here
In the circuit above, or in the editor it opens.
- Drag the soil moisture and watch the reading on A0
- Calibrate the probe’s dry and wet ends in the sketch
- Watch the relay click and the pump run for three seconds
- Change the threshold, the pump time or the soak time
- Add a water level sensor so the pump never runs dry
- Print the moisture on an LCD or send it over WiFi from an ESP32
What the running circuit shows
Lower voltage means wetter soil.
A capacitive probe reads lower when the soil is wetter. This one gives about 2.55 V held in the air and 1.27 V in water, about 522 and 260 on the Uno’s ADC, and the sketch maps that range onto 0 to 100 percent with the ends swapped. The slider starts at 30 percent, about 2.17 V on A0, so the serial monitor prints “soil 30%” and then “dry: watering 1”.
Pin 7 pulls the relay in, the relay connects the pump to its own 6 V supply, and the pump runs at about 120 liters an hour for three seconds. Then the sketch prints “soaking” and waits ten seconds before it reads again, so it does not flood the pot chasing a probe the water has not reached yet. Still at 30 percent, it prints “dry: watering 2” about 13 seconds in.
Drag the probe past 35 percent, about 2.10 V, and the pump stays off; the sketch just prints the reading every second. Set it to 60 and the serial monitor reads “soil 59%”, because the sketch’s whole-number arithmetic rounds down.
How the probe is modeled
A straight line between dry and wet.
The probe is the common capacitive “v1.2” stake, which has its own 3.3 V regulator, so its output is the same on a 5 V and a 3.3 V board. Between the dry and wet voltages the model is a straight line in the slider’s moisture, and both ends are settings you can change to match your own probe’s calibration. The relay has a real pull-in time, and the pump is a small motor whose flow follows its voltage.
What it leaves out: real soil. A real probe’s reading against water content is a curve that differs between soils and between two probes from the same bag, so every project calibrates its own probe in dry and soaked soil. The reading here follows the slider at once, where a real board’s filter takes a second or so, and nothing drinks the water: set the moisture yourself.
Questions
Is it free?
Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.
Do I need an account?
No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.
Why does my soil sensor read lower when the soil is wet?
Because a capacitive probe’s output falls as the water around it raises its capacitance: about 2.55 V in air and 1.27 V in water for this one. Map the reading with the dry end as 0 percent and the wet end as 100.
Can I simulate an automatic plant watering system?
Yes, the circuit above is one: a probe, a relay and a pump on an Uno, with a soak time between bursts. The parts bin also has a water level sensor, a rain sensor and an LCD to build a bigger one.
Does it work with an ESP32?
Yes. The probe runs from 3.3 V or 5 V and gives the same voltages on either, so wire AOUT to an ESP32 analog pin and scale for its 12-bit ADC.
More simulators
Each one opens on a circuit that is already running.
Water a plant
Open the circuit, drag the soil dry and watch the pump run. Nothing to install, and no account needed.