Hello, me and my teammates are making a robot about soil moisture sensor. It's already done and just doing any test but earlier we faced a problem and since I'm the programmer, I'm the only one who knows the coding aspect.
The robot can be driven via a Bluetooth module and it works, and the sensor works and can fairly read and detect soil moisture.
But, 5 hours earlier, I decided to take it for a small stroll drive so that it works in the day of the presentation. After that, I decided to plug the sensor and it sensed a continuous number of 33 percent and that it's too dry despite being in a wet area.
I've discerned something and maybe I've drained the battery power source and that's why it did not sense anymore. So our last resort was just to charge the battery.
But I'm a new programmer here and I'm anxious if that's our only case and problem here. But I'm trusting on that discernment because we have two more extra sensors that read the same stagnant 33 percent.
const int moisturePin = A1; // Connect the moisture sensor AO to A1
int moistureValue = 0; // Variable to store sensor reading
void setup() {
Serial.begin(9600); // Start serial communication for monitoring
}
void loop() {
moistureValue = analogRead(moisturePin); // Read the analog value from the moisture sensor
// Print raw moisture value
Serial.print("Moisture Level: ");
Serial.println(moistureValue);
// Determine moisture status
if (moistureValue < 400) {
Serial.println("Status: TOO DRY! Water the soil.");
} else if (moistureValue >= 400 && moistureValue <= 700) {
Serial.println("Status: Soil moisture is OPTIMAL.");
} else {
Serial.println("Status: TOO WET! Avoid overwatering.");
}
Also, this doesn't make sense to me. You should have three pins in the Arduino: the +V, Ground and a signal pin into A1 because that's how you defined it.
Is "A0 to A1" just a typo? Or did you actually connect it that way?