PROBLEM TO READ ADC GPIO 36

Raka Mahendra
Posts: 1
Joined: Mon Jul 04, 2022 10:26 am

PROBLEM TO READ ADC GPIO 36

Postby Raka Mahendra » Mon Jul 04, 2022 10:57 am

NEED HELP PLEASE FOR MY FINAL PROJECT ON CAMPUS.

hello guys. i will really really appreciate if u can help me.
i have a problem with gpio 36. i use this pin to measure a voltage divider.
when i just connect my ESP32 Devkit, it writes 0 ADC.
but when i combine my ESP32 with another components on PCB Board, the ADC starts from +- 3029 and changed randomly.
so what should i do to calibrate the adc when it connected with another components?

the code:

Code: Select all

#define ADC_PIN     36               
float Vmodul = 0.0; 
float result = 0.0;
int value = 0;
float R1 = 68000.0; //68k
float R2 = 7500.0; //7500 ohm resistor, 


void setup()
{
   pinMode(ADC_PIN, INPUT);
   Serial.begin(9600); 
}
 
void loop()
{
  value = analogRead(ADC_PIN);    
   Vmodul  = (value * 3.3)  / 4095.0; 
   result = Vmodul   / (R2/(R1+R2));
  
  Serial.print("module voltage = ");
  Serial.print(Vmodul,2);
  Serial.print("volt");
  Serial.print(", real result  = ");
  Serial.print(result,2);
  Serial.println("volt");
  Serial.print(", ADC = ");
  Serial.println(value);
  Serial.println("");
  delay(1000);
}
the image before i connect to my pcb board:
Image

the image after i connect to my pcb board (i dont even measure anything with my voltage divider sensor) :
Image

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: PROBLEM TO READ ADC GPIO 36

Postby ESP_Sprite » Tue Jul 05, 2022 1:29 am

Pins that are not connected to anything have no determinable voltage on them. Connect them to the resistive divider and try again.

Who is online

Users browsing this forum: No registered users and 112 guests