Page 1 of 1

ESP32 INPUT_PULLUP connected to a Mechanical Light Switch

Posted: Tue Aug 17, 2021 7:09 am
by kiranvivo
Hi all,

I have been recently working on esp32 home automation experiments where I had a quick question on the INPUT_PULLUP Resistor and its working in real world application.

Problem:
I am using a GPIO INPUT Pin with INTERNAL_PULLUP configured to read the state of my Mechanical Switch (not the push button but the actual Light Switches we use at Home).

I understand the PULLUP Resistor value is 40k Ohm as per the data sheet which means ~82.5uA ( V/R = 3.3 /40k ) of current will flow through the switch to reach the GND making the GPIO Pin read LOW.

My issues here, will there be an issue when 82.5uA current flows through the Light Switch which might have its own resistance. Is there a possibility this connection can go wrong and the Switch Path will not lead to GND preventing the GPIO LOW ?

Adding graphical image for reference
Note: The PUSH Button below are to be replaced with the Actual Light Switches.
esp32.jpeg
esp32.jpeg (58.89 KiB) Viewed 2762 times

Re: ESP32 INPUT_PULLUP connected to a Mechanical Light Switch

Posted: Tue Aug 17, 2021 7:56 am
by ESP_Sprite
Theoretically, you could play this by numbers. Look up the datasheet for the switch (or one that is similar), look up the maximum resistance it has when the button is pressed and the minimum resistance it has when it is not pressed, and use Ohms law and the pullup current to figure out the voltage on the GPIO when the button is pressed or released. Compare that to the ESP datasheet, specifically the minimum input voltage for a signal to be seen as high as well as the maximum for it to be seen as low, and you have your answer.

More practically: given that the on-resistance usually is milli-ohms and the off resistance usually is mega/giga-ohms, the solution you proposed should work perfectly fine.