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 Robotics

Arduino Robotics Series, from a car to a robot arm

Arduino keeps standing out from the crowd of all-around development boards due too its ease of use and budget price. As a result, this has enabled almost anyone to get his own idea into life no matter how crazy or even useless to the whole world it was, except for its maker! Also, it has …

Arduino Robot Arm

How to build an Arduino Robot Arm placed on RC Car

Arduino robots are always funny and definitely more enjoyable when combined with robotic arm! And today, I will walk you through the making of a simple Arduino Robot Arm that’s made of cardboard and how you can attach it over your Arduino Bluetooth RC Car / Robot that you have made so far through this series. …

Arduino Line Following Robot

How to build an Arduino Line Following Robot using Cardboard

Arduino Line Following Robot is one of the easiest and most well-known projects that anyone can make to learn the basics of programming, electronics, and mechanics all in one project. It’s known that this project is common for most of the makers and tech students and today I am going to give it a revisit …

Arduino Obstacle Avoiding Robot

How to build an Arduino Obstacle Avoiding Robot using Cardboard

Back again with another Arduino Bluetooth RC Car tutorial but with an advanced feature that makes your car autonomous by adding ultrasonic sensors to the RC Car you have made before!. Yeah, I know that you may have seen other tutorials using ultrasonic to make the car/robot avoid obstacles ahead, but I am going to …

Arduino Bluetooth RC car

How to make an Arduino Bluetooth RC Car using Cardboard

  Cardboard crafts are one of the most popular and easy to make DIY stuff. Mixing this with the unmatchable enjoyment of RC Cars and the ease of using Arduino, I am going to show you how to make a Cardboard Arduino Bluetooth RC car that you can control via Bluetooth from your smartphone.  …

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …