I am trying a tiny arduino project to help me see when my irrigation starts from my community. I have read alot of tutorials and projects but I am not using a grove water sensor. I don't have one so I thought two pieces of wire or two screw heads in a plastic cup would work.
I wired pin 2 on the arduino to one screw and Gnd to the other screw. If I put water in the cup, I would think it will complete the circuit and the Pin will go low on the arduino. No joy.
One tutorial said I need to keep the pins from "flapping" so I added a 300ohm resister in line from pin 2 and the screw. No joy.
I tried the LED indicator without luck so now I am just trying to put something on the monitor screen.
The resistance of fresh (non-salty) water is kind of high. It's likely too high for your makeshift sensor contacts to sufficiently pull down the 'sensor' pin to ground. The grove sensor is also a kind of rudimentary contraption that will probably work OK-ish, but will never be optimal. I'd rethink the sensor system if I were you.
Hello
You don´t need an external resistor.
I have made some mods to your sketch.
The key is to set the input pin to INPUT_PULLUP and revers the logic.
Try it and give a feedback.
/* Test sprinkler */
int switch_pin = 2;
void setup() {
Serial.begin(115200);
// new INPUT_PULLUP
pinMode(switch_pin, INPUT_PULLUP);
// pinMode(led_pin, OUTPUT);
Serial.println(" Start ");
}
void loop() {
//new !digitalRead(switch_pin)
if (!digitalRead(switch_pin) == HIGH) {
Serial.println(" switch HIGH ");
// no water
}
//new !digitalRead(switch_pin)
if (!digitalRead(switch_pin) == LOW) {
Serial.println(" switch .....LOW ");
// sprinker water
}
delay (30000);
}
Keep in mind the corrosion of the electrodes.
The sketch is untested, but well done.
on the bench, set up a bunch of cups.
rain water in one
desert dry soil in one.
and then get the other samples different levels of damp, moist, wet, saturated.....
you can test with wires dipped in each.
move the wires closer together or farther apart
my crude testing in water was a about 8k ohms with the wire about that (holds fingers up to show distance) far apart. your testing will answer a lot of your questions.
in the end, the problem with metal in contact with soil is electrolysis.
the electrical flow will remove metal from one electrode and deposit it on the other.
in an attempt to reduce that, some of the sensors swap flows.
not worth the effort when a capacitive sensor is just a few dollars.