Hi, I made a PCB project using the esp32 as my microcontroller and have simple inputs that I want to read voltages with.
I use a voltage divider 100k and 47k to reduce the voltage.
My problem is that when I try to read the voltage on gpio 4 for example, when no voltage is applied - analogRead(4) gives me a value of around 1230
I have measured with my multimeter and there is no voltage on said pin, yet, the esp still reads that value
Any ideas on what's going on?
Do you have anything connecting to the pin when the measuremets are performed? is your pin pulled to GND or VCC during measurements?
Meausure voltage from the pin not being connected to anything will result unpredicted values because of EMG noise.
Yeah so my voltage divider is is connected to ground. So my pin should be pulled to ground
Certainly NOT pulled to ground by the resistor values you showed! Put a small value capacitor across the pin connection and to ground. Increase capacitor values until the stray signals are minimized. You are creating a great antenna for picking up stray signals in your location.
Please post a schematic.
Probably not. Carefully check the connections for correctness and continuity (use your multimeter).
My multimeter shows 0.0068V when I manually probe the pin on my most sensitive setting on my multimeter, however the esp reads a value above 1200
I've never used an ESP32....
If it's noise it will jump-around and I'd expect some zero readings when the noise goes negative. If it's reading constantly around 1230 (and possibly jumping a little) something is wrong...
The meter will filter-out/smooth-out most of the noise whereas the ADC is just "sampling" every time it reads.
Then it seems likely that either the ESP ADC is not connected to that pin, or that pin has been damaged.
So I tried applying 3.3v to that pin and it still reads 1200, now the weird thing....
I read pin 4, 12, 13, 14 and 15 and they all give the same reading.
These pins are connected to ADC_2 of the esp32, I read somewhere that ADC _2 can't be used whilst WiFi is active, is there a pice of code I should be adding to my script to disable the WiFi?
Yes, there is a function to disable wifi. Consult the wifi documentation at the Espressif support site. Did you enable wifi? Do you need it? It's not on by default.
I read pin 4, 12, 13, 14 and 15 and they all give the same reading.
The same as what? Consistent with 3.3V (max reading), or same as the pin that gives you a problem?
Sounds like nothing much is working.
Start over, running the simplest possible (tutorial) example, and verify that you can obtain and print a single ADC reading, from any pin.
-
ESP32 has 2 ADCs, named ADC1 and ADC2
-
ESP32 ADCs functions
- ADC1 controls ADC function for pins GPIO32-GPIO39
- ADC2 controls ADC function for pins GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27
3… ESP32 WiFi uses ADC2 for WiFi functions
- in order to use ADC2 for other functions, we have to acquire complicated firmware locks and very difficult to do
- It’s not advisable to use ADC2 with WiFi
Are you test measuring the voltage at the pin, or at the input to the protection network, for example IN7, or AIN9 ? There would be a 0.7V drop in the series diode.
I am measuring at the pin on the esp32.
I have now changed my voltage divider to 10k and 1k and it has helped, however there is still a reading of around 350 on a pin that has 0V on it according to my multimeter
i have a problem also with my esp32 dev kit V1, its giving gibris when measure amplitude and frequency on pin 32(adc).
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.