It's a simple analog sensor, for compatibility with Raspberry Pi (see, no analog inputs) you will need an extra ADC converter. The Arduino analog input voltage is 1V max, and the output voltage of the capacitive sensor is about 3V (if powered by 3.3V), which means you have to use a voltage divider at the output of the sensor.
Principle
There is a classic 555 timer in the sensor. The sensor provides an analog signal. How does it use the timer, and why does it need the timer?
pins 2 and 6 are tied for several modes of operation. That schematic is an astable, it’s charging up the 1uF across the soil sensor each time it triggers. The conductivity of the soil will discharge the cap between triggers, so the lower the minimum cap voltage the more conductive (rough proxy for “moist”, considering soils have salts in them and are conductive).
Before you buy
- One SOT-23 component marked as 662K is 3.3V 200mA Positive Fixed LDO Voltage Regulator (XC6206P332MR) which gives the board an operating voltage range of 3.3-5.5V
- And 555 timer. Be careful with greedy sellers that might put the wrong version of the timer that can only work with 5V. So verify this info with the datasheet. I have NE555 from Texas Instruments which only works from the voltage in the range between 4V and 16V. Instead it should be TLC555C or TLC555I or an outlier NE555 with a second line 20M
Calibration
Calibrate or not calibrate? Don't do it but normalize (as science people say).
Probes are normalised by matching the raw readings from each sensor at both 0% (held in air) and 100% water levels (submerged in water). Without normalising, these devices would only provide a range of irrelevant raw data that varies slightly with each sensor. By matching the raw reading from each sensor to both 0% and 100% water levels, a comparison of readings taken by different sensors can be made on a common scale. Equipment suppliers should provide you with procedures for normalising their product.
Sketch
- Open the serial port
- Record the sensor value when the probe is exposed to the air. This is the minimum value of dry soil "Moist: 0%"
- Take a cup of water and insert the probe into it (the probe, not the whole board)
- Record the sensor value when the probe is exposed to the water. This is the maximum value of moist soil "Moist: 100%"
void setup() {
Serial.begin(9600);
}
void loop() {
int val = analogRead(0); //connect sensor to Analog 0
Serial.print(val);
delay(100);
}
Schematics
Schematics from Biomaker's website.
Note: I think on this scheme there is a mistake in how wire goes from pin 4 and connects to pin 7 through a resistor. It's missing a dot where pin 4 should be connected to Vcc and pin 8
Reference
- How it works and more about 555 timers and later you will need this online calculator
- About parallel RC circuit just before output
- Constant reading of 1023
- Schematics
- DFRobot wiki
- Adafruit alternative
- Check R1 resistor if readings are slow
- Many sensors are defective
- My model from AliExpress