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 lotGuillermo Bastian– Guillermo Bastian2020年12月24日 19:04:23 +00:00Commented Dec 24, 2020 at 19:04
1 Answer 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:
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.
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.
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– Howlan2019年12月12日 13:32:34 +00:00Commented Dec 12, 2019 at 13:32
Explore related questions
See similar questions with these tags.