Control ANY light or electrical appliance with you tablet or smartphone (wifi) using arduino, blynk and a wemos / ESP8266 board
In this tutorial we will be making something I call a wifi controlled ac switch. (But it also works for DC applications that are powered by a wall outlet) Basically we will make a small box that can control any ac electric current in your home, based on commands from your tablet or smartphone. On top of that it can be programmed to react to input from any kind of sensor. Tailored to your needs and limited only by your imagination. The total cost of the project is between €5 and €25 depending on what you have lying around at home.
Check out the video real quick and you will get the idea. (I apologise for filming with a potato). This is what you will make in very little time if you follow this instructable.
Why make this?
I had a problem. I have had it for a while. My beautiful girlfriend and now soon to be wife always falls asleep with the nightlight on, often with her head on my shoulder (Pic from yesterday afternoon attached!). The nightlight is on her side, as she needs the nightstand for her jewellery, and whatever else women keep in there? This puts me in the painful dilemma of either lying awake or waking her. Her long curls make any ninja attempts impossible. So I came with this idea: “What if I could control the nightlight from my phone?” This instructable is the result of months of research towards exactly that end. I am going to show you the best and most cost efficient way to hack your hot girlfriend’s nightlight but also to control any other electrical appliance. You will make a remotely controllable relay, a simple but effective arduino home automation sketch and a blynk smartphone app that you can share with your hot girlfriend, any other mistresses you may have and whomever else. Important to this project is that no damage is done to the electrical appliances you wish to control and it continues to operate as before with manual control. Safety is also an important feature, and tips and pointers will be given. We don’t want to electrocute our future spouses when they touch their nightlights, now do we?
Why else would you want to make this?
– You think the Phillips hue and all other commercial alternatives are way overpriced and you want a solution you can actually tailor to your needs for a fraction of the price.
– You want to scare the **** out of someone by switching their lights ON/OFF when they are home alone, they wont be able to comprehend what’s happening
– You want to hack the lights at the office you work, so all the lights go on every time you and only you enter.
– You want to control your kettle in the morning or your toaster,
– You have an electric heater you want to program to switch ON/OFF or control with your phone,
– You want to make all the lights in your house smartphone controlled, but also want them to turn off during bright day time to be sure none stay on needlessly.
– You want to create a fireworks or rocket detonator (I have a better instructable for that, but same idea – NEVER use a mechanical relay for this though),
– You want to turn a fan ON/OFF according to temperature in the room, time of day or smartphone command.
– You are making a custom project that requires remote control of a relay and maybe also sensory input.
– You want to program the lights in your house to go switch while you are on holiday in different order, to really make it seem that you are home.
– You want to switch on your desktop computer remotely (see my next instructable)
– You want to put current on the front door handle and electrocute burglars or your drunk teenage children sneaking in through the front door passed midnight. (Maybe this is a bad example?)
– You want to make a programmable switch that reacts to temperature, heat, light, movement, sound, or any combination, but at the same time you want to be able to override it remotely through your phone or pc.
The box you saw in the video is what we will be making. I call it the Mona AC wifi switch and I sell tailor made versions of it on my website www.monaselectronics.com. It plugs in like an extension cord to your electrical appliance and regulates the current that goes from the socket to the appliance through a relay that is powered by an esp8266 and programmed in arduino or lua. The unit is powered by a small internal power supply. No batteries or other funny booboos. Ready to get started, read on!
The first thing you will need to do to build your Mona AC wifi switch is recycling or shopping. Most parts you likely already have so this wont be expensive. If you have a hard time finding the parts, check out aliexpress.com. All my supplies come from there and it is dirt cheap with free postage. Avoid western sites like sparkfun and amazon if you are on a budget.
NOTE ON IOT Microcontrollers:
If you want to make an IOT or arduino project that is connected to the internet over wifi, you need a board that can connect to wifi. It’s that simple. The arduino uno, nano, micro, mega… cannot connect to wifi without the addition of expensive and outdated shields. So save yourself a lot of time and money and don’t do this unless you have a good reason to. I learned the hard way… ESP8266 boards are great but often do not support arduino out of the box. A lot of headache is often involved in getting these to work with arduino and their size makes them hard to work with.
Instead get a wemos D1 mini from www.wemos.cc. The wemos D1 mini is an ESP8266 on a breakoutboard, features full wifi capabilities out of the box and costs only $4,00. Thats right, four dollars for a microprocessor that connects to wifi! It features all the things you know and love about the arduiono uno like: digital pins, analog pins, vin, GND, 3,3 v output, power supply connector, 5V output and a fast and easy micro usb connector to upload your sketches. Do yourself a favor and go for a board like this if you want to start making IOT projects in small quantities.
An esp8266, I strongly recommend the wemos d1 mini, or mc lua boards WITH micro usb port.
One 5v / 10a relay, I recommend the ones with screw terminals often labelled “arduino relay”.
One AC to 5V DC power converter (these are in any and all phone, tablet and usb chargers).
One electronics box or any other NON-CONDUCTIVE box or case you may have.
I like the black ones from aliexpress because they are cheap and a perfect fit.
One AC 250v, 1a power switch – any type will do. (Find these in pretty much any old radio or toy).
One DC 5v pushbutton – any type will do. (Find these in pretty much any old radio or toy or arduino starter kits)
One line of screw terminals (min 10 amps is recommended here)
One micro usb cable for destroying (It can be damaged on the usb side, and does not need to be a data cable – we only need the micro usb plug side)
One micro usb cable for programming
Some cable / wire that can withstand 10A – I recycled mine from an old pc power supply cable.
LEDS (I added one led in series with the push button because it makes testing way easier, I also added a bright blue led that can be programmed and switched on separately to find the bathroom at night)
One circuit breaker or fuse ( I did not put one in this project) most likely though, your home has these already on the wall outlet)
Epoxy or hot glue for potting your electronics (recommended for durability)
Whatever sensors you wish to add (I did not add any for this project but I did add an additional pushbutton that can be programmed to do anything (send email, switch power ON for just a short time, crash the device, flash all Lights and leds in SOS pattern, etc.)
Male and female wall plug (like you would find on the two ends of an extension cord)
I am not associated with any of the products or services mentioned in this instructable. AC current is dangerous (Like seriously, DO NOT underestimate it). This guide prides itself on being noob friendly and will allow anyone to make an ac wifi switch and enter inexpensive home automation. It is for you to decide if you should. That being said, if you are confident that you can handle this project and you know that touching both ends of a powered line is gonna be aauwieeee, keep reading!
For more detail: Control an electrical appliance with your smartphone – WiFi
Low cost PCB at PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $30 with Free shipping all around world + Free stencil
Extra 15% off for flex and rigid-flex PCB