Capacitive soil don't work

Hi everyone,

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 ?

Thanks for you help !

Which Arduino are you using?
(There's no good reason the soilMoisture variable should have global scope)

which Arduino ?
show a picture of your setup

And what sensor? Do you have a link?

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...

I use an arduino nano and it's a capacitive sensor


You've got the wrong pin number in your analogRead.
A3 is not pin 22

I see on net and i try with 22, 9 and 3 but the problem is same

3 should have worked as well as A3.
I don't know why you would have tried 9.

(Does anyone know if analogRead wraps pin numbers? I'm on my phone)

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 ?

Why are you asking me?
I don't have your sensor, whatever it is. (That was hint)

Because it's an capacitive sensor and it send a tension between 0 to 3V. And a conversion on analog you need value between 0 to 1024 i think

may be a bad calibration ?

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.

NIIIIICEEEE !!
With an 3v3 power is perfectly work !
Thanks for you help !
But the value range only 100 to 400

I don't know the specification for you sensor (hint), so don't know if that's a Good Thing or a Bad Thing.

operating voltage: DC 3.3-5.5V

output voltage : DC 0-3.0V

you can see more details with this link : https://fr.aliexpress.com/item/1005002224917883.html?spm=a2g0o.order_detail.order_detail_item.8.5da67d56zyD7vG&gatewayAdapt=glo2fra

That page is garbage - it says the sensor has a Hall sensor (that's magnetic, not capacitive) and that it's a temperature sensor..

with this link is may be better : https://www.amazon.fr/Capacitive-Moisture-Corrosion-Resistant-Raspberry/dp/B07FLR13FS

It seems you've got around 2/3rds FSD (400 out of 615).
Seems quite good to me, but I don't know how you're testing it.

Yes I think it does you can use 3 or A3 with analogRead

Edit

Here

@J-M-L (aka Jackson :wink: ) thanks.