ESP32 reading adc
#132
Replies: 5 comments 3 replies
-
On 12/4/23 17:20, ocimjr wrote:
So, when I connecting a ESP32 and try to read adc of pin 35 I have a reading of between 0 to 400.
I just used a basic script to read adc, no front circuit no edrumulus code.
What did you connect then?
It's perfectly normal that reading from a floating ADC (i.e. one without anything connected) gives you random values.
Btw if you connect a piezo without the front end circuit, you'll very likely
a) read random values most of the time as well as the piezo has high impedance / is mostly identical to a disconnected circuit.
b) break the ADC and thus the microcontroller when you hit the piezo as the piezo will output +-10V, but the ADC only supports 0 to 3V3.
So you'll always need a front end circuit to fix those two points.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
On 12/4/23 18:09, ocimjr wrote:
So what you saying is if I have a script like this :
`// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
int sensorValue = analogRead(35);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}`
And have a bare esp32, nothing connects to pin. I'll have a floating reading ?
Yes.
There's nothing connected, i.e. the voltage on that pin is undefined / defined by whatever happens around it electromagnetically.
I'm not in electronics so I just exploring.
I tought this would be reading 0 all the time.
Should be this way? Or if I connect a front circuit this will be 0?
Depends on the circuit. If you connect it to GND, it will be 0V. ;)
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ocimjr
-
Hi, if you don't mind I have another question. After connect a front end circuit I have this floating reading Shouldn't this be stable? Since it's just 1 pin connect to a 3.3v rail and ground ? Thanks again |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't know what circuit you're using...
But if you connect it to GND/0V, it should go to zero. If you connect it to 3V3 it should go to the ADC maximum value (10 bit ADC = 2^10 = 1024, 12 bit = 4096). It should be _relatively_ stable there, i.e. maybe you'll see +-1% variation or so - depends on your power supply and general isolation of the circuit.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
On 12/5/23 22:05, ocimjr wrote:
I use the edrumulus frontend without pad. One jack with head and slave
With that you should get roughly half the ADC range (1,65V).
If you don't, there's either something wrong with your code (didn't look like it), your circuit or your ADC is already broken from over-voltage.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, when I connecting a ESP32 and try to read adc of pin 35 I have a reading of between 0 to 400.
I just used a basic script to read adc, no front circuit no edrumulus code.
Even with a noise filter circuit or a powered usb hub.
Só, asking if anyone has some ideas to try eliminate or attenuate this problem.
I tried a ESP32-s3, 2 esp32 dev kit 1 and a devKit C.
Also tried both ports of my old mac, 2011.
Beta Was this translation helpful? Give feedback.
All reactions