1
\$\begingroup\$

I am using an ESP8266 12 F Module with 3 x 1,2 V Batteries (3,6 Volt) I connected a chinese soil moisture sensor like this (LINK) to the anaolog pin of the ESP8266 Module. The Module works from 3,3 Volt on to 5 V.

Problem: The Sensor gives back 1024 every time no matter what the actual moisture conditions are. Dry Conditions = 1024, Fully under Water = 1024

I tried the same with an NodeMCU Module which uses the same ESP8266 Chip and there where no problems with the analog reading.

Question 1: I found out that the ESP8266 12 F has an analoge pin capable of reading only values from 0-1 Volt so this could explain the high reading on every measurement when supplied with 3,6 Volt and under wet conditions.I still don't understand why the sensor returns 1024 even if there are absolutely dry conditions. Shouldn't there be a 0 reading?

Question 2: I know that I need some kind of voltage divider e.g. two resistors and would appreciate some hint which ones I should use. The NodeMCU Module seems to have a voltage divider on board and that's why everything worked with this module.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ What is the range of your input voltage, from dry to wet? Have you measured it with a meter to see if the voltage is within the 0 - 1V range of the ADC? \$\endgroup\$ Mar 20, 2018 at 12:54

2 Answers 2

1
\$\begingroup\$

I recently ran into the analog read problem on an ESP12 and found that the problem is referenced here:

https://github.com/esp8266/Arduino/commit/09bb75874deb95c22b4c09e63b842fc1f89eebc3

To resolve the problem I modified core_esp8266_wiring_analog.c as shown here:

extern int __analogRead(uint8_t pin)
{
    // accept both A0 constant and ADC channel number
    if(pin == 17 || pin == 0) {
        return readvdd33() >> 2; // readvdd33 is 12 bit
    }
    return digitalRead(pin) * 1023;
}
\$\endgroup\$
1
  • \$\begingroup\$ This did not work for me. I changed the file according to your post and reflashed the ESP module. I am still getting 1024 for every reading... \$\endgroup\$
    – Peter S
    Jul 16, 2017 at 11:31
1
\$\begingroup\$

I know this is a old post but to benefit anyone that search for the answer that came across this post.

The solution is a voltage divider, 220k and 100k resistors will do the job.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.