Introduction: Using the ESP8266 Module

Picture of Using the ESP8266 Module

This Instructable will teach you how to use those $5.00 ESP8266 modules, as well as provide you some basic knowledge about networking. I'll be using the Micromite Companion Kit in my examples which is programmed in BASIC, however all of these instructions should be adaptable easily to your favorite micro.

In short, the ESP8266 module is a TTL "Serial to Wireless Internet" device. Providing your microcontroller has the ability to talk to a TTL serial device (most do) you'll be in business! The original instructions have been translated from Chinese into cryptic data sheets. We'll try to change that with this Instructable.

The ESP8266 module is a 3v device, but it's no wimp. It draws quite a bit of power. In fact, you'll probably need to make sure that your circuit's power supply can handle at least 1 amp of power. (In my case, I was using a simple 7.5v 500ma power supply. When I started working with this module, I switched it for a 7.5v 1amp power supply and had plenty of power.) As it turns out there is good reason for this; some Youtube videos have surfaced recently with folks seeing anything from 500 meters to a couple miles of transmission capability from this module. That's a lot of horsepower for $5.00!

Step 1: Obtaining and Preparing Your 8266 Module

Picture of Obtaining and Preparing Your 8266 Module

I obtained my module from an Ebay vendor in the United States. The shipping was faster than China, but more importantly, the vendor provides the module without the pins soldered in.

The 8266 module isn't really breadboard friendly, but it's easy to convert it to a four pin module if you purchase the pin-less version. (or take a few minutes to remove the pins if you have obtained the other version)

You'll need 5 pin connections to make the module work. (See image 1)

RX, TX, ground, and 3v connected to two positions on the module.

I sourced a 4pin female cable from my parts box and cut off one end.

I used a small amount of nail polish to carefully paint over the unused pin, then looped the 3v connection from the power pin over the unused pin into the center. (See image 2)

The end result is a 4pin module that is now breadboard friendly to plug into your project.

Step 2: Hooking It Up

Picture of Hooking It Up

Once you have the module adapted, now make the four connections, (RX,TX,3v,Gnd) to your microcontroller. I've breadboarded mine to my Micromite Companion which is using the Micromite chip (created by Geoff Graham) running BASIC. The Micromite has multiple serial connections, and a console which I'm using as my interface to the 8266 module. You could even connect the module directly to your PC if you have a TTL-Serial-to-USB adapter. (Don't try to connect the module to a PC serial port directly, you could cause damage to the module or the your computer!)

The correct connections to the Micromite Companion (Micromite) are RX to 21, TX to 22.

The default baud rate settings are 115200,N,8,1

Next, you'll need to use a terminal program to program the unit.

I've written the following BASIC terminal program for the Micromite:

  • Open "Com1:115200" As #1
  • terminal:
  • a$="" : b$=""
  • a$=Inkey$
  • If a$ <> "" Then Print #1,a$;
  • If Loc(#1) >=1 Then b$=Input$(1,#1)
  • char = Asc(b$)
  • If char >31 Then Print b$;
  • If char =13 Then Print " "
  • GoTo terminal

Step 3: Configuring the 8266 Module

Picture of Configuring the 8266 Module

You'll need to configure the module for your wireless network.

You should already know your wireless SSID and password, as we'll need those next!

From your terminal, type AT and press enter. If you get a cheery OK from the module, you have have accomplished a big step in this Instructable!

Next, type AT+RST and give the module a moment to reset. You'll see a paragraph of data returned.

Type AT+CWMODE=3 to set the module as both a client and an access point.

Don't worry if you make a typo in the process of doing these commands. (There's no backspace) Just hit the enter button and enjoy the broken English error message and retype the command.

Next, let's see if we can see your wireless router. Type AT+CWLAP and enter. You'll see something like this.





See your access point? Type the following command, replacing SSID and password with your information.


Congratulations! Your module is configured for your network.

Now we need to see what IP address has been assigned to it.

Type AT+CIFSR and press enter. Your module's IP address should be displayed.

Step 4: BASIC Networking

Picture of BASIC Networking

Ok, we've lost about half our audience at the end of the last step. If you are still reading, it means that you have a working module, but need some guidance in the world of networking. Don't worry, you are in good hands. I'm going to condense a semester of networking classes (I used to teach CCNA) into just enough networking knowledge to be really dangerous. Sound like fun? Read on!

So you have the IP address that was displayed in the last step of the last page. (Did you write it down?)

Now what?

I'll assume you are at home with a wireless router somewhere in your home. It's probably connected to either a cable modem or DSL adapter. It's even possible that you have a single device which is doing both jobs. This device is the gateway to all of your internet travels, even the Instructable you are reading!

Your home network has a private side, and a public side. The private side of your network is all of the computers and devices which are connected to your wireless router. They can be wired to it's ports, or connected wirelessly.

You actually got a BIG CLUE to how the private side of your network is configured by the IP Address you were given to your module. Mine was

Take a look at those first three numbers.. 192.168.1

Those are the private side of your network. You might have 192.168.0 or even 10.0.0.

All of your computers and wireless devices on your network have an IP address that starts with those three digits.

It's that last digit (20 in my case) that determines the full address of each connection.

Each of your devices will have a different last number. Your wireless router probably uses 1.

The neat part about the private numbers is that typically there is room for up to 254 different devices and computers on your network right now! Talk about a LAN party!

Take a look at the image above.

Remember when I said that your wireless router has both a private side and a public side?

Your router receives a live IP address from your Internet provider. This address is unique to the entire world, and it's very important that it is! The wireless router actually contains two addresses. One is the private side, the other is the live IP address which is visible to the world. Don't worry, your router is designed to be the gatekeeper, controlling your web requests from your devices and keeping the bad guys out of your computers. The truth is, those private IP addresses are not visible from the outside world. (Unless we want them to be, keep reading!)

Step 5: Communicating With the Module

Picture of Communicating With the Module

Let's take a break from networking class to see if your little 8266 module is able to communicate with your network. An easy way to do this is using the PING command.

If you are using Windows:

Click on Start, Run, and type CMD and press enter.

Type IPCONFIG and press enter.

Type PING and the IP address of your module. (I typed PING

If you are using Linux:

Open a terminal window

Type IFCONFIG and press enter

Type PING and the IP address of your module (I typed PING

I've circle two pieces of information in my image. The first is the IP address of the computer I'm working at. (This is always good information) and the second is the IP address of what I actually PINGed. Did you catch me PINGing my wireless router? Good eyes! Ping your router as well as see if it answers. It's usually .1

A successful PING request will always return a set of numbers like mine did. If you get "Request Time Out" messages it means that something isn't communicating.

Step 6: Running a Simple Webserver in BASIC

Picture of Running a Simple Webserver in BASIC

If you've gotten good PING results from your module, you are ready to start experimenting!

Let's start with a really simple web server written in MMBASIC. If you are using another micro, the BASIC program should be very easy to read and convert to your language.

Type in the little program and RUN it on your Micromite Companion.

If you are using a terminal program connected to your 8266 module, take note of the following commands..


These two commands set up the magic to make the module automatically answer a request from another computer or device. In my case, I've configured the module to answer web requests on port 80.

Typical ports are as follows:

  • 80 = Http web requests
  • 8080 = Http web requests on networks on which 80 is blocked
  • 23 = Telnet (text terminal) requests

Once you've run the program, open a web browser and type the address of your device (mine was into the web address bar. That place where you've typed

The module seems to handle all of the formatting of the required HTML headers your web browser is looking for, so you can blast data directly. (At a reasonable speed of course!)

Step 7: Inviting the Internet

Picture of Inviting the Internet

So you can communicate from your web browser, your phone, laptop, or other Internet capable device to control your projects. I'll bet the ideas are already churning!

What if you want your friend in Ireland to control your project as well?

What if you want to control your project from somewhere other than your home network?

Those private IP addresses are only good while you are inside your own network.

It's time to talk about public address and something called router "Port Forwarding".

First, you need to know your router's public Internet address. It's easy to find. Simply point your web browser at are you be given your live IP address. (See first image)

Next you'll need to configure your router to allow requests from the outside world into your network and provide it a "rule" to allow certain traffic to your wireless module. This is called "Port Forwarding".

Remember when i said that I PING'd my wireless router at .1 to find it's address?

Open your web browser and type the address of your wireless router into the address bar.

(Usually, it's or depending on your network, but you should know it now.)

The router will respond with a login/password response. Unless you have re-programmed it, (Most people haven't) it will accept admin and password. (Don't worry, your router doesn't allow folks from the Internet to program it by default!)

Here's the tricky part. You'll need to dig, (usually in the "advanced" menus) for something called "Port Forwarding" or "Forwarding". All routers are a little different, but don't be afraid to poke around. You aren't going to hurt anything.

Take a look at the 2nd and 3rd images. They are great samples of some common routers.

Once you found it, you'll need to add a rule with the following information:

The External Port# you want to use with your device. Most of the time, you'll use either 80 (if you want to provide web access) or 23 (if you want to provide telnet "text" access). Just use the same number twice as you see in my examples. Some routers will also ask for an Internal Port# as well. Again you can use the same numbers twice again. Finally, give the IP address of your device. (Mine was

Once you've established this rule in your router, your device is now accessible from the world! From outside of your network, you can use your "live" IP address to access your 8266 module.

Step 8: Closing Notes

Picture of Closing Notes

Remember when I said you'd get enough networking information to be dangerous? Welcome to the fun.

A few notes:

First, some Internet providers, in paticular cable providers don't like to give you the ability to use the common lower port numbers (like port 80, or 23). They will claim that doing this is a violation of their service (nonsense!) or that they are protecting you by blocking these ports. (hog wash!)

If this is the case, just us higher port numbers, like 8080 or 2323 (or just make up a higher number you can remember easily.) Just add it at the end of the web or telnet request to make it work.

Also, from time to time your "live" IP address can change making it impossible for you to reach your project until you go back home and look up the new address with There is a great, free service which you can subscribe to called DuckDNS ( ) which will give you a name on their server and a little tool to run on your PC which will keep track of the changes. Instead of using the IP address, you'll be able to use {yourname} It really works well!

Need more help?

Drop over to our friendly forums at Propellerpowered and post up!


KashyapA4 (author)2017-12-01

How do you open up this to the internet when you have more than 1 esp in your network.

JanithaP1 (author)2017-09-10

Hey! Can I Use this module to send high speed data to a machine!!!

CraigM159 (author)2017-07-19

Great tutorial, thank you. Its just what i was looking for, for one of my projects.

hkumar9 (author)2017-06-15

great tutorial

ojasb1 (author)2017-06-11


I am using my esp8266 in AP mode and I want to allow only specific devices to connect to my esp for security reasons. So how can I give a specific id to my devices other than setting a password for my esp in ap mode?

guycs (author)2017-04-09

Thank you very much for the detailed and knowledgable explanation.

I succeeded to connect my ESP but lost you on the part of using it as a server,

I don't understand where is the html response is being defined and what triggers it.

From looking at your terminal code I can see that ASCII 71 ("G") is calling the server sub routine but I don't see how it would run automatically while getting a client request

Any clarification would be appreciated,

1999aksy (author)2017-03-16

how to connect more than 1 esp8266 and read the corresponding rssi at same time??? Please reply ASAP.

GabrielC115 made it! (author)2016-09-17


Type AT+CIFSR and press enter. Your module's IP address should be displayed.

i got AT+CIFSR






If you are using Windows:

Click on Start, Run, and type CMD and press enter.

Type IPCONFIG and press enter.

Type PING and the IP address of your module

i typed and got a different screen from yours,

Windows IP Configuration

Wireless LAN adapter Local Area Connection* 2:

Media State . . . . . . . . . . . : Media disconnected

Connection-specific DNS Suffix . :

Wireless LAN adapter Wi-Fi:

Connection-specific DNS Suffix . :

Link-local IPv6 Address . . . . . : fe80::5462:3d11:7fa0:5a5a%7

IPv4 Address. . . . . . . . . . . :

Subnet Mask . . . . . . . . . . . :

Default Gateway . . . . . . . . . :

Wireless LAN adapter Local Area Connection* 12:

Connection-specific DNS Suffix . :

Link-local IPv6 Address . . . . . : fe80::e102:d273:cfe6:48d3%18

IPv4 Address. . . . . . . . . . . :

Subnet Mask . . . . . . . . . . . :

Default Gateway . . . . . . . . . :

Tunnel adapter isatap.{B47839E6-0F16-42F5-B42B-E4F611F3071B}:

Media State . . . . . . . . . . . : Media disconnected

Connection-specific DNS Suffix . :

Tunnel adapter Teredo Tunneling Pseudo-Interface:

Connection-specific DNS Suffix . :

IPv6 Address. . . . . . . . . . . : 2001:0:9d38:90d7:4d9:3d0a:3f57:fef6

Link-local IPv6 Address . . . . . : fe80::4d9:3d0a:3f57:fef6%13

Default Gateway . . . . . . . . . : ::

Tunnel adapter isatap.{62B05E0C-5222-40F9-9240-6BA9E8322691}:

Media State . . . . . . . . . . . : Media disconnected

Connection-specific DNS Suffix . :

so i do not know which one is my module.

i tried to ping and i got a signal but no internet access, please help? i feel i am close but i am also very very far away, please help thanks:)

ChristopheE3 (author)GabrielC1152017-01-07

APIP is the Access Point IP, that is, the IP used when your ESP is used as a router.

STAIP is the Station IP, that is, the IP used when your ESP is used as a client (kind of like your phone)

When you go on command prompt (CMD), since you're using Windows, try typing IPCONFIG then PING *STAIP*

That should definitely work. If that doesn't, then something has to be wrong.

GeeksTipsDotCom (author)2016-12-18

Also, if you use Arduino code to program the ESP, I highly recommend you to use ESP.config() and setup static IP, Mask and Gateway. In this way you will save some time and delay when connecting to your router or Access Point. ESP.eraseConfig() method can be used to clear the cache in the end.

Arduino tutorials

taifur (author)2016-12-15

Thanks, I have learned a lot from your instructables.

GeeksTipsDotCom (author)2016-12-11

Nice article, I've made an ESP8266 network in my house using 5 this modules.

Xiu Wen Song (author)2016-07-24

Hi, I am gonna use ESP8266 to build wireless tire pressure monitoring system and display on android? Any information to give me in order to facilitate my project? Thanks so much guys!


did u get any support on this ? We are also looking for similar product. Can you please tell which sensor you plan to use ?

OmarS127 (author)2016-11-09

any thread discussing ESP8266 and arduino ?

TamásS13 (author)2016-11-05

I don't want to make that much electro smog in my environmet. I need a range of say 10m only, no more.

Can you please suggest an IC with that range?

KhaledE39 (author)TamásS132016-11-06

using Bluetooth module would be about 20 m in range .., but if you would like to use networking without any signals on the air you can use Ethernet the module to use is "enc28j60"

GabrielC115 made it! (author)2016-09-17

i also got another query, i am connected to my singtel 5g but there is no ap on m y com port, can i ask why? thanks:)

dev1234bajaj (author)2016-09-16

this is use to host a wifi network or to connect a wifi network

abhay yelads (author)2015-12-30

Hi! I want to use esp8266 module as an normal wi-fi adpter to make my computer wi-fi enabled. Can i use this module.. Thanks in advance..

M.S4 (author)abhay yelads2016-06-03

Simple answer is no. But it is possible by a very complicated way. But why? U can purchase usb wifi adaptor for same price.

SamuelR66 (author)2016-06-03

i want to send and receive data between my esp 8266 and a web server,how can i do it?


AminA33 (author)2016-05-01

how to store an array with the set of values of rssi and can i send them back to pc p.s. u would save my semister :D?

sandeep.laik (author)2016-03-01

Very well written. Thank you. :)

gmeadows3 (author)2016-02-10

Brilliant - took a little of the mystery out of ip addresses for me. I've ordered a 8266 to try out now. Thanks for a very clear instructable

souhadl (author)2016-01-26

Hi. After connecting my esp-01's vcc and ch_p0 to 3.3V to the arduino and started the serial monitor at 115200 baud, i got the cheerful OK after entering AT and even the version info after AT+GMR but that's about it.
All other commands end up with ERROR. Tried toggling the baud rate but with same results.
Any thoughts?

priyam170 (author)2015-04-30

how can i make the esp's IP static(assigned by router,something like

leaosir (author)priyam1702015-10-15

If you want to change static address; this is the command at




drmpf (author)priyam1702015-09-06

check out this instructable for code to assign static, configurable IP for ESP8266

A Cheaper ESP8266 WiFi Shield for Arduino and other micros

sagaraute (author)2015-09-16

My esp8266 is disconnect to client app after some time when i use esp8266 as webserver.

sagaraute (author)2015-09-16

how to change IP address of esp8266???

AlessandroP (author)2015-02-19


I am working on a project with the ESP8266 and need to define requirements so I have different options. I want to use the ESP8266 Version 12 connected to Arduino to collect sensors data and communicate with a mobile app that sends these data to the cloud. So I am trying to figure out how to set the ESP8266 to talk to the mobile app. The mobile app would be like a bridge between the ESP/Arduino system and the cloud. The mobile phone can be set as tethering or portable hotspot via Wifi and connect to the cloud via 4G. Would like to have some suggestions for the best setup for the ESP8266/Arduino in this configuration?

drmpf (author)AlessandroP2015-06-02

I suggest setting the mobile as an Access Point and then connecting directly from ESP8266 to cloud. I will soon put up an Instructable showing how to use ESP8266-01 as a passthrough Wifi connection for Arduino connected via Serial (or Serial1)

P.S. Using the AT command set is asking for trouble (although I have a library that works, see


I am too working on this type project. Instead of arduino I am using Atmel8051. It will be very help full if you give me some information on the same. Thanks in advance

jmpm4619 (author)2015-05-16

Hi would you be able to assist in making a schematic with the esp8266?

bobbytaylor7 (author)2015-09-04

Thanks for sharing..

hjsalom (author)2015-08-31

Very nice. This article has made a lot of things clear to me. Thanks for sharing.

radames ajna (author)2015-01-30

hey, is it possible to set the it up as an access point? i.e make it discoverable by an SSID?

KevinC10 (author)radames ajna2015-02-04

Yes it is. I have 6 named GEOCACHE1, 2 , 3 and so on for various geocaches hidden in the area, I am working on some type of solar for the supply, was triggering by infrared to start the device, then moved on to solar. In ap mode , you can look at the wifi settings on your phone or download an app for range of wifi's and as you get closer to the geocache the signal gets better etc. This is the primary use at this time for me. I have 2 other controlling relays and am using another for rgb led mixing. The rgb color mixing I am going to expand to use on a mini remote control car , color mixing will be the control voltage for right, left and foward [ no reverse yet ] buffered off a 3 transisters. This is just for fun and where I am now. I had it connected to the web with no other interest. I am applying them to surge strips and out lets naming them outlet one, or TV or kitchen light etc using a different code to control the on off of each device, yes I know smartswitchs and plugs are out their but when you make it yourseld it is fun.

AnthonyP15 (author)KevinC102015-07-30

Kevin, what firmware did you use for configuring your ESP's as configurable access points? I want to create unique SSID for the device, that I can connect to on any device, preferably housing a cut-down webserver. Is there any particular flavor you found easier than others?

KevinC10 (author)AnthonyP152015-08-01

I forgot to tell you that every time they came out with a newer firmware i had to have it and began to have problems if is not broke why fix it? I went back to 9.2 wep you can program 4 manuel the esplorer has 3 built in but their is 4 anyway i went to as far as 1..1 or something and went back to 95 9.2 for the switch. The newer firmware I am still playing with and is not working up to my expectations suppose is set up to control the output power so you can lower it. Several at commands have been dropped and/ore changed and the way you enter the at commands are different. Still playing I have about 35 esp devices whats cool if you have an annoying neighbor try running about 15 at a time....on the wall tends to block out any wifi connection even to his router....too much interference. This may not work for you but it does a great job here placing them on different the router their name on all devices and vary the channel big confusion on their part if they dont know the mac address..

KevinC10 (author)AnthonyP152015-08-01

0.9.2 use this app

use the info from his web site here

download the cool esplorer programer

download the flasher

note ypu will have to make changes in this flasher to his page inf examp, load his 0000 and 4000 to the appropriate location on node mcu program page. you will have to select the comm port for it also. If you played with the esp befort this should be easy for you. If not use his loader at : this is his xcomm loader after the 9.2 is loaded load his 0000 then load his 4000 as described on his page at:

If you want me to preload one for you I will do it for free ...either send me a esp8266-01 or a the cost of the chip ( about 2,75) . The 201 and the 12 will take the same program....note that the 12 and 201 have several outputs but you have to run lots of wire to control various items this could be ok in like a car short runs to a multi relay box but in a house several long runs....i use only 1 esp8266-01 per relay to control ...the only downside is that you have to connect to that wifi esp directly for each switch. Hope this helped a little. Google hangouts for me is

radames ajna (author)KevinC102015-02-12

Hey great! thanks for the information

BugBlaster (author)KevinC102015-02-08

I was thinking of doing the same with te geocaches but then perhaps also letting people get cords from the web pages or even have a pizzel builr into the page that then could open the locked cache

KevinC10 (author)KevinC102015-02-04

Also here is a link to some KUHN smart sockets for about $21.00 fre shipping.

Ambrogio (author)2015-05-13

priyam170 (author)2015-04-30

How can i access my esp8266 from any where in the world..??

SeanM9 (author)2015-04-18

Great job! For those wanting to talk from their PC, you can use this breakout board to convert from USB to TTL:

There is a program called CoolTermWin that's free that lets you communicate to the board: Be sure to set your baud to 115K in the options.

About This Instructable




More by Propellerpowered:Sprites & Graphics On the Micromite CompanionUsing the ESP8266 moduleBuilding your own Micromite Companion Minicomputer
Add instructable to: