- My actions are: [I Tried Using GPIO.read(pin) And ADC.read(pin) To pin 34 in ESP32 ,The Pin 34 is connected to Battery and It has to read the battery voltage from that pin. ]
- The result I see is: [I Am Either Getting 1 or 0 iAs output by reading that pin .When I Am Reading the same pin using arduino code i am getting proper voltage reading ]
Neither a microcontroller nor an OS or a framework, at least today, can guess what you want to do unless you tell them properly. Some environments make assumptions and simplifications to make user life easier, what in my opinion is (at least) confusing (if not misleading).
If you want a pin to be connected to the ADC, you have to configure the microcontroller for that. At the firmware level that means to call the proper function in the API, with the proper parameter.
If you want to read a measurement from the ADC, you have to read the ADC, not the GPIO. If the ADC has several pins enabled, it will have a mux to select which pin to convert, and you will have to indicate that somehow. At the firmware level that means to call the proper function in the API, with the proper parameter.
The ADC API lives here
I don’t have the time to check for mistakes on my part, I guess what you need is:
ADC.enable(34); batt = ADC.read(34);