Soil Moisture Sensor Soil Hygrometer Detection Module It is a simple water sensor, it can be used to detect soil moisture. Module Output is high level when the soil moisture deficit, or output is low. It can be used in module plant water device.
Interface Description (4-wire)
VCC: 3.3v-5v GND: GND DO: Digital output interface (0 and 1) AO: Analog output interface
Instructions for use- Soil moisture module is most sensitive to the ambient humidity is generally used to detect the moisture content of the soil.
- Module to reach the threshold value is set in the soil moisture, DO port output high, when the soil humidity exceeds a set threshold value, the module D0 output low;
- The digital output D0 can be connected directly with the microcontroller to detect high and low by the microcontroller to detect soil moisture;
- The digital outputs DO shop relay module can directly drive the buzzer module, which can form a soil moisture alarm equipment;
- Analog output AO and AD module connected through the AD converter, you can get more precise values of soil moisture;
Arduino Code:
// Soil Moisture Sensor Hygrometer example code // Code author: aafent. This code is copy free, if you want please mention the author's name and/or the site //Interface Description (4-wire) //VCC: 3.3v-5v //GND: GND //DO: Digital output interface (0 and 1) threshold taken from potentiometer //AO: Analog output interface
const int moistureAO = 1; const int moistureDO = 31;
int AO = 0; int DO = 0; int tmp = 0;
void setup (){ Serial.begin(9600); Serial.println("Soil moisture sensor"); pinMode(moistureAO, INPUT); pinMode(moistureDO, INPUT); }
void loop () { tmp=analogRead( moistureAO ); if ( tmp != AO ) { AO=tmp; Serial.print("A="); Serial.println(AO); } tmp=digitalRead( moistureDO ); if ( tmp != DO ) { DO=tmp; Serial.print("D="); Serial.println(DO); } delay (1000);
}
|