-->
Page 1 of 6

Reading a soil moisture sensor using a ESP-12-F

PostPosted: Tue Jan 26, 2016 1:41 pm
by ErikLem
After some trouble, I recently got my ESP-12 up and running. I've been able to upload sketches, run a web server and blink some leds, all worked like a charm. The next thing I want to do is hook up a soil soil moisture sensor, like this one:
Image

I hooked it up to 3.3v, gnd and connected the analog output to a0. Unfortunately I only get 1024 out of it, weather it's dry or completely submerged in water. When I use it on a arduino, I get the whole range of values from 0 to 1024

The sketch I'm using can't be simpler:

Code: Select allvoid setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT);
}

void loop() {
  Serial.println(analogRead(A0));
  delay(100); 
}


Any idea where Im'n going wrong? The only thing I can think of is that the arduino powers the sensor with 5.5v, while with the ESP I'm powering it with 3.3v

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Tue Jan 26, 2016 1:54 pm
by krzychb
Hi ErikLem,
What is the voltage output range of your moisture sensor?
Does it match the A0 input range that is 0 - 1V?
Krzysztof

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Tue Jan 26, 2016 4:51 pm
by ErikLem
ah, I did not know the ADC needed between 0 and 1 volts, that explains my readings.

I just measured what this sensor is giving me, it seems to give between 1.8v (fully submerged) and 3.3v (in air)
Is there any way I could convert those voltages and get a reliable output? Or could I better have a look at something like https://www.tindie.com/products/miceuz/ ... re-sensor/

Edit: Would a voltage divider like described here work? http://www.instructables.com/id/ESP8266 ... e-divider/

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Tue Jan 26, 2016 5:10 pm
by martinayotte
Yes, simple voltage divider should do the trick.