Control a fan with smartphone gesture (Arduino Home Hacks #2)

Welcome to our home automation hacks series #2, today I am going to show you how to hack your home outlets with Arduino and a phone gesture ๐Ÿ˜‰ .This time I used Accelerometer sensor shield from 1Sheeld application. And with a simple gesture it will open\close the outlet to trigger the fan on or off according to it’s last state. So let’s start with

1- Components

These are the components we need, so we will test the system first before hacking our real home plug.
1- Arduino Uno
2- 1Sheeld
3- Relay board
4- Wired outlet
5- Female to Male jumpers
6- USB cable
7- Smartphone
8- Screw driver

2- Connections


1- So we got the wired outlet to simulate and test the process of controlling devices (which is a fan in our case). It comes with two wire lines, at first we gonna cut one of these wires and strip the ends to wire them to our relay board on ports (Common and Normally open).
2- Then connect the relay board to the 1Sheeld&Arduino on Vcc, GND & pin13 for the signal line.

3- Code

Here’s the full working code. The code uses the Accelerometer sensor library provided with the 1Sheeld library to control pin13 (which already connected to the relay signal pin) and with a simple gesture by shaking off the phone it will trigger the fan on/off.

4- Testing


1- Now plug your arduino to your PC/Laptop and upload the code (make sure first to put your 1Sheeld to uploading mode preventing errors).
2- Open 1Sheeld application and connect to 1Sheeld board.
3- Now switch back the 1Sheeld to “Operating mode”.
4- Choose Accelerometer sensor shield, and check the Linear acceleration option from the check box.
5- Now shake the phone to turn on/off the fan.

5- Designs


The same as before in #1 hack, I have an already designed 3D case to hold my electronic parts together, you can check it out and download the files from Here, and as usual feel free to design your own 3D cases for your extra electronic parts ๐Ÿ™‚ .

6- Deployment


1- After testing we gonna wire thing on a real home outlet, but before touching or unscrewing anything, cut the power off the outlet (as stated before) and do the job.
2- Now unscrew the outlet face cover and reach in to one of the wire lines, cut&strip it the same way we did in testing.
3- Connect the two stripped ends to the relay board.
4- Power up the system with a 12V DC adapter or with a 9V battery.
5- Return the power back to the outlet, then open the application, connect and open the accelerometer sensor shield.
6- Now Plug in the fan and make sure it’s opened and shake the phone to enjoy the hack.

Second hack done..! stay tuned for more hacks ๐Ÿ˜‰ .




Related Blogs

Arduino IoT

Arduino IoT Shield Functions Explainer

Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shieldย that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …

Arduino Plant Watering System

Arduino Plant Watering System (Arduino Home Hacks #3)

๏ปฟ Arduino Plant Watering System Welcome to our home automation hacks series #3, for so many times I had problems with watering my plants while traveling abroad and I have always needed a way to control it remotely, then I decided to do it with one of the fanciest ways you may ever hear off, …