1

I have a 'Capacitive Soil Moisture Sensor' hooked up to my Uno. Very simple code. AnalogRead(MoistureSensorPin); This will return a differing value that I can work with.

When applying the same code to an ESP32 with a similar set-up. It always returns '4095' which I understand is the maximum value an analog input can return. But I cannot understand why it does this.

Any help will be much appreciated.

  • Thanks friend, this response also helped me a lot – Guillermo Bastian Dec 24 '20 at 19:04
1

The ESP is a 3.3v device. If your Uno is a 5v device, its A/D converter can measure and report voltages from 0 to 4.9878v (5v minus 1 LSB). If the same signal is presented to the ESP, any value above 3.29919 volts (3.3v - 1 LSB) will read as 4095, i.e., out of range.

(If this isn't your issue, adding wiring diagrams of each system to your question will help us understand it better.)

Update:

Perhaps a different ESP unit would be the ideal solution?

As far as I know, all of the ESP's are 3.3v devices. So the solutions I see are:

  1. Power your sensor with 3.3v (is this an option?) so its output will be within the input range of the ESP's built-in A/D.

  2. Scale the sensor output from it's 0-5v range to the 0-3.3v range the ESP can accept. Whether you can use a simple divider network or would need an op-amp may depend on the sensor, but if, as I suspect, it is a simple resistance device, a voltage divider should work.

  3. Use an external 5v A/D converter. This will require a 5v power supply (which I presume you are using already, to power the sensor) and voltage level conversion between the A/D and input pin(s) of the ESP. The conversion could be a purchased level-converter board or a simple resistor-divider network.

  • Thank you for the response! I believe this is the issue I am facing, so it's an A/D converter issue on the ESP device... Perhaps a different ESP unit would be the ideal solution? (ESP82?) Or, do you know of a different solution for me to be able to get a different result from my ESP32? Much appreciated. – Howlan Dec 12 '19 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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