Home Automation using ESP8266 on LUA

Robo India presents tutorial on how make HTTP server of ESP8266 wifi module in both station and access point mode. This server is being used to automatic control of LEDs. This tutorial can be implemented to automate home or industry.

Detailed Tutorial

1. Introduction:

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.

1. This tutorial explains configuration and setup of ESP8266

2. This tutorial explains basic of ESPlorer.

2. Circuit

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.

You may download this init.lua file from here.

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 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


4.1 LUA code:

LUA code for the above mentioned operation is here.

You may download init.lua file from here.

Rest of the things are as same as in the upper part of the tutorial. Just remember that is the IP address to access ESP8266 in this mode.

If you have any query please write us at

our whatsapp helpline: whatsapp-logo-robo-india +91 9694011188

Thanks and Regards
Content Development Team
Robo India

Related Tutorials
LED Blinking using ESP8266 by LUA

Robo India presents tutorial on LED blinking on ESP8266 wifi module by LUA.

ESP8266 Connecting to Internet

Robo India presents tutorial on connecting ESP8266 wifi module to internet.

NodeMCU Amica Installation - ESP8266 Based Development Board

Robo India presents tutorial on how to install NodeMCU Amica, ESP8266 wifi module based development board.

Robo India Tutorial portal

Illustrated tutorials and guides.

Feel free to contact us

© Robo India |