Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By erbedo
#53349 Hi all, I am building an hygrometer with an ESP8266-12, connected to a soil moisture sensor like this one: http://www.banggood.com/Soil-Hygrometer-Humidity-Detection-Module-Moisture-Sensor-For-Arduino-p-79227.html

The sensor outputs 3.3V when totally dry, and 0V when totally humid.

I have connected it to the ADC pin of the ESP-12, clearly using a voltage divider to bring the voltage between 0V and 1V. So I tried to use a 2R+1R scheme, with 20K and 10K, 330K and 660K, and 2K and 1K. However, what I see is that the difference between the totally dry and totally humid ranges for the different resistor schemes between 0.13V and 0.28V, which thus is not very accurate. I do not mind to get super accurate measurements, but something in the range 0.10V-0.90V would be better.

Testing the sensor without voltage divider with a multimeter reports a value between 1.48V-VCC(3.15V). I guess that the best I can do would be to get a value between 1.48/3.15 and 3.15/3.15, so 0.46 and 1V, but of course I can also accept less difference between the two measurements. In fact, what I really care about is not when the soil is humid, but have accurate measurements with the soil dry, therefore for high voltages.

Any idea why this is not working? I have checked the connections multiple times, and they are ok. I am wondering whether to use different resistor values, but cannot figure out what they could be.
User avatar
By trackerj
#53352 If you look around using the search function you will find a lot of discutions on the forum about the subject.

Also this 2 posts can help you with:
- ESP8266 Internal ADC and voltage divider explained
- ESP8266 - Internal ADC Part 2 - the easy way example

The latest is just a very quick example on how to add a Voltage Divider for a 0-5V input range to the ESP8266 Internal ADC input.
User avatar
By Barnabybear
#53368 Hi, whilst a little rough and ready the following my get the readings to some useable for you.
Testing the sensor without voltage divider with a multimeter reports a value between 1.48V-VCC(3.15V).

If you put 2 normal silicon diodes in series with the output, each will drop about 0.7V giving a total loss of about 1.4V. If you subtract 1.4V from the readings you are getting you end up with:
1.48V - 1.4V = 0.08V & 3.15V - 1.4V = 1.65V. This takes the lower reading to nearly Zero & the upper to 1.65V, which could be scaled to 1.0V using a voltage devider with the ratios 1 : 0.65 or 1K : 660R (500R : 330R).

Sensor output -> diode -> diode -> 660R -> ADC -> 1K -> Ground.

I haven't tried this but on paper it looks good. As allways only testing will tell.

Worth noting: If you use resistors that are to high a value, the current flowing through diodes may not be enough to ensure they drop their 0.7V and things will not work as expected. Give it a go (it has one of two chances) and if you don't get the expeted results post the types and values you used.