This tutorial explains how to turn your ESP8266 in to a web server. This web server can be accessed in both mode station and access point. We are controlling two LEDs through this tutorial. As ESP8266 is a wifi module so by this tutorial you can control any appliance of your home wirelessly using any wifi based device may be a smart phone, tablet, computer or laptop.
You need to have basic understanding of ESP8266, below mentioned tutorials of Robo India may help you out in this.
Additional to the basic setup circuit you will need to connects positive legs of LED to GPIO 0 & GPIO 2. And the other negative legs of LEDs are to be connected to GND. Beacuse ESP8266 works on 3.3V so its OK to connect LEDs without resistance in series. It you want to use resistance with LED, you may use them.
3. ESP8266 web server in station mode:
In this mode ESP8266 will be connected to the existing wifi network. On the serial port you can see the IP address allocated to the ESP8266.
You can control LED connected to ESP8266 from any of the device connected to the network as shown in the above image.
3.1 LUA Programming:
Upload the following init.lua file to your ESP8266 after entering your wifi name and password. Reset your ESP8266, init.lua will be executed after reset. The ESP8266 will try to connect to the wifi network. Once it is connect you will get the IP address allocated to your ESP8266 on the response window of the ESPlorer.
As you can see the response window it showing how ESP8266 connected to the wifi network and what IP has been allocated to the ESP8266.
Our ESP8266 gets 192.168.1.6 IP address. Now from any other device connected to the same wifi network open this IP address using any browser of that device. You will be able to control LEDs connected to the ESP8266.
This tutorial turns your ESP8266 in to a web server that is being accessed in a station mode. The server will respond in the following manner.
These four buttons control LEDs.
4. ESP8266 web server in Access Point mode:
In this mode ESP8266 will be an access point, once you upload init.lua file to the ESP8266 and ESP8266 restarts after that, you will be able to see ESP8266 as available access points from other devices. connect to this. and go to the following IP address 192.168.4.1
4.1 LUA code:
LUA code for the above mentioned operation is here.
Rest of the things are as same as in the upper part of the tutorial. Just remember that 192.168.4.1 is the IP address to access ESP8266 in this mode.
If you have any query please write us at firstname.lastname@example.org
our whatsapp helpline: +91 9694011188
Thanks and Regards
Content Development Team