Categories

Tutorial

ESP8266 Connecting to Internet

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

Detailed Tutorial

1. Introduction:

This tutorial explain how to connect to internet using ESP8266 wifi module by LUA Programming.

1.1 Prerequisites:

1.1.1 Basics of ESPlorer and ESP8266: This tutorial explains basic of ESPlorer.

Connect RX and TX pins of ESP8266 module to the Serial Port of you computer, if you don't have one in your computer, FTDI or CP2102 can be used.

connecto-to-internet-logic

3. LUA Programme:

The following  LUA code will be required to connect ESP8266 wifi module to internet. Download this init.lua file. Open it and write your Wifi Access Point Name and security key in it. Save this file and upload the same to your ESP8266 wifi module.

You may download init.lua file from here.

wifi.setmode(wifi.STATION)
wifi.sta.config("AP_NAME","SECURITY_KEY") -- Replace with your AP Name and security key.
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("Obtaining IP...")
else
tmr.stop(1)
print("Got IP. "..wifi.sta.getip())
end
end)

4.  Explaining programme:

This code is written in init.lua so as your ESP8266 wifi module starts up this code will be executed. In this code the ESP8266 is working in station mode. It connects to the wireless access point provided by you. The we have created a timer of one second duration that timer is to obtain IP address. This timer runs till it get IP address. Once the ESP8266 module obtains IP address the timer stops. Obtaining IP address means that your ESP8266 has been connected to the Access Point Provided by you. If the access point has got access to internet your ESP8266 is connected to internet.

esp8266-connect-internet

If you have any query please write us at info@roboindia.com

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

Thanks and Regards
Content Development Team
Robo India
http://roboindia.com

Related Tutorials
Logic Level Converter

Robo India presents tutorial how to use logic level converter. While interfacing with sensor or other electronic device logic level converter is required, if one device works on 5V and other on 3.3V and both have to communicate than this logic level converter will be required between them.

ESP8266 Wiif Module Setup

Robo India presents tutorial how to setup ESP8266 wifi module. Hardware configuration to run ESP 8266 wifi module is explained in this tutorial.

ESP8266 Flash with NodeMCU firmware

Robo India presents tutorial how to flash ESP8266 wifi module with LUA firmware. NodeMCU firmware is used here.

Starting with LUA on ESP8266 Wifi module

Robo India presents tutorial on starting with LUA on ESP8266 wifi module and ESPLORER.

Robo India Tutorial portal

Illustrated tutorials and guides.

Feel free to contact us

© Robo India | http://roboindia.com