Automatic Contactless Switch For Smart Home

This post was originally published on this site
Advertisement

Fig 1. Switch with OLED version

With increased technological advancements, switches require updating with current times. To avoid the risk of contracting COVID-19, it has become important to not touch surfaces of buttons and keys that have been frequently used by other people. This calls for a need to innovate the switching technology for replacing a hand-operated switch,

So today, we will design a no-touch switch that works entirely on hand gestures. Our smart switch includes a sensor that is capable of detecting hand movements and translates them into commands for controlling lights, fans and various home appliances.

Bill of Materials

Let’s start designing the smart switch by shopping for the following components.

Coding

First of all we need to install the required library in the Arduino IDE. Go to Select → Library Manager → Search APDS9960 → Install Adafruit APDS9960 

Installing LibraryFig 2. Installing library

After installing the library, add it into the code and then define the pin number for light and fan control. Next, create a setup function where you can initialise the sensor and set the pinmode output for light and fan control. 

Fig 3.Coding Fig 4.Setup function

Then create a loop function to update the sensor readings and use your hand gestures as an input to control the pin. Also create a few if conditions for specifying the commands based on the type of hand gestures (up, down, left and right). 

Up: Lights ON 

Down: Lights OFF 

Left: Fans ON

Right: Fans OFF

Fig 5. Loop function

Connection 

Now upload the code to Arduino and connect the components as described in the circuit diagram. Then connect the AC wire with the common pin of relay module to control the lights and fans.

Fig 6.Connection Fig 7. Connection inside board

Testing 

Now power the device and relay. When you will move your hand in an upward direction, the relay will be moved and lights will switch ON. Similarly, a hand gesture in downward direction will switch OFF the lights. 

Code

Advertisement