I am novice in arduino code and I wish try to measure a soil humidity with a capacitive soil moisture sensor 1.2. My program :
int soilMoistureValue = 0;
void setup() {
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
pinMode (22, INPUT);
}
void loop() {
soilMoistureValue = analogRead(22); //put Sensor insert into soil
Serial.print("value =");
Serial.println(soilMoistureValue);
delay(1000);
}
But with this program the sensor value is sensibly same between wet or dry, it measure 800 to 810.
I need a special library for this ? or i forget thing in my program ?
The moisture sensors I've seen are resistive and with another (regular-fixed) resistor you have
a voltage divider. But I believe those are subject to corrosion...
okay i think is better with 3 !
But with the sensor in air i have 0 and in the water only 25.
This sensor should measure an value between 200 and 800 no ?
No, analogRead will return 0 to 1023 for a voltage between 0V and Vref (whatever that is for your board).
If Vref is 5V, then a 3V sensor can never read more than around 615.