Tag Archive: ESP8266

WEMOS D1 is a WIFI development board based on ESP8266 12E. The functioning is similar to that of NODEMCU , except that the hardware is built resembling Arduino UNO.

The D1 board can be configured to work on Arduino environment using BOARDS MANAGER.

So,its not necessary to use a separate Arduino board , the D1 itself can be programmed on Arduino IDE.This is handy in using with IOT projects. Further many Arduino SHIELDs are compatible with the D1 board.

Different versions of D1 boards are available in the market    R1  ,  R2  , MINI

As the name implies D1 Mini is a smaller version

R1 , R2 boards look like Arduino UNO board ,but version is not printed on board. On some boards WEMOS D1is printed , as the ESP12 chip is manufactured by WEMOS.

In some other boards it is printed just D1 ,where the ESP12 chip is that of AI Thinker.

As the ESP12 chip has only one ANALOG pin , on board there is only A0 & other analog pins are dummy .

Image 2

Image 3   Image 4

Use a MicroUSB cable to connect D1 with PC. Make sure that the cable is capable of handling both Data & power (some of the mobile cables can handle  only power & not data) .

Open the DEVICE MANAGER & note the COM PORT allotted to the module.

As the serial chip used on D1 is CH340 , you need to install the corresponding drivers.

Image 1



Following is the pin configuration of R2 typeD1 Module.Note the changes in GPIO Pin position.


Open the Arduino IDE &  select this COM port.

From TOOLS  —>  BOARDS  —> BOARDS MANAGER install the package for ESP8266.

Prior to this , you need to provide the link from where the Boards manager will look for the package.

To do this copy the following Link


Go to FILE  –> PREFERENCES on Arduino IDE

Paste the link against the Additional Boards Manager URLs ,seen at the bottom of preferences screen & click OK.

Image 1.1



Search for ESP8266

Now you will find the package from ESP8266 Community.

Select the latest version from drop down & install it.

It takes a while & requires internet connection.

Image 2.1

Once the package is installed ,you can see the list of  boards under TOOLS –> BOARDS

Select the board as WEMOS D1 R1.

Select UPLOAD speed as 115200 &Programmer as USBASP

Image 3.1

Now open the  File –> Examples –> Basics –> BLINK sketch

No need to modify the sketch ,as we’re going to blink the built in LED (on the ESP chip , there is another LED on board which is mapped to pin14)

Click on UPLOAD


On some PCs you get a compile error ,stating that the file is being used by another process.

On some forums ,it is mentioned that the board is Duplicate .Its not the case, the reason is that some Antivirus program like McAfee does not allow the compilation process.

Open the Antivirus dashboard & TURN OFF the REAL TIME SCANNING for some time



You can also configure the Antivirus settings for an EXCEPTION to Arduino programs.

Now Upload the sketch.


Once the code is uploaded, you can see the built in LED blinking on the chip

Next code is a WIFI scanner which scans for nearby SSIDs & display the names of WIFInetworks with RSSI signal power &encryption mode.

For this we include the Header file ESP8266WiFi.h

This is installed along with the Boards Manager & is a very powerful library.

You can get more information on this library from here :


Many useful Functions are there for this WiFi library.

WiFi.mode (WIFI_STA); 

The mode function of library is used to set the D1 board in STATION mode.


scanNetworks function scans for nearby SSIDs & the result is an integer (number of surrounding WiFis) which is stored in a variable n

Then we print the SSID name,RSSI signal strength ( the lower the negative dB the stronger the signal), & Encryption mode (a * indicates SSID is password protected)


// D1 ESP8266 WiFi scanner

# include  “ESP8266WiFi.h”

void  setup () {

Serial . begin ( 9600 );
// set WiFi to station mode and disconnect from previous connection
WiFi.mode (WIFI_STA) ;
WiFi.disconnect ();
delay ( 100 );

void  loop () {
Serial . println ( “Start Scanning ..” );
// scan for nearby WiFi SSIDs & save their number into n
int n = WiFi.scanNetworks ();
// in case no Network found , print info
if (n == 0 ) {
Serial . println ( “No SSIDs nearby seen…” );

else   {
Serial . print (n);
Serial . println ( “WiFi network SSIDs nearby ….” );
// list all WiFi networks nearby
// name, signal strength and security method
for ( int i = 0 ; i <n; ++ i)
Serial . print (i + 1 );
Serial . print ( “:” );
Serial . print ( WiFi.SSID(i));
Serial . print ( “(” );
Serial .print ( WiFi.RSSI(i));
Serial . print ( “)” );
Serial . println (( WiFi.encryptionType (i) == ENC_TYPE_NONE)?”” : “*” );
delay ( 10 );
// Exit
Serial . println ( “” );
// pause for 15 seconds before new scan
delay ( 15000 );




Support VIDEO:



NODEMCU is built on ESP8266 12E Module & is an excellent , economical IOT PLATFORM.

Generally it is shipped from factory with NODEMCU FIRMWARE which can be programmed with LUA Script.

In this post we shall install the ARDUINO CORE for ESP8266 on NODEMCU & start exploring how to use the ARDUINO IDE to code NODEMCU



To use the ARDUINO IDE , first thing is to install the ARDUINO CORE on to NODEMCU.

Open the ARDUINO IDE & under FILE –> PREFERENCES paste the link provided below :

Arduino Boards Manager file link is HERE


Image 1


search for ESP8266 & then click on it to install the latest version.

Image 2


Connect the NODEMCU to the USB of PC & open the DEVICE MANAGER to note the COM PORT allotted.If you see exclamation mark , then install the CP2102 driver for the NODEMCU.

Under Tools –>

select the board as NODEMCU V1.0 (ESP12E) , Port as the COM port alloted, Programmer as USBASP , UPLOAD SPEED as 115200.

Image 3


Under FILE –> EXAMPLES –> ESP8266 select the BLINK sketch

Image 4


Here the LED_BUILTIN is mapped to the inbuilt LED on board NODEMCU.

So , just click on the UPLOAD button.

Image 5


Once the sketch is compiled , the uploading starts , as seen at the bottom of the IDE.

It takes some time to upload ( i.e the reason to select upload speed 115200 , to make it fast)

as the code upload is like upgrading Firmware.

As the sketch is uploaded , the blue LED on the ESP chip (near WIFI antenna) flickers & finally the RED LED on board blinks.

In the next example let us connect an LED at pin D2 through a resistor.

D2 pin is GPIO4 of NODEMCU , but in the code we use the notation Dx to represent GPIO pin.

To control GPIO4 pin we use D2 in the code & not GPIO4 directly.

Image 7


In the blink code , the following line is added

#define LED_BUILTIN D2

Image 8

Upload the code to see the LED connected at DS2 blinking.

In the same way we can use ANALOG WRITE function to give a fade effect on the LED.


Now let us explore the NETWORKING capabilities of NODEMCU.

To start with we include the ESP8266WiFi.h header file.

The WIFI library is enhanced version of Arduino & is installed along with the Boards Manager.

This ESP8266WiFi  library has several classes, methods and properties  , which combines many powerful FUNCTIONS .

In the first line of sketch #include <ESP8266WiFi.h> we are including ESP8266WiFi library. This library provides ESP8266 specific Wi-Fi routines we are calling to connect to network.

After the header file  , we store the SSID name & Password as character arrays

#include <ESP8266WiFi.h>
char ssid[]=”SSID_NAME”;
char pass[]=”Password”;

Inside the setup function , Serial communication is started with 9600 baud & the name of SSID is printed.

void setup() {
Serial.print(“Connecting to..”);

WiFi.disconnect() function is called to disconnect any previous connections

While using the WiFi CLASS , there is no need to create WiFi Object.Simply call the function like

begin(),  SSID(), status(), disconnect(), scanNetworks(), localIP(), etc..

Actual connection to Wi-Fi is initialized by calling the begin() function.We pass on the 2 parameters to WiFi.begin() function to start the connection


We use a While loop to test the status of WiFi.status(). Here we check whether it returns WL_CONNECTED

IF not connected , a dot is printed every 500 msec.

while(WiFi.status() != WL_CONNECTED)

Once connection is established , it jumps out of loop & prints the SSID name connected with.

if connection is established, and then lost for some reason, ESP will automatically reconnect to last used access point once it is again back on-line. This will be done automatically by Wi-Fi library, without any user intervention.

Serial.println (WiFi.SSID());
Serial.println(“Successfully connected!!!”);


Next the IP address allotted to the NODEMCU by the Router  (by DHCP method) is printed by calling the function WiFi.localIP()

The MAC address is printed using WiFi.macaddress()


Serial.print(“IP Address allotted to NodeMcu ESP..”);

Serial.print(“MAC Address of ESP…”);

WiFi.printDiag(Serial) prints all the WiFi credentials like Channel , SSID name , Password , etc..

This specific function  prints out key Wi-Fi diagnostic information:


void loop()

Upload the code & open the Serial monitor at baud 9600 to see the result.


Image 10

Next example is to scan the surrounding networks & print the name of SSIDs.

Here we use the function scanNetworks() which returns an Integer value on the number of surrounding SSIDs.

We assign this to an integer variable

int n = WiFi.scanNetworks();

& then in a For loop iterate to print out name of each surrounding SSIDs


for (int i=0; i<n; i++)


Serial.println(  WiFi.SSID (i) )


Image 11


Scan for available Wi-Fi networks in one run and return the number of networks that has been discovered.


There is on Overload of this function that accepts two optional parameters to provide extended functionality of asynchronous scanning as well as looking for hidden networks


Both function parameters are of boolean type. They provide the flowing functionality: * asysnc – if set to true then scanning will start in background and function will exit without waiting for result. To check for result use separate function scanComplete . * show_hidden – set it to true to include The in scan result networks with hidden SSID.



Download code samples HERE

Download ESP8266 Library document PDF HERE




cooltext753793315   cooltext753790696

The ESP8266 by itself hosts a 32 bit Microcontroller on it & you can now program your ESP using Arduino IDE. Best part is that NO Arduino board is required.You can upload your code from Arduino IDE , as if you were upgrading the Firmware on ESP.

You can pretty much write any code  for an Arduino and run it on the ESP8266. Of course there is a limit to the I/O on some of the modules, but the Flash on the ESP-12E (Black) module is 4MB and the RAM is 80kB! Add to that the 80MHz 32-bit processor and you have a pretty impressive little cute Arduino.

A sample Blink example program on the ESP8266 turns out to be around 225kB, but that includes the core code.So it’s advisable to use an ESP8266 with more FLASH Memory.Generally the BLACK ones are with higher memory than the Blue ones.The new ESP12E has a Flash of whooping 4MB !!  The Arduino UNO has just 32k Flash & Mega 256k.





Program uploading is done at 115,200 Baud, the default for the module. But It still takes a while to upload a sketch to the module , unlike a regular Arduino.

To begin, you must install the ESP8266 board files in the Arduino IDE.

That is easy enough to do. Make sure that your Arduino IDE is latest

Open the Arduino preferences from File  —> Preferences

Image 1


Add the following URL to the “Additional Boards Manager URLs” seen at the bottom of Preferences Window


Image 2


Click OK to close the Preferences Window.


Image 4

When the Boards Manager opens, scroll to the bottom. You should see the esp8266 entry.

Select the latest version & then click on INSTALL button.


It takes a while to download & install .


Image 6

Once installation is over , close the IDE & start again,

Under Tools –> Boards you can now see a new list of ESP8266 Modules.

Image 7

Its time to test some example code.

While using the ESP module make sure that

Power source is 3.3v DC

CH_PD & RESET pins pulled HIGH through resistor.

You can use a development board available at



An LED is connected to GPIO4 through a resistor.

Image 22

An USB-TTL board is used to connect ESP with USB port of PC.

Rx of USB-TTL board goes to Tx of ESP board

Tx of USB-TTL goes to Rx (3.3v level) of ESP board

GND is made common.

5v of USB-TTL is connected to Vcc of ESP board.As the ESP board has a built in 3.3v regulator we can connect to 5v safely.

Connect the GPIO0 pin to GND.



Open the Arduino IDE & select the COM port allotted to the USB-TTL board.

Other settings are done under Tools tab as seen in screenshot below :


From File —> Examples —> ESP8266 select the BLINK sketch.

As we’ve connected an LED at GPIO4 pin , change the pinMode & digitalWrite pin to 4.

Ensure that GPIO0 is connected to GND & click on UPLOAD button.

It takes a while to compile & then uploading starts.


Once the Uploading is done the LED connected at pin 4 , starts blinking.

Remember to upload another sketch, you need to ground GPIO0 and push the reset switch. The ESP8266 will be put in UPLOAD mode.

When the upload is done, the sketch will start running. If you reset with GPIO0 still grounded, the sketch will not start running because the ESP8266 will be in PROGRAMMING mode. To exit programming mode, remove the ground from GPIO0.




In the next post we shall see how to use the built in WIFI library in your code.

cooltext753793315   cooltext753790696

ESP8266 WIFI Module comes with an inbuilt firmware which supports serial interface and can be controlled using AT commands. Even though we can use this module to offer WiFi functionality from another micro controller ,this module is not just a simple serial to WiFi transceiver .

It is comprised of  a 32Bit processor ( 80MHz) ,  512KB SPI FLASH , 64KB SRAM ,96KB DRAM , GPIO Pins & WIFI Transceiver.

In this post I shall walk you through how to upgrade new Firmware on to the ESP module.This procedure can also be followed in case  esp8266 stopped working , or giving out some random garbage data.

Before starting upgrading I downloaded following 2 files .




2. FIRMWARE latest BIN file  version 9.5.0


I used a  USB – TTL converter between my ESP-01 board & PC. As the ESP device requires 200ma current which cannot be sourced from USB-TTL module , I used a separate power source 5v/1Amp adaptor followed by a 3.3v regulator ( 1117 3.3v).

Please note that while I used a separate power source for ESP module , the operation was smooth.

I connected the ESP module with USB-TTL board as per following wiring diagram :

Image 2

CH-PD is CHIP ENABLE which is directly connected to +3.3v

RST is pulled HIGH through a 2k2 resistor.A press switch is connected to GND , so that when it is pressed RST pin is grounded.

TX of ESP is connected to RX of USB-TTL module

RX is connected to TX .

Vcc is connected to +3.3v of the external Regular. GND is made common for all , i.e GND of ESP ,USB-TTL & that of 1117 regulator are ALL MADE COMMON.

GPIO0 pin is connected to GND to upload firmware.

After uploading firmware , this GPIO0 connection must be removed from GND.

The USB-TTL converter I used is built on Silicon Labs CP2102 chip which is highly reliable one.The other type available in the market is built on Prolific chip (Chinese one , not original) , which has got some issues with driver installation .

I connected the USB-TTL board to my PC & from the Device Manager I noted the Port allotted .

COM port COM9 is allotted.

Image 4

Next , I browsed to the folder where I’ve already downloaded the 2 required files , one is the simple flasher & the other one is the latest firmware to be uploaded.

On double clicking the esp8266_flasher .exe file , I got this Downloader window open


I clicked on the BIN button & browsed to the location of the folder to select firmware.bin file.

Before clicking the DOWNLOAD button I changed the COM port number , where USB-TTL is connected to PC.

The default address 0x000000  is automatically displayed after COM port


First time when I clicked the Download button I got “Failed to connect”   error.

This was because I’ve connected GPIO0 to GND after the power to ESP board is ON.

GPIO0 pin must be at GND level when the power is initially provided to the ESP module.


Second time when I clicked on the Download button , Writing started  but abruptly failed .


You can see the “Failed to write to target Flash” message in the screenshot below .


After repeated trials I finally found that , connecting 100uf capacitor between Vcc & Gnd

solved the problem.


Finally I hit the Download button and waited for the flashing process to complete. The STATUS BLUE LED blinked fast while the uploading was going on.

“ Failed to leave Flash mode “ message after 99% writing ,does not affect the flashing process in any way and can be ignored.

After the firmware flashing, ESP8266 module settings changed. The default baud rate now is 9600 & can be modified using AT+CIOBAUD command.

It is even possible to cloud update ESP8266 Wi-Fi module firmware using AT+CIUPDATE command.But I suggest you not to try this cloud update , as it’s got some issues.

Now I removed GPIO0 pin from GND & pressed RESET switch & then closed the Flasher application.

I opened the terminal software Putty & selected Serial COM Port 9 & baud rate 9600.

Image 5

I typed in AT command & got an OK response from the ESP module.

AT+GMR returned the upgraded firmware version 9.5.

Image 6

Watch this support Video :

cooltext753793315     cooltext753790696

After struggling for nearly a week with MTS dongle , finally I found an excellent solution to enable PORT FORWARDING.

HUAWEI POWER FI  E8221 model dongle  is the solution I found.This dongle accepts any data SIM for internet connectivity & we can create a WIFI HOTSPOT with this dongle to connect max. of 10 devices.

Further it has got a VIRTUAL SERVER setting tab in the configuration , thus enabling Port forwarding.

There is no need of an external Router like TP-LINK (which I used with MTS , as seen in my previous post).


I’ve inserted a BSNL DATA SIM into the HUAWEI dongle for Internet connection.

The DEFAULT GATEWAY IP address while using Huawei is

This can also be found by opening CMD in Windows search bar & then typing the command IPCONFIG /ALL

Typing this Gateway address in the browser , you get the HUAWEI CONFIGURATION window.Here the service provider (for me BSNL ) name is displayed with connection status.

Image 1

Click on CONNECTION SETTINGS seen below the “Connected” status.

On left pane , under SECURITY tab select the VIRTUAL SERVER.

Before clicking the ADD button under VIRTUAL SERVER LIST , we’ve to configure the ESP module & start a SERVER on port 333.

Image 2

The ESP 8266 module is connected to PC through USB-TTL board & the COM port allotted in my PC is COM 48 .

I’m using PUTTY terminal software to communicate with this COM port.

Following is the screen shot on which you can see the AT commands used to connect ESP with HUAWEI on WIFI , & starting a server on port 333.

The selection of port is random.You can select any port within 65536 , except the standard ports like 80 (HTTP) ,  21 (FTP), 23 (TELNET) ,etc..

AT+CWLAP   – to list the surrounding Access Points near ESP module

AT+CWJAP=”ssid”,”password”   – to join the AP using the SSID name & its password.

AT+CIPMUX=1   — to enable Multiple connections before starting server

AT+CIPSERVER=1,333   –  to start a server on port 333

AT+CIFSR  –  displays the IP address . STAIP is the IP address we need to port forward.

Image 3

After starting the server on ESP8266 , we need to port forward under the HUAWEI configuration.

Click on the ADD button , seen under VIRTUAL SERVER LIST.

Fill in details as below :

Name  : ESP

WAN Port : 333

LAN IP   :

LAN Port  ; 333

Protocol : TCP

Status  : ON

Finally click on APPLY.

Image 4

Needless to say , you’ve to apply an INBOUND RULE on Windows Firewall settings to allow this port 333 . (check the previous post on how to do this).

The external world can contact this ESP only through the EXTERNAL IP address.To know the IP , just type in WHAT IS MY IP on Google .In my case it is

To confirm that the PORT 33 is open & listening , visit the online tool www.yougetsignal.com

You need to test this on the PC where you’ve connected the ESP module.

The external IP will be automatically displayed.You just  type in the port no. to verify.

Following screen shot shows that my port 333 is open

Image 6

Now we’re all set to contact ESP from outside World.

From a distant PC with different Internet connection , open a PUTTY terminal.

Select RAW as Connection type & type in the IP  & port no. as 333.

Following screen shot shows the PUTTY terminal which I’ve opened on a different PC with a different IP.

Image 5

On clicking OPEN button , the ESP Terminal at the other end will respond with


This means a connection established on channel 0.

Image 8

Now type in some characters on the distant PC terminal.


The ESP terminal responds with

+IPD,0,21:characters received

which indicates , it has received 21 characters on channel 0.

The screen shots with HUAWEI symbol (IP ) is that of TERMINAL where ESP module is connected & the screen shot of distant PC is shown with the IP address

Image 9

To send characters from ESP , use the AT command :


This indicates that you want to send 15 characters on channel 0.

The ESP will respond with a > symbol & waits till you type 15 characters.

Image 10

The distant PC now receives the 15 characters you typed inside ESP terminal.


Hence a two communication is established with ESP Terminal & a PC from anywhere in the world.This opens the door for INTERNET OF THINGS where you can control the devices connected to ESP from anywhere in the World.


cooltext753793315    cooltext753790696

In the previous post we’ve seen the ways to control the ESP8266 WIFI module from anywhere in the world.The key to success depends on the PORT FORWARDING , where we route the contact on particular port to the local IP address of the WIFI module.

Nowadays USB dongles are used widely for internet access .This post will help you troubleshoot PORT FORWARDING.

Following is the SETUP diagram .

TPLINK ROUTER is on the top of the NETWORK. An MTS USB dongle is plugged to TPLINK Router (model TL-MR 3420 with 3G/4G support).

A Laptop is connected to TPLINK Router on Ethernet using RJ45 cable.

A USB to TTL board is connected to PC on which the ESP 8266 module is wired.

The ESP module is linked to TPLINK Router on WIFI using the AT Command AT+CWJAP=”SSID”,”password”



On switching ON the ROUTER , it assigns LOCAL IP address to the modules connected to it either on RJ45 (wired) or on WIFI.

In our set up the LAPTOP which is connected by wire is assigned

& the ESP module which is connected on WIFI is assigned

Note that the allotment of address is on first come basis.When you power off & on the Router again , this allotment may vary.

You can RESERVE the address by selecting the DHCP tab of TPLINK configuration.Here select

Address Reservation & then feed in the MAC address of the devices you’ve connected to the Router.

To know the MAC address you can use the ADVANCED IP SCANNER TOOL.

Download & install the tool. Start the scanner to know the IP address & MAC address of the devices connected .



Confirm that you’ve Internet access after plugging  the USB dongle to the TPLINK Router .You need to login the TPLINK configuration with address & enter the QUICK SETUP for this process.

STEP 2 :

Start the SERVER on ESP module





To confirm that the port we’ve started server ( here port no. 333) is OPEN , we use a  port scanner tool .

Advanced Port Scanner is a small, fast, robust and easy-to-use port scanner for Win32 platform. It uses a multithread technique, so on fast machines you can scan ports very fast.

Also, it contains descriptions for common ports, and can perform scans on predefined port ranges.

Download it & install.


Open Port scanner & under Select port range enter 100 to 500 . As we’ve to check port 333 , we enter the range below 500 .Click on SCAN .



The PORT SCANNER displays the result regarding status of PORTs of your PC as well as the module connected to PC.

Here we can confirm that port 333 is OPEN on IP (ESP module).




On TPLINK configuration window , under FORWARDING select the tab VIRTUAL SERVERS.

Click on ADD NEW.. & enter the Service & Internal port as 333 .

IP Address as , which is the local IP allotted by Router to ESP module.

Select Protocol as TCP & then SAVE the settings.




IP 10



Open Windows Firewall Advanced settings & click on INBOUND RULES.

SET the rule to allow communication on port 333.



Now you are set to check the condition of PORT 333 externally.

For this we make use of an online tool www.canyouseeme.org

On opening the site your external IP will be automatically displayed.Enter the port number to check.

Click on CHECK PORT.

ip 13

Unless you see SUCCESS on this test , you can’t contact your ESP module from external world.

If you get ERROR , open the TPLINK configuration & click on STATUS.

Note IP Address displayed under 3G/4G.

From another computer with a different internet connection try to PING this IP address.

Open CMD & type in PING x.x.x.x



If the PING result is OK , you can be sure that the ESP module can be contacted from outside world.

If the PING result is TIMED OUT , you can’t communicate with ESP.

The   STATUS tab in my case , as shown in above screen shot , indicates an IP address starting 100.86.x.x

Generally following IP address ranges are PRIVATE IP ADDRESS RANGES :




These are reserved by IANA for private Intranets & NOT ROUTABLE TO INTERNET.

Private addresses are not reachable on the Internet. Therefore, Internet traffic from a host that has a private address must either send its requests to an Application layer gateway (such as a proxy server), which has a valid public address, or have its private address translated into a valid public address by a network address translator (NAT) before it is sent on the Internet.

In my case , the MTS ISP provider hide the PUBLIC IP address.

The MTS dongle does not support VIRTUAL SERVER settings , which means PORT FORWARDING IS NOT POSSIBLE with MTS.

What I couldn’t understand was , while writing my previous blog ,it worked sometimes.While MTS customer support was contacted repeatedly , they finally accepted that port forwarding is blocked by them.

After sleepless nights I’ve found a solution….. Read on my next post ….


cooltext753793315    cooltext753790696

In the previous post we’ve seen how to initiate ESP module & use AT commands.In this post TCP CLIENT mode operation is explained.

ESP8266 WIFI module has 3 modes of operation.

ST  – Station mode in which ESP acts as a device & connects to an existing Access point.

AP – Access Point mode where the ESP itself acts as AP & other devices like Mobile can connect to it.

Both – ST & AP both mode is allowed in ESP.The mode of operation is set by the AT command

AT+CWMODE = 1 for ST mode , 2 for AP mode & 3 for both.

As we’re testing ESP on STation mode , issue the command


Image 7

To communicate with a webpage , we need to start a server with ESP module.You need to set multiple connections using command


This initiates the server for a Webserver.

Next we start the server at HTTP port 80 using command ,


Image 8

To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST

To get the STATION IP address ,


The module returns the Station IP address , .

If the CWMODE is set to 3 , you’ll get 2 IP address , one for AP & another for Station mode.We need the station IP address for Client mode operation.

Open your web browser & type in the address

The browser sends a HTTP GET request which is displayed on the putty window where ESP module is connected.The host IP address & the user agent (your web browser name) are displayed.

After you get OK  type in the command


This command is to send 30 characters through channel 0 .Use the channel number which is displayed as CONNECT while a request is received from the browser.


Now you get a  >  symbol , after which you’ve to type in 30 characters.

The module will wait till you type in 30 characters & finally displays SEND OK.

You’ve to type characters within the Timeout limit.Otherwise the link will be closed.


Now the characters are sent to the Web browser.

But the browser is still waiting for the channel to be closed.


Here use the channel number ( 0) where the connection was established .


Once the channel is closed , you get the characters displayed on the browser.

HTML tags can be used to send characters




The above one displays characters using HTML tag type Heading 1.

Image 121

To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST

For testing 2 way communication , open another instance of PUTTY .

Select connection type as TELNET & Port 80.

Type in the host address , which you get by AT+CIFSR command in ESP window.

Click on open.

Image 122

Type some characters inside TELNET window .You get these inside ESP window


0 is the channel of communication & 17 is the number of characters received.


From within ESP window type AT+CIPSEND=0,20

ESP will wait till you type 20 characters.

On TELNET window the characters are received.


Watch this support video :

ESP WIFI Modules available at :

cooltext753793315  cooltext753790696

ESP8266 is an UART to WiFi module,  a really cheap and easy way to connect any small microcontroller platform (for example Arduino) wirelessly to Internet.

The ESP8266 is now one of the leading platforms for the Internet of Things. It’s super cheap, and super easy to work with.

This is a serial module with a built-in TCP/IP stack, so you can use it standalone

You can use AT commands to connect with WiFi networks and open TCP connections without need to have TCP/IP stack running in your own microcontroller: You can simply connect any microcontroller to ESP module and start pushing data up to internet.


There are several module designs called ESP-x where x is 1 to 12, so far.

I am using the ESP-1 module. The new firmware  is set at 9600 baud. provides the same 2×4 connector, Tx,Rx , RST, CH_DP(chip enable), and two GPIOs, GPIO0 and GPIO2.



ESP8266 is 3.3v device & cannot tolerate 5v levels.

Make sure you pullup the CH_DP and the RST line. I used  3k3 resistor to pull up  RST to +Vcc.

CH_PD is directly connected to +3.3v .Unless you connect CH_PD to Vcc , you won’t get any response from the module. The firmware boots up only on this connection.

So far it seems you can leave the GPIOs floating. For upgrading the firmware , however , the GPIO0 must be grounded.

The current consumption of the module is  80mA at idle state &  it can draw as much as 300mA during operation.

  1. Vcc: 3.3V, up to 300 mA
  2. GND: Ground
  3. Tx: UART Tx of the module, to be connected to the  Rx of the microcontroller
  4. Rx: UART Rx of the module, to be connected to the  Tx of the microcontroller
  5. RST: Reset/Restart, pull to GND to restart
  6. CH_PD: Chip enable, used for flash boot .
  7. GPIO0: pulled low for update mode
  8. GPIO2: not sure yet???



I used a USB to TTL converter for connectivity between PC & WIFI module.The converter has 3.3v output which is used to power the WiFi module. It has also a +5v supply out.

Care has to be taken with power supply as the unit is to be powered at 3.3V and using 5V will probably kill it.

For ease of connections I’ve used a Breadboard.The connection details are as below :

WIFI Module       USB-TTL

Vcc     —  3.3v

Gnd      — Gnd

Tx        — Rx

Rx        — Tx

CH_PD   — connected to 3.3v to enable chip firmware boot.

RST        —  connected to 3.3v through 3k3 resistor

CH_PD pin acts as an enable signal, without it the board is mute and deaf. If CH_PD is not pulled HIGH , you won’t get any response from the module.

Once you connect this last pin to VCC (remember 3.3V) the module is brought to life, and after some garbage in the serial port you can read the word “ready”. Once you get there things will start to get interesting.

The USB-TTL converter I used required a driver “Prolific 2303” to be installed.After installing the driver , I got the port allotment under device manager while the converter is connected to a USB port of PC.

Image 1

A serial Terminal software PuTty  is used to communicate with the port where USB-TTL converter is connected.

Open PuTty & select Serial .Feed in the port number seen under Device manager (here it’s COM41) & speed as 9600 (Baud Rate).


Image 2

Click on OPEN button to see the Terminal black window.

Try to type in AT .If you do not get any response , just momentarily connect the RST pin of module with GND.

You get some garbage data initially & then the address of the vendor “www.ai-thinker.com”

followed by the firmware version & then “ready”


Image 3


Now type in AT .The module will respond with OK. If not ,close the Putty window & again open it & proceed with above steps.

AT+GMR will return the current firmware version.


Image 4


Generally , you can inquire the module with AT command followed by question mark ?

or you can assign a value  , by using equal to = , after the AT command.

All AT commands must end with a “\r\n” – a carriage return & a New Line.

For detailed list of AT commands visit :



AT+CIOBAUD? will return the Baud Rate the module is working with.

AT+CWMODE? returns the Mode of operation of the module.

CWMODE returns an integer designating the mode of operation either 1, 2, or 3.
1 = Station mode (client)
2 = AP mode (host)
3 = AP + Station mode (Yes, ESP8266 has a dual mode!)


Image 5


But the magic starts once you try AT+CWLAP command, that will provide you a list of available wifi access points in the area.

The command AT+CWLAP will list access points in range. This was very encouraging, not only is my access point (MBLAZE..) on the list, but the ESP can see at least as many access points as my laptop can .

The APs are listed as  +CWLAP: ecn,ssid,rssi,mac

The Parameter are

ecn:  0 OPEN  , 1 WEP , 2 WPA_PSK , 3 WPA2_PSK , 4 WPA_WPA2_PSK
ssid: string, SSID of Access Point
rssi: signal strength
mac: string, MAC address

In the above screen shot you can see my AP “MBLAZE..” is WPA2_PSK  (3) password protected.You can see some other APs which are open  & not protected with password .They are listed with ecn 0.


Next you want the board to join a certain access point (most of us want the board to act as a STA or WIFI client that will connect to an access point). That behavior is selected with the AT+CWMODE=1. You will need to reset your board after making this selection.

To connect to your home/office access point you issue the command AT+CWJAP=”yourSSID”,”yourWifiPassword”

The good news is that from now, every time you power the board it will try to connect to the same wifi network. You can see if it was successful by checking your router’s DHCP client list.

Even if the power is removed , the ESP module will remember the joined AP .

You can make it forget by issuing the QUIT command AT+CWQAP


Image 6


Alternatively you can check your module IP address with command AT+CIFSR. Once you know your board’s IP address you can try pinging it from your computer.

In the upcoming posts we shall investigate the module in TCP client and server modes.


For availability of these modules contact :

cooltext753793315   cooltext753790696