// Replace 4 with the digital GPIO pin you will use #define SOIL_MOISTURE_SENSOR_PIN D3 // If you want to control the power of the sensor #define SOIL_MOISTURE_SENSOR_POWER 23 void setup() { pinMode(SOIL_MOISTURE_SENSOR_PIN, INPUT); // Set the sensor pin as input pinMode(SOIL_MOISTURE_SENSOR_POWER, OUTPUT); // Control the power of the sensor digitalWrite(SOIL_MOISTURE_SENSOR_POWER, HIGH); // Turn on the sensor Serial.begin(115200); } void loop() { int sensorValue = digitalRead(SOIL_MOISTURE_SENSOR_PIN); // Read the sensor value if (sensorValue == HIGH) { Serial.println("Dry soil"); } else { Serial.println("Moist soil"); } delay(1000); // Wait one second between readings }