There are some design considerations to increase safety while building an ESP32 Arduino based physical switch controlled by IoT project. In our earlier guide (Controlling AC Powered Appliances With ESP32 and IBM Watson IoT), we have shown the basic of how to use a pushbutton and IoT control together. The case will be using both the pushbutton and IoT control independent. Our that guide is a shortcut to avoid learning difficulties new users commonly face to control switchover Wi-Fi, Bluetooth. That easy method nicely works for building real-life touch controlled wall switch panel with additional IoT control provided the electrical and electronics part is perfectly set.
The way we have shown set up in that guide will make the relay unreliable when tried to control with the pushbutton. This is where we need the logic level shifter to convert 3.3v logic to 5v logic. Using a logic level shifter will end the puzzling situation we mentioned in that guide – it will convert 3.3V logic to that of 5V. We can use a 2N2222 NPN transistor to shift levels. The ground will be common for 5v and 3.3V. From the relay, we can connect different devices. Whenever you will have the proper circuit, on the Arduino IDE’s serial console you will get the match of present real action. You can make a thing on by tapping on mobile application and off by clicking the pushbutton. You can use ready to use logic level shifters with our shown 4 channel relay. This one consideration.
The second part is powering the ESP32. If you power the ESP32 by converting AC mains to 3.3V and 5V DC that becomes compact and cost becomes negligible to use status indicator LEDs. That is a star configuration of power supply. If you use battery then you need to replace the batteries on a regular basis plus thoughts to decrease the number of LEDs to decrease consumption comes in to question. We will suggest keeping the ESP32 powering part and relay in such a way that it does not crowd the thing, avoids short-circuit etc. If you power the ESP32 by converting AC mains to 3.3V and 5V DC then that power conversion part should be properly designed and insulated. If you use the breadboard components then consider to power the system from a 9V battery (step down it to 3.3v and 5V regulated supply). Star configuration of power supply (i.e. using same AC mains supply for ESP32 and appliances) is not exactly easy to make fool-proof than it appears. The transformer in-between makes a huge difference with the battery powered control.
The third part is obvious – most these days want to use touch switches. ESP32 support touch switch, indeed Espressif has official touch dev kit (ESP32-Sense Kit). Crystal glass touch switch panels are nothing more than that basic. Many peoples researched on the topic of creating yet beautiful cheap glass touch panels :
Comments reveal one terrific China technology – pushbuttons behind a glass panel. I have not tested using pushbuttons behind a glass panel. Most of the great looking tempered glass panel with touch switch is from China, costs too high (and are unreliable), usually packaged our idea before us i.e. they are already Wi-Fi controlled, IoT controlled system. China sends less variety of stuff to India. I could not found just the switches with a panel.