Today most people desire to use smart devices. But most of the times they have to spend buckets of money to achieve it. They even have to buy new electrical equipment that supports smart features. But I’m going to show you how to make a smart device yourself, which is ideal for homes, working places, and also for dorms.
There are 3 modes available in this device.
- Manual Mode - Turns ON and OFF the electrical equipment manually whenever you need.
- Human Detection Mode – Automatically turns off the electrical equipment when no one is detected around which saves power a lot.
- Timer mode – Sets a countdown timer to switch OFF the electric equipment when the time ends.
The main advantages of this device are:
- No need to modify the wiring system of the house
- Not expensive
- Easy to operate
- Saves power
- Fire safe
Autodesk circuit simulator is used to demonstrate steps and functions.
Here are the components.
- Arduino Uno/Nano
- PIR sensor
- 16X2 LCD
- 4 Push Buttons
- 5 1K resistors
- 10k potentiometer
- 5V relay Module
- Old mobile phone charger
I will break down the making process to make it convenient.
Step 1: Testing the LCD
Connect the potentiometer to LCD as follows. Potentiometer is used to control the contrast. Last 2 pins of the LCD are for the backlight. Usually, it denotes by A and K. However, here both pins are mentioned as LED. Connect Vcc to A through a 220 Ohms resistor and GND to K. (Figure 1)
Then connect the remaining pins to the Arduino board as follows.
- LCD RS pin to Arduino D12
- LCD E pin to Arduino D11
- LCD D4 pin to Arduino D5
- LCD D5 pin to Arduino D4
- LCD D6 pin to Arduino D3
- LCD D7 pin to Arduino D2
- LCD R/W pin to ground
- LCD VSS pin to ground
- LCD VCC pin to 5V
When you connect the Arduino to the computer, the LCD back-light should turn ON. Then upload the given Arduino code (LCD_test.ino) to the Arduino board. It should display “Hello World!” on LCD. (Figure 2)
Step 2: Connecting PIR
Connect the Pins of PIR sensor to the Arduino board as follows.
- PIR’s Vcc to Arduino 5v
- PIR’s GND to Arduino GND
- PIR’s Signal to Arduino D6 (In image I have connected it to A5 pin.)
Step 3: Connecting the Buttons
Now we focus on the push buttons. We have 4 push-buttons. Connect them according to the shown diagram. Use A2-A5 pins.
- Mode Button to pin A2
- Decrement Button to pin A3
- Increment Button to pin A4
- Start Button to pin A5
Now the basic part is done. I will use an LED here instead of a relay. But keep in mind if you want to control electrical equipment of your house you have to connect the relay module. Here, the LED is connected to D10 pin using a 220 Ohms resistor. I will explain the method to connect the relay after this.
Now upload the given Arduino code (final.ino) to your Arduino board.
Step 4: User Manual
The initial mode is the Manual mode. You can turn on the bulb by Increment button and turn off by decrement button.
To change the mode to Human detection mode, press Mode button. In this mode LCD will display “Detected” and turn ON the bulb when it a human being is detected in that range. When a human being is not in the range, it will automatically run a 20 second timer and if someone didn’t return during that time period, it will turn OFF the bulb.
To change the Mode to Timer mode, press Mode button. You will see there are parameters for hours, minutes and seconds. Initially, the hour digits are blinking. You can increase or decrease hours by increment and decrement buttons. If you press mode button again it will move to minutes. Again with the mode button it will move to seconds. After that press the mode button again to end the timer edit option. Then by pressing start button you can turn on the device for that time period.
To control electrical equipment from the main power line connect the relay module the Arduino board. Then, Vcc and Gnd of the relay module to the VCC and gnd of the Arduino and the signal pin to D10. Finally, connect the main power and electrical equipment to screwing headers.
The best thing is you can make this device compact as a hand-held-sized enclosure.
Hope you will have a good smart home without spending a fortune on that.