I have a small ESP32 module, that has some in-built features, like a TFT, and has few available pins for general use.

It has some input only pins (GPIO36 to 39) that are used by buttons soldered in the pcb, and they are all pulled high by 4.7k resistors, in the schematics below:

enter image description here

I won't use these pins as buttons (and I won't press them), and I need to connect the analog output (0-3.3V) of one sensor in one of these inputs and use analogRead() to get the results.

Is is possible to use a pulled high pin to read an analog voltage from a sensor? It just inverts the readings of the output voltages? When the sensor outputs 3.3V the pin will read 0V and when the sensor outputs 0V the pin will read 3.3V?

It's just a matter of inverting the values read in the code? Or anything else?


  • Do these pins have external pullups on the PCB or are the builtin ESP32 pullups used (which can be activated and deactivated via software)?
    – chrisl
    Nov 4, 2022 at 11:48
  • There will be no inversion because of the on board button's external pullup resistor. The impedance of an analog pin is extremely high (say 10Mohms) so a 4.7k series resistor in series will make little difference. Any required inversion of the analog result can be done in software. Don't press the connected button though if a sensor is applying a voltage.
    – 6v6gt
    Nov 4, 2022 at 11:51
  • @chrisl these pull-ups are wired in the pcb, not inside the chip. I'll update the question
    – Rodrigo
    Nov 4, 2022 at 12:09
  • @6v6gt, so nothing happens? It acts as a normal analog input?
    – Rodrigo
    Nov 4, 2022 at 12:16
  • 1
    @Rodrigo My previous comment may not be correct under all circumstances. If your sensor is say a light dependent resistor, then you need a pullup to form part of a potential divider. If the sensor, however, delivers a voltage (say some types of microphone), then you need to remove the pullup resistor (or cut a track) as already mentioned by hcheun . It depends on the sensor. What sensor are you using ?
    – 6v6gt
    Nov 4, 2022 at 14:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.