Wrong ADC readings when using Serial Communication at PortA
I'm using M5Core2 to make a datalogger. For that, I'm communicating with a telemetry box by Serial using a PmodRS232, with needs alimentation. So I use PortA for Serial and feeding of PmodRS232 and the communications run smoothly.
The problem is that I'm also using PIN 36 as an ADC and if I plug the PmodRS232 at PortA the readings of the ADC increase by ~60%. If I unplug the cable of PIN 36 I get 4095 if PmodRS232 is plugged in (which is wrong), and 0, if PmodRS232 isn't plugged in (which is correct).
I already know PortA as pull-up resistors, but I don't understand why that affects PIN 36 (or 35, I already tried it) readings.
Thanks a lot for your help, I'm looking forward to solving this problem.
felmue last edited by felmue
I don't see the ADC reading on GPIO36 being influenced by serial traffic on port A.
My setup periodically (1 s) sends a string through port A (and I generate traffic from the terminal in the other direction) while I read the ADC value from GPIO36. The value is pretty stable. And I don't see a difference whether port A is connected or not.
The fact that you get the maximum value (4095) with GPIO36 floating and PmodRS232 connected, but the minimum value (0) when PmodRS232 is not connected is very strange. If I have GPIO36 floating I get a reading of about 400 independent of port A connection.
Can you share the circuit you use for the ADC input? And also how you setup and read GPIO36?
Thanks for your response @felmue,
It's very strange, that's why I'm asking on this forum. I could not find anything online. I'll take a picture of the setup, and send the relevant code.
It works well without the PmodRS232.
// Serial Config
Serial2.begin(115200 , SERIAL_8N1, 32 , 33 );
// ADC Config
pinMode(36, INPUT); // I already tried with and without this, same results
M5.Lcd.drawString(("Read voltage: " + String(analogRead(36)/4095*3.9), 0, 0, 4);
felmue last edited by
It seems that the PmodRS232 can be powered with 3.3 V or 5 V. And I assume whatever voltage is used to power it, it also uses on the TX and RX pins. Now, port A, while the GPIOs are 3.3 V, delivers 5 V on the VCC line. My assumption is that a connected PmodRS232 raises the TX and RX lines to 5 V and through the pull-up resistors or internally in the ESP32 its 3.3 V VCC line is raised as well messing with the ADC. Maybe check the TX and / or RX lines with a multi-meter to see if they are 3.3 V or 5 V. If I am correct you need to change your setup to power the PmodRS232 with 3.3 V instead.
ADC: if you care about values between min an max, I'd modify the calculation to first do the multiplication and the the division.
@felmue thanks for your reply again Felix,
You might just be right. Tomorrow I'll try it. Thanks a lot!
It worked! Fixed problem eheh!