Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Measuring soil moisture to know when your plant needs water.
Connect the module's analog pin (A0) to A0 on Arduino. VCC to 5V.
void setup() {
Serial.begin(9600);
}
void loop() {
int moisture = analogRead(A0);
Serial.println(moisture);
// في بعض الحساسات، التربة الجافة تقرأ قيمة عالية (1023)
if(moisture > 800) {
Serial.println("التربة جافة جداً!");
}
delay(2000);
}Leaving the sensor powered continuously in wet soil, which causes the electrodes to corrode within days. Solution: power it through a digital pin only when taking a reading (for one second every hour).