skywebplanet

Thursday, 28 April 2016

Control a Lamp Remotely Using the ESP8266 WiFi Chip


Control a Lamp Remotely Using the ESP8266 WiFi Chip 

featured

Control a Lamp Remotely Using the ESP8266 WiFi Chip


The ESP8266 is an amazing WiFi chip that can be used in several home automation applications. In this article, we are going to use it to control a lamp remotely via WiFi. However, we won’t do what you usually see on this website. Indeed, I usually use a server running on my computer to control devices remotely. Here, we are going to use the onboard processor of the ESP8266 to host a small web server, that will serve a simple interface page from which you will be able to control the lamp. And we will even make this interface responsive, so it can also be used with your phone or tablet!

Hardware & Software Requirements

For this project, you will of course need an ESP8266 chip. I used the Olimex ESP8266 module, but any ESP8266 module will work fine here.
You will also need some way to control your lamp or other devices. I originally used a simple relay for my tests, but I quickly moved to a PowerSwitch Tail Kit which allows to simply & safely plug high voltage devices to your projects.
You will also need a 3.3V FTDI USB module to program the ESP8266 chip. Finally, you will also need some jumper wires & a breadboard
This is a list of all the components that will be used in this guide:
  • ESP8266 Olimex module
  • Breadboard 3.3V power supply
  • 3.3V FTDI USB module
  • PowerSwitch Tail Kit
  • Breadboard
  • Jumper wires
Note that you will also need a device to control. I used a simple 30W desk lamp as a test device, but you can also use any other device in your home (if the power rating is lower than the maximum power accepted by the PowerSwitch Tail Kit). You can also just use a simple relay for test purposes.
On the software side, we will use the Arduino IDE to configure the ESP8266 chip. I will let you see my guide on how to set up the ESP8266 for a first use & how to upload a sketch:
https://www.openhomeautomation.net/getting-started-esp8266/
You will also need to install several libraries for this project:
  • aREST
  • aREST UI

Hardware Configuration

Again, for most of the hardware configuration I will redirect you to the article I wrote on setting up your ESP8266 chip:

The only thing you need to add to this basic configuration is the PowerSwitch Tail Kit. Connect the two pins on the right (-in and Ground) on the ground of our project (blue power rail), and the +in pin to the GPIO5 pin. If your board doesn’t have this pin, you can plug it to the free GPIO pin of your choice, you will just need to modify your code accordingly.
Then, also connect a lamp or any electrical device to the PowerSwitch, and the other end of the PowerSwitch to the mains electricity.
This is the assembled project, without the FTDI module to configure the module:
relayesphw
And this is the project deployed close to the test lamp:
esplamp

Controlling the Lamp Remotely

We are now going to write the code required to control our lamp remotely. Note that we want a completely autonomous operation of the device. The ESP8266 will have to handle requests coming from your browser, display a simple HTML page with two buttons (On & Off), and then control the PowerSwitch Tail Kit accordingly. To do all that, we will use the powerful aREST UI library that makes it really easy to build graphical interfaces.
As we are using the Arduino IDE for the ESP8266, we will simply write some Arduino code here. It starts by declaring which libraries we are going to use:
#include <ESP8266WiFi.h>
#include <aREST.h>
#include <aREST_UI.h>
Then, we declare the aREST UI object:
aREST_UI rest = aREST_UI();
After that, you will need to include your WiFi name & password:
const char* ssid = "your_wifi_name";
const char* password = "your_wifi_password";
Now, in the setup() part of the sketch, we actually build the interface of the project, with a button linked to pin number 5 of the board:
rest.title("Relay Control");
rest.button(5);
After that, we connect the board to the WiFi network:
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
 delay(500);
 Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
 
// Start the server
server.begin();
Serial.println("Server started");
 
// Print the IP address
Serial.println(WiFi.localIP());
Then, in the loop() part, we handle incoming connections with the aREST UI library:
WiFiClient client = server.available();
if (!client) {
 return;
}
while(!client.available()){
 delay(1);
}
rest.handle(client);
Note that you can find all the code for this project on the corresponding GitHub repository:
I used the Arduino IDE to upload the code to the board. First, select the ESP8266 board inside the Arduino IDE. Make sure that you choose the option that corresponds to your board, especially if you are using the Olimex board like I did for this tutorial. Also make sure that you changed your WiFi name & password inside the sketch.
Then, put the chip in bootloader mode by connecting GPIO0 to GND, and then power cycle the board by switching the power supply off & then on again. Then, upload the sketch to the board. Once it is done, disconnect GPIO0 from GND, and power cycle the board again.
Now, open the Serial monitor. You should see the IP address of the board being printed inside the Serial monitor. Finally, simply open your favorite web browser, and type in the board IP address. You should see the interface being displayed:
Screen Shot 2015-03-17 at 08.16.02
You can now try the buttons: you should notice that the state of the PowerSwitch or the relay is changing instantly. And note that this is only using the ESP8266 chip here: it’s completely independent from your computer!
The interface is also responsive, thanks to the aREST UI library. This means it will automatically adapt to the device on which it is used. This is for example the result on my phone:
IMG_0190

How to Go Further

In this project, we build a completely autonomous remote lamp controller using the ESP8266 WiFi chip. We made this little chip control a lamp (or any other device) by serving a nice & responsive interface, allowing you to control the electrical from any device within your local WiFi network.
Of course, you can use what you learned in this project to build other home automation. You can for example use the same principles to build a completely autonomous sensor module, that measure data from several sensors and display them all in a single interface, also served by the ESP8266 module.
Posted by sahabudeen at 03:44
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Just Register and earn money

Grand Bux

Earn Money Ultimate

Share Up To 110 % - 10% Affiliate Program

Business

Blogroll

Earn Money Click Register

Popular Posts

  • (no title)
    Arduino Projects 1 by sahabudeen
  • Activity Diagrams - Advantages, Disadvantages and Applications of Use
    Activity diagrams describe the actual work flow behavior of a system in Information Technology. Activity diagrams are very similar to stat...
  • London Web Design And Branding Company
    Understanding What A Brand Is and Isn’t Branding is less about getting target market customers to choose your company over the competition ...
  • Penny Pick Finders Review - Perfect Guide to Find Penny Stocks
    Some people prefer these ways : 1. scroll through stocks Scroll with the day's "most active" and also the day's "big...
  • Robotics ATmega328
    ATmega328 by sahabudeen
  • Should You be Using a VPN?
    You may already know what a VPN, or Virtual Private Network, is but are you using one? If you’re not using one, there’s a high likelihood t...
  • Different Types Of Futures Traders -- Hedgers
    In Trading Futures, there are actually 4 types of futures traders active in the Futures Market. Each of these brings liquidity to the Marke...
  • Forex trading - if you invest?
    Forex trading is concerning putting your hard earned dollars into various currencies, to help you gain the interest for the night, for time...
  • The Importance of Solid and Secure Computer Data Storage
    Are you thinking about computer data storage yet? Because with the rainy season approaching, your backup computer files might be the only t...
  • Windows Safety Series is a Virus
    What is Windows Safety Series? Windows Safety Series is a new web threat that is causing problems for computer users. This is a scareware p...

Looped Slider

About Me

sahabudeen
View my complete profile

Formulir Kontak

Name

Email *

Message *

Blog Archive

  • ▼  2016 (537)
    • ►  May (282)
    • ▼  April (255)
      • When to Seen an Audiologist: Hearing Loss Symptoms...
      • Frequently Asked Questions About Hearing Services
      • 4 Signs It's Time to Schedule a Hearing Test
      • Benefits of Consulting an Audiologist
      • Natural Eye Care Made Simple And Easy With Good Vi...
      • Effective Double Vision Reducing Nutritional Remedies
      • Where Can Students Get a Free Eye Test?
      • How to Get Rid of Eye Floaters
      • Natural Vision Improvement Diet For Better Eyesight
      • Better Vision Visualization Technique To Relax The...
      • Mad March Hair? Common Myths About the 'Crowning G...
      • Indian Ayurvedic Herbs As Hair Fall Remedies
      • Dispelling Myths About Non-Surgical Hair Replacement
      • Hair Transplant Treatment Can Change Your Life
      • What Factors Lead To A Healthy Head Of Hair?
      • Things to Keep in Mind Before Laser Hair Removal
      • Invasive Vs Non Invasive Treatments For Hair Regro...
      • Tips To Prevent Hair Loss Caused By Shampoo
      • Natural Solutions to Hair Loss - 5 Important Tips ...
      • The Best Hair Loss Home Remedies
      • How to Make Your Own Chocolate Truffles
      • How to Make Chocolate Truffles
      • 5 Genius Tricks for Hiding Your Cat's Litter Box
      • Planting an Herb and Succulent Garden in a Strawbe...
      • Chile Relleno Casserole Recipe
      • A Historical View of Cats
      • Provide Your Outdoor Cat with a House for More Com...
      • Cat Courageous - Adopting A Cat
      • Damned to be Free - The Photographs of Edward Colver
      • Top Resources To Learn How To Draw Caricatures
      • Stand up comedian funny podcasts are dominating In...
      • Free comedy – The Smartest Way to Locate the Funni...
      • Funny Sayings and Messages
      • He's a Mustache Machine!
      • Hanging with a clock collector
      • Humor Column: The Only Blues You Should Be Playing...
      • One liners funny like never before
      • Easy Ways To Get Whiplash Claim And Compensation
      • UK Property: Have you ever thought about down-sizing?
      • Funniest Show Touches the Heart of Everyone
      • Top Nerd Girlfriend Freakouts
      • Chapter 4 --1st grade
      • Mark Sweeney
      • Funny Christmas Stories to Share with Your Loved Ones
      • Funny Short Stories
      • Photographs that displays emotions not just poses!
      • A Bobcat
      • The Top Weight Reduction Guidance Is Too Set Smart...
      • Operating To Lose Weight - What You'll Need To Com...
      • Weight Loss Over Gain Weight
      • Weight Loss Capsules
      • Diet Program To Lose Weight
      • What Is Functional Fitness?
      • Your Diet Solution Is Your Nutrition
      • I'm Skinny But Have Belly Fat
      • Working Out With Your Pet
      • Gluten-Free Diet Review
      • Causes of Limping in Dogs
      • Tips To Secure Your Php Web Applications
      • Motherboard
      • Online Poker Games: earning a fast buck
      • Activity Diagrams - Advantages, Disadvantages and ...
      • Great Gambling Board Games Of The Past
      • 7 Best Single Tree Flower Essences: Black Spruce
      • The Top 10 Ways to Build Backlinks
      • The Top 10 Ways to Build Backlinks
      • Loya's Auto Insurance Place
      • Roof Top Football Challenge
      • London Web Design And Branding Company
      • What is the Best Way to Lose Weight
      • Slimming Pills - Probing the Expectation of Benefi...
      • Making Simple Changes Will Help You Lose Weight
      • Review Of 31 Day Fat Loss Cure
      • 10 Top Tips On Keeping The Weight Off
      • Lose Weight Fast - 5 Essential Tips to Lose Weight...
      • Do you know how difficult the hcg diet or any diet...
      • Review Tips on Finding the Best Hoodia
      • Operate Your Business Efficiently with Transport E...
      • Ice Watches are very cool and very popular
      • Cheap Women's Shoes
      • Why Satellite TV From Directv
      • Policies on Enjoying Slots Games On line
      • Easy Back Link Strategies
      • How Does Bad Credit Effect My Chances of Getting a...
      • Finding the best Casino Card Video games Online
      • Viagra’s Unexpected Side Effect
      • High Risk Bad Credit Personal Unsecured Loans: Sec...
      • Cost Price Of Facial Laser Hair Removal Cost in La...
      • Bad Credit Computer
      • How long does marijuana stay in your system?
      • Bipolar Disability Benefits in Minnesota
      • Directory Submission Tips for Your Website
      • Instant Decision Business Loans with No Credit Check!
      • How Forums Can Increase Your Website Traffic
      • Building a Conducive School Climate
      • Signing up with a Mag of your Taste
      • IoT Applications With Examples
      • 5 Easy To Understand Examples Of The Internet of T...
      • Wireless temperature logger ESP8266 NodeMCU v1.0 w...
      • Control a Lamp Remotely Using the ESP8266 WiFi Chip

Find Us On Facebook

Advertisement

Featured Video

Featured Video

Breaking News

Pages

  • Home

Sponsor

Gagdet

Flickr Images

Click Here! Imagine If You Could Have A Consistent, Profitable Robot Developed For A Private Group Of Traders That Makes Over 30% A Month Trading In The Forex Market With Live Documented Proof?

Video Of Day

Gallery

Paling Dilihat

  • (no title)
    Arduino Projects 1 by sahabudeen
  • Activity Diagrams - Advantages, Disadvantages and Applications of Use
    Activity diagrams describe the actual work flow behavior of a system in Information Technology. Activity diagrams are very similar to stat...
  • London Web Design And Branding Company
    Understanding What A Brand Is and Isn’t Branding is less about getting target market customers to choose your company over the competition ...
  • Penny Pick Finders Review - Perfect Guide to Find Penny Stocks
    Some people prefer these ways : 1. scroll through stocks Scroll with the day's "most active" and also the day's "big...
  • Robotics ATmega328
    ATmega328 by sahabudeen
  • Should You be Using a VPN?
    You may already know what a VPN, or Virtual Private Network, is but are you using one? If you’re not using one, there’s a high likelihood t...
  • Different Types Of Futures Traders -- Hedgers
    In Trading Futures, there are actually 4 types of futures traders active in the Futures Market. Each of these brings liquidity to the Marke...
  • Forex trading - if you invest?
    Forex trading is concerning putting your hard earned dollars into various currencies, to help you gain the interest for the night, for time...
  • The Importance of Solid and Secure Computer Data Storage
    Are you thinking about computer data storage yet? Because with the rainy season approaching, your backup computer files might be the only t...
  • Windows Safety Series is a Virus
    What is Windows Safety Series? Windows Safety Series is a new web threat that is causing problems for computer users. This is a scareware p...

Blog Archive

  • ▼  2016 (537)
    • ►  May (282)
    • ▼  April (255)
      • When to Seen an Audiologist: Hearing Loss Symptoms...
      • Frequently Asked Questions About Hearing Services
      • 4 Signs It's Time to Schedule a Hearing Test
      • Benefits of Consulting an Audiologist
      • Natural Eye Care Made Simple And Easy With Good Vi...
      • Effective Double Vision Reducing Nutritional Remedies
      • Where Can Students Get a Free Eye Test?
      • How to Get Rid of Eye Floaters
      • Natural Vision Improvement Diet For Better Eyesight
      • Better Vision Visualization Technique To Relax The...
      • Mad March Hair? Common Myths About the 'Crowning G...
      • Indian Ayurvedic Herbs As Hair Fall Remedies
      • Dispelling Myths About Non-Surgical Hair Replacement
      • Hair Transplant Treatment Can Change Your Life
      • What Factors Lead To A Healthy Head Of Hair?
      • Things to Keep in Mind Before Laser Hair Removal
      • Invasive Vs Non Invasive Treatments For Hair Regro...
      • Tips To Prevent Hair Loss Caused By Shampoo
      • Natural Solutions to Hair Loss - 5 Important Tips ...
      • The Best Hair Loss Home Remedies
      • How to Make Your Own Chocolate Truffles
      • How to Make Chocolate Truffles
      • 5 Genius Tricks for Hiding Your Cat's Litter Box
      • Planting an Herb and Succulent Garden in a Strawbe...
      • Chile Relleno Casserole Recipe
      • A Historical View of Cats
      • Provide Your Outdoor Cat with a House for More Com...
      • Cat Courageous - Adopting A Cat
      • Damned to be Free - The Photographs of Edward Colver
      • Top Resources To Learn How To Draw Caricatures
      • Stand up comedian funny podcasts are dominating In...
      • Free comedy – The Smartest Way to Locate the Funni...
      • Funny Sayings and Messages
      • He's a Mustache Machine!
      • Hanging with a clock collector
      • Humor Column: The Only Blues You Should Be Playing...
      • One liners funny like never before
      • Easy Ways To Get Whiplash Claim And Compensation
      • UK Property: Have you ever thought about down-sizing?
      • Funniest Show Touches the Heart of Everyone
      • Top Nerd Girlfriend Freakouts
      • Chapter 4 --1st grade
      • Mark Sweeney
      • Funny Christmas Stories to Share with Your Loved Ones
      • Funny Short Stories
      • Photographs that displays emotions not just poses!
      • A Bobcat
      • The Top Weight Reduction Guidance Is Too Set Smart...
      • Operating To Lose Weight - What You'll Need To Com...
      • Weight Loss Over Gain Weight
      • Weight Loss Capsules
      • Diet Program To Lose Weight
      • What Is Functional Fitness?
      • Your Diet Solution Is Your Nutrition
      • I'm Skinny But Have Belly Fat
      • Working Out With Your Pet
      • Gluten-Free Diet Review
      • Causes of Limping in Dogs
      • Tips To Secure Your Php Web Applications
      • Motherboard
      • Online Poker Games: earning a fast buck
      • Activity Diagrams - Advantages, Disadvantages and ...
      • Great Gambling Board Games Of The Past
      • 7 Best Single Tree Flower Essences: Black Spruce
      • The Top 10 Ways to Build Backlinks
      • The Top 10 Ways to Build Backlinks
      • Loya's Auto Insurance Place
      • Roof Top Football Challenge
      • London Web Design And Branding Company
      • What is the Best Way to Lose Weight
      • Slimming Pills - Probing the Expectation of Benefi...
      • Making Simple Changes Will Help You Lose Weight
      • Review Of 31 Day Fat Loss Cure
      • 10 Top Tips On Keeping The Weight Off
      • Lose Weight Fast - 5 Essential Tips to Lose Weight...
      • Do you know how difficult the hcg diet or any diet...
      • Review Tips on Finding the Best Hoodia
      • Operate Your Business Efficiently with Transport E...
      • Ice Watches are very cool and very popular
      • Cheap Women's Shoes
      • Why Satellite TV From Directv
      • Policies on Enjoying Slots Games On line
      • Easy Back Link Strategies
      • How Does Bad Credit Effect My Chances of Getting a...
      • Finding the best Casino Card Video games Online
      • Viagra’s Unexpected Side Effect
      • High Risk Bad Credit Personal Unsecured Loans: Sec...
      • Cost Price Of Facial Laser Hair Removal Cost in La...
      • Bad Credit Computer
      • How long does marijuana stay in your system?
      • Bipolar Disability Benefits in Minnesota
      • Directory Submission Tips for Your Website
      • Instant Decision Business Loans with No Credit Check!
      • How Forums Can Increase Your Website Traffic
      • Building a Conducive School Climate
      • Signing up with a Mag of your Taste
      • IoT Applications With Examples
      • 5 Easy To Understand Examples Of The Internet of T...
      • Wireless temperature logger ESP8266 NodeMCU v1.0 w...
      • Control a Lamp Remotely Using the ESP8266 WiFi Chip

Pages - Menu

  • Home
Simple theme. Powered by Blogger.