Control a Lamp Remotely Using the ESP8266 WiFi Chip

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:

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:

Hardware Configuration

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

https://www.openhomeautomation.net/getting-started-esp8266/

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:

Control a Lamp Remotely Using the ESP8266 WiFi Chip

And this is the project deployed close to the test lamp:

Control a Lamp Remotely Using the ESP8266 WiFi Chip

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:

https://github.com/openhomeautomation/esp8266-relay

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:

Control a Lamp Remotely Using the ESP8266 WiFi Chip

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:

Control a Lamp Remotely Using the ESP8266 WiFi Chip

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.

What about you, already built projects using the ESP8266 that are similar to this one? Please share in the comments!

Want to learn more? Get my free eBook about the ESP8266!
The ESP8266 is an amazing WiFi chip that you can use to build all sorts of projects. Download today my free eBook "Build a WiFi Weather Station with the ESP8266". Simply click on the button below!

Leave a Comment

Please enter your name.
Please enter your email.
Please enter your comment.
Jamie a year ago
Hi Marco, I would love to try this, but my country uses 220V. Is there a suitable relay that you can recommend?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
pankaj jain a year ago
how many relay switches can be controlled with single esp8266
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz pankaj jain a year ago
As many as the number of available pins on the ESP8266 :)
Harpreet Kaur a year ago
Is the anyway to integrate the existing dumb electrical wall switches that we have in home ?? Like I want the option to control the light via an app but also if someone uses the electrical switch to turn off and on. Unlike the push switch these electrical switches shorts the pins unless turned off and as a result the app fails to turn control the light.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Mick Harpreet Kaur 3 months ago
You could use a single pole changeover relay connected to the esp2866 o/p pin and use a two way (changeover) light switch?
Santhosh Kumar .R a year ago
I need to change the state for 4 bulbs and one fan, the fan speed will be controllable through the slider or 4 mode buttons.So i ned 4 more buttons and slider/button for speed control.....How do i create those!!!Can you please help me with this!!!!!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Willi a year ago
I want 2 esp8266 12e modules should be connected as server client configuration and gpio's of both modules should be controlled with one android app
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Carlos del Gato 2 years ago
As of yesterday, it has become an off-the-shelf solution to use any of ITEAD's products - with the update of the eWeLink Smart Home app. And ALEXA discovers the devices now so it is as simple as asking to turn on or off by name. COOL. All of our SONOFF units are now working with the Echo perfectly.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Gregory Carlos del Gato 4 months ago
You are not telling the whole truth -you must be from Marketing. ITead and Alexa (et al) need a massive extra infrastructure to be able to switch a light on. Marco's admirable solution here does NOT use the internet. So it wins. FO Clouds.
Tony Knors 2 years ago
Hello Marco, thanks for this great example ! I am a newbie on ESP8266 and REST but have some experience with Python, Raspberry ... I was trying to make a few simple changes like adding additional buttons to control additional ports. Simply done by adding a rest.button(6), rest.button(7) ...but .. How can you put "text" in between them so that you could have for example :Garden ON OFFKitchen ON OFF...All help is greatly appreciated !!!Kind Regards,Tony
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Hasan 2 years ago
i was work as this project but with current sensor(relay + current sensor ) , can you help me pls i have code but i dont know why dont read real value any one can you help me pls < my gmail. is : [email protected]
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Channa Ranatunga Hasan 2 years ago
Change the Baud rate to 115200.
Babar 2 years ago
Hi Marco,A very nice tutorial to begin with IoT.Can you please provide the browser part in HTML instead of JavaScript ??
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Alex Hs 2 years ago
Hallo Marco,how would you set an Analogvalue in order to meassure the temperature and see it through aREST. I put in setup: pinMode(0, INPUT); float temperature = analogRead(A0); rest.variable("temperature",&temperature);But it meassures only once, doesnt refresh the value from the A0. thank you - mercy - dankewas soll ich machen? :)
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Gaurav Bansal 2 years ago
hi marco,i bought your book IOT with esp8266, i want to deploy my own cloud server, but i am getting errors, while performing mup initi get no mup.json instead mup.js.pls help
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Ronald Gladney 2 years ago
I have discovered a problem with the ArestUI example 'ESP8266'. It includes:while (!client.available()) {delay(1);}rest.handle(client);I have been having a problem with esp8266 wifi switches while using this code. Occasionally my modules would become non responsive until I unplugged them and restored power to them. During troubleshooting I installed a Serial.print() command inside this while loop. Using Chrome I started repeatedly refreshing the screen (http://192.168.1.182) and found that about one out of every 10 to 15 refreshes, the module would get locked into this while loop. I have temporarily resolved this problem by using a millis() counter to force a return if this loop continues for greater than 130 milliseconds. I plan to use130 ms in all my WiFi switch sketches unless a better solution is available to solve my problem.I am sending http commands to the esp from my home network with the esp configured as a server on my network. There are no communications across internet. I was using Chrome to send page refreshes to the esp when I discovered I was getting trapped in the while() loop.Please review how this while() function interacts with ArestUI. I am not a fan of while() commands because they typically do not have any error checking and lead to the problem I have been struggling with. I also tried increasing the delay(1) time incrementally up to a delay(250) and still observed getting trapped into the while().After further testing I have found that the problem only occurs when using Chrome (public mode) on PCs or Android tablets. If I use Chrome incognito or Explorer (public or private) the ESP8266 does not get trapped in the while loop. In my case the 130 ms delay is about right. When I removed several debug (serial.print statements) I found I could not decrease the time below ~130ms to keep the ESP talking to Chrome. GitHub has an open issue post about "TCP RST not handled? client.connected is true but client.available is false" that may be related to my problem, but they say the problem exists with both Chrome and IE and I only see my problem using Chrome (public). My phone uses Safari and I have never observed a code lockup while accessing the modules thru Safari. Using Serial.print inside the while() loop I confirmed that Safari does not cause the issue.I am not sure if the problem is caused by ESP firmware or by the ArestUI, but, in either case it is very repeatable and will impact ARest users if they use Chrome. The ESP8266 I am using were supplied by Itead under the design styles “Sonoff” or “Sonoff S20”. The designs are electrically about the same, but, the Sonoff S20 has an integrated wall plug/socket for ease of use.I am now running 6 WiFi ESP8266 remote controlled switches with my code to abort the while loop if it continues for more than130ms. They are being sent a turn on command and a turn off command once a day. I have previously tested one module with about 200 refreshes using Chrome (public mode) without any while() loop lockups occurring.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Kanstantsin Bucha Ronald Gladney 2 years ago
Found same issue using chrome on MacOS. For me Locks occured only when I use custom functions like /digit/0/1 and more frequently when I send something weird like this /led/1 instead of that /led?params=1
Jacques Norris Ronald Gladney 2 years ago
Maybe try this:https://github.com/esp8266/...it's made from an example Code from here:https://github.com/esp8266/...
malecos 2 years ago
Hi, Marco! Great project!Maybe you could help me with one question.I'm using this project to control a lamp. I'm using a relay board between ESP and the lamp.The default position of relay is N.O. (normally open), and this way the lamp stays off.When I click the ON button, relay switches and lamp turn on. The lamp stays on till I click the OFF button.The problem is:I lamp is ON and power failure occurs, relay come back to normally open state and the lamp turns OFF. So far, no problem, because if there is no energy the lamp will not bright at all. However, when energy is restored ESP do not switches the relay to his last state. The relay stays in the normally open state and the lamp does not turn on till I click ON button again.I would like to save the relay state on ESP memory and when the module restarts it use this saved status to decide about the relay operate.Can you help me with this question?Thanks and sorry poor english!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Jaric Sng malecos 2 years ago
You will need a latching relay.How Is a Non-Latching Relay Different from a Latching Relay?A latching relay stays where it was when the circuit was last powered. If it was in an NO position while there was power flowing, it will stay in that position if the power is removed from the circuit. If it was in an NC position, it will retain that state if the power is removed from the circuit. These devices can have one or two coils in them.A non-latching relay, by contrast, goes back to its normal position when the power is removed from the circuit. This small difference means a lot in terms of the applications that this device is suitable for. Notably, these relays automatically return to a known state if the power is removed from the circuit. This is useful if, when a piece of equipment is powered down, it’s necessary to know the state of some of the relays on the apparatus before it is powered up again.Outwardly, these devices quite often look very similar. They are usually designed with either plug in or PCB mountings on them and there are many different variables that dictate which one is right for any given task.reference : http://uk.rs-online.com/web...latching relay: https://www.adafruit.com/pr...non latching relay: https://www.adafruit.com/pr...relay to handle more power: https://learn.adafruit.com/...
David A Riewe 2 years ago
Well done tutorial Marcos!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz David A Riewe 2 years ago
Thanks!
ami 2 years ago
Hithank you. this works well, is there another way to open the page without IP something like DNS that enter a address and direct to the esp IP.sorry for my English.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Ganicus ami 2 years ago
Just mount a dns server with the ip's that u'll use and done. If u want to enter to the site at outside of your house, you can deploy your app to a public server, or buy a domain to your IP and mount a server in DMZ (please do hardening to that server if you're going to set up one), with that you can access from anywhere to the app and turn on or off your lights or another device available in the app.Peace ;)
Dinesh Madushanka 2 years ago
hello Marco,thanks for the tutorial and I want to control many lamps using many ESP8266 Serial Wireless Transceiver modules. can you please tell me how I can switch all the modules using single web page. Please.....
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Praanesh 2 years ago
hello Marco I am currently doing this WiFi project can u please tell me how can i connect this module to an android app rather than a web page? Please help me in this.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Ronald Gladney 2 years ago
Have you considered tweaking your project so it runs on a Itead Sonoff switch? The beauty of this product is it is an esp8266 module with power supply and relay output in one box and you connect an AC power cord on one end and an outlet for the lamp on the other end.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Ronald Gladney 2 years ago
I think that would work nearly out of the box :)
clo 2 years ago
...and one more problem. How can I set interval for "on" button? I wont set time, after pushing "on", will set to off. For example, after 5 seconds.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
clo 2 years ago
Hi,Program works, but I have problem. When I switched relay by mobile, I can't switch relay other phone, notebook etc. Why? Can I connect more that one client?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
L.D. Taylor 2 years ago
Marco, I'm using an ESP8266-12E board. After customizing your code to fit my network, I was able to switch a relay on and off once. Since then I get the following errors:Memory loss before reset: 4294926712; Memory loss after reset:0, Memory free: 40584; Memory loss before reset:184; Memory loss after reset:0; Memory free: 40400; Memory loss before reset: 0; Memory loss after reset:0; Memory free: 40400. Any ideas on how to adapt your very fine project to the ESP8266-12E? Thanks for any help!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz L.D. Taylor 2 years ago
There are known issues with the ESP-12E & aREST, working on it :)
Luis Pablo Salvay 2 years ago
Hi Marco , I've managed to install and run the example in a esp8266-01 but the question I have is how I have to configure the control panel to activate or deactivate the gpio0 or GPIO1 since I have selected "digital" "1" turns on and off the blue lED on the esp8266 but I do not activate the relay.Very good project !! I hope someday I can make an api like this !I can ride your own project on your own server ? and make it work somehow?Thank you so much for everything!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Luis Pablo Salvay 2 years ago
Hi Luis, for now I am aware that aREST is not compatible yet with all ESP8266 boards, but I am working on it :)
K790 Luis Pablo Salvay 2 years ago
Hi Luis, the ESP8266-01 does not have a GPIO1, this only have GPIO0 and GPIO2.
vasanth rajaec Luis Pablo Salvay 2 years ago
hi, i flashed the program on to my ep8266-01 but once i put my ip address on my brouser its not working any corrections regarding esp8266-01
Shyam 2 years ago
great work, how can i add one more title or subtitle and put two or more control interfaces on UI ? lets suppose i have 3 devices to be controlled, i need the UI to show 3 devices names, when i tried with set.title it overwrites the previous titles
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Lennyz 2 years ago
Can you also use a simple relay module instead of using the "PowerSwitch Tail Kit" if I power the ESP8266 using the power supply?Is the only benefit of using the Powerswitch that you can draw power directly from the Powerswitch to power the ESP8266?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Lennyz 2 years ago
Of course! You can use the tutorial and apply it to any output you wish :)
aakash salvi 2 years ago
hi marco ..great work man ..i have implemented home automation at wifi network ...can u pls help me out with a tutorial for home automation outside wifi network through android app..once again man i really appreciate your work and contribution to esp8266 community ..thanx in advance.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz aakash salvi 2 years ago
Hi! Thank you :) Noted, I'll make more tutorials with Android!
Bill Mulligan 2 years ago
How are you controlling a 30 watt lamp with this setup? The info listed on amazon for the PowerSwitch Tail Kit indicates that it is only capable of switching up to 15 watts.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Jamie Bill Mulligan 2 years ago
The specs state 15 amps so its capable of switching 15a x 120v = 1800watts
Marco Schwartz Bill Mulligan 2 years ago
The official page says: Switching capacity: 15amps @ 120vac. So no problem for a 30W lamp :)
Gnu 3 years ago
I haven't seen a switch button in the aRestUI, it would maybe be easier as you would only have one button and you would also know the state of the lamp (if it's turned on or off).
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Gnu 2 years ago
Good suggestions! I marking that on my to-do list
Pradheep Krishna 3 years ago
Hey,Hope you are doing fineActually I have a problem with ESP8266! I'm not able to initialise the module. The serial monitor displays:Cannot initialize No wifi shield found and Time out !Do you want me to share the program also ? Will be glad if You can help me out ! Thanks a ton
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Pradheep Krishna 3 years ago
Hey! If you have this message, probably you didn't select the ESP8266 as the target. See this page to add ESP8266 support to Arduino: https://github.com/esp8266/...
moza 3 years ago
Hi Marco! Can you please tell me what type of output the ESP8266 chip gives? is it like a simple logical 0,1 on the pins we assign or some other type, when you press the buttons ON and OFF remotely through the browser.ThankYou :)
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz moza 3 years ago
Hi! It basically returns the same JSON answer as in the aREST library, see: https://github.com/marcosch...
tobias 3 years ago
Hi Marco, nice work! I made it, works very good, but sometimes it hangs. You suggested using WDT, but please help what should I write in the script, because I tried a lot of things, but no success. The other problem is that the ESP server's security mode is none, so my neighbor can enter and switches off my lamp :-)
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz tobias 3 years ago
Hi, thanks! It's a known bug with the ESP + aREST, I am working on the issue :)
Marco Schwartz tobias 3 years ago
For your neighbour's issue, they can't access it if they are not connected to your WiFi network!
Jason Brown 3 years ago
Hey Marco, so i have this running on a esp-01 and im useing both gpio pins but the server hang's after like 9 mins or so and no clients can connect to it.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Jason Brown 3 years ago
Hi Jason, if you have problems like this I recommend using the ESP watchdog feature to automatically restart the chip in case it hangs.
John 3 years ago
Hi Marco, well defined info... thanks for this. Actually I have made a RF controlling remote to control my local RF based devices (433 Mhz module) with ESP8266 it is working fine on my local wifi network with local IP like http://192.168.1.1/swith1/0 or 1. Please suggest how it can be accessible from cloud. I m using a dongle based wifi router which doesn't have port forwarding mentioned in its UI.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz John 3 years ago
Hi! Not with the code of this tutorial, but make sure to check this one out: https://www.openhomeautomat...
Akeda Hosten 3 years ago
How would I use this set up but for a web page i've designed on my own?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Akeda Hosten 3 years ago
I recommend checking the aREST documentation: https://github.com/marcosch...
moussa M 3 years ago
thanks for all this information and this great presentation . but i have a question , can i use another shield wifi ? for exemple MRF24WB0MB ? how i configure it ? ....i'm waiting for your answer
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz moussa M 3 years ago
You could, but I don't see why you would need it as the ESP8266 already has WiFi :)
Vinter 3 years ago
Great project! Is it possible to switch the logic for the buttons? So that the "On" button cuts the power to the lamp?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Vinter 3 years ago
Thanks! So far that's not an option in aREST UI but that's an interesting suggestion!
Denise Angeline Pantig 3 years ago
Hi! Can this work with Arduino Uno, ESP8266 Wi- Fi Module, relay module and without the powertail kit or current sensor?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Denise Angeline Pantig 3 years ago
Not really, the sketch would be too big for an Uno :(
Adrian 3 years ago
Hi Marco thank you for share your proyect.Is it posible to use with the esp8266 modelo ESP-01 ? Can you share the circuit ?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Pen serey otdom 3 years ago
we can use to control lamp 220v or not ?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Pen serey otdom 3 years ago
Sure! You just need the right PowerSwitch Tail kit
HBI 3 years ago
I like the idea and simplicity of having the web interface directly on the microcontroller without the need of a separate server-side files or scripts. I would like to use this concept on a Spark/Particle core. Can I use the aREST UI library also on this board? Has anyone done or tried that? Can it be ported to the Particle IDE?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz HBI 3 years ago
Thanks! Never tried it myself so far. Also note that currently aREST UI still requires a working web connection to grab jQuery & Bootstrap from the Internet.
Gabor Szakacs 3 years ago
Has anyone figured out how to resolve the issue with the ESP8266 not responding to REST calls ? After 20-60 minutes the rest calls fail, but the device is still responding to ping. Any ideas ? I understand that reset may fix this issue, but how do you implement the reset function ? Thanks
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Vleis Walker 3 years ago
Hi MarcoThank you for all your efforts with the ESP8266.I have bought all your books regarding Home Automation, but ran into the following error......section attribute cannot be specified for local variables const char PROGMEM *p = (const char PROGMEM *)toAdd;I am on Win7 X64 and uses Arduino IDE 1.6.5The aRest library was installed through the Library Manager.What am I doing wrong?Kind regardsVleis Walker
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Vleis Walker 3 years ago
You're welcome! Hum, this is something that should have been fixed a while ago. Make sure to upgrade to Arduino 1.6.7 and also make sure the version of aREST is the last one (2.0.1).
Hieu Nguyen 3 years ago
Do you know why esp8266 shutdown when I plug in 220v to relay?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
NovaKasy Hieu Nguyen 3 years ago
There so many reasons this could happen, the most obvious would be that the relay does not provide good isolation. Others could be that a spike in the supply causes the ESP8266 to reset or the magnetic field of the relay is upsetting your circuit. I usually connect and power everything up before I power the ESP8266. This way all the surges and spikes are gone before the ESP8266 boots up.
soumil nitin 3 years ago
thanks program was uploaded succesfully but i dont see any ip in serial monitor instead any garbage value baud rate 115200what should i do sir
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
soumil nitin 3 years ago
please hep me i downloaded the code its showing me arest no such file or directory foundBuild options changed, rebuilding allESP8266.ino:10:19: fatal error: aREST.h: No such file or directorycompilation terminated.Error compiling.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Kenneth Arevalo soumil nitin 3 years ago
first install arest.h in your lib folder then compile
Marco Schwartz soumil nitin 3 years ago
Looks like you missed the aREST library :) Make sure to install it using the library manager.
Romaw 3 years ago
I have doit ESP12E board with Arduino v1.6.6 environment. When I first open the server website from my phone I can switch on and off the LED once. Then everything stops and will start working again when I close and reopen the website again. Does somebody have a solution or have the same problem?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Romaw Romaw 3 years ago
Problem is maybe caused by caching internet pages by MS internet explorer.Using Chrome or Firefox everything works fine.With MS internet explorer I can switch LED on and off once and then everything stops.
Ultraread 3 years ago
Very nice Marco...I succeeded from the first attempt on my ESP8266-01 on GPIO 2 .....It works fine from the desktop computer, but there is a problem on my Windows phone.I can see the page and buttons but can not turn it on or off (maybe ones in 50 attempts)Any suggestion.Thanks for great work.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
joey babcock 3 years ago
anyone know how i might go about adding GET request support to this? something like 192.168.0.1?state=1 would turn it on and 192.168.0.1?state=0 would turn it off? I tried to find something in the wifi library but i couldnt...
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Sven 3 years ago
Kudos on this! The ESP is a powerful but confusing device for many, so many firmware and programming option, this one is clear and simple yet powerful even given the restrictions of the UI.One odd thing I am experiencing though is that I get garbage on serial monitor and a failed server start when I have GPIO2 of an ESP01 module connected to relay. If I disconnect the GPIO pin (still have power pins to relay connected) and then boot, connect the GPIO pin after boot all works fine. I am using a generic 2 relay breakout module with no out puts connected.Any suggestions?
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Sven 3 years ago
Thanks! Hum strange, I actually only tested this with the PowerSwitch module. Maybe the relay is interfering with the behaviour of the ESP8266. Make sure you have a protection diode on your relay to prevent current coming back to the ESP8266.
Srki 3 years ago
Great tutorial.I have one problem. After a time period (couple of hours) I cant open the IP any more. I can see on my router that it is still connected but i cant access the UI. Any help would be great.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Marco Schwartz Srki 3 years ago
Thanks! That's unfortunately a well-known problem coming from the ESP8266-Arduino software. Try add to code to automatically reset the board if needed.
Shares
Control a Lamp Remotely Using the ESP8266 WiFi Chip Control a Lamp Remotely Using the ESP8266 WiFi Chip Control a Lamp Remotely Using the ESP8266 WiFi Chip Control a Lamp Remotely Using the ESP8266 WiFi Chip Control a Lamp Remotely Using the ESP8266 WiFi Chip Control a Lamp Remotely Using the ESP8266 WiFi Chip
Someone from Egypt
Recently signed up
5 days ago
Someone from the United States
Recently signed up
12 days ago
Someone from France
Recently signed up
15 days ago
Someone from Netherlands
Recently signed up
23 days ago
Someone from Moldova
Recently signed up
24 days ago
Someone from Oman
Recently signed up
a month ago
Someone from South Africa
Recently signed up
a month ago
Someone from Belgium
Recently signed up
a month ago
Someone from France
Recently signed up
a month ago
Someone from United Arab Emirates
Recently signed up
a month ago
54 people recently viewed this page