ESP32 INPUT_PULLUP connected to a Mechanical Light Switch

kiranvivo
Posts: 1
Joined: Tue Aug 17, 2021 6:51 am

ESP32 INPUT_PULLUP connected to a Mechanical Light Switch

Postby kiranvivo » Tue Aug 17, 2021 7:09 am

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 2763 times

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

Re: ESP32 INPUT_PULLUP connected to a Mechanical Light Switch

Postby ESP_Sprite » Tue Aug 17, 2021 7:56 am

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.

Who is online

Users browsing this forum: No registered users and 96 guests