ESP8266 WiFi Server @ESP-01

Prerequisite : No Programming knowledge is required to complete the steps here. I strongly recommend you to read earlier blog for better understanding . If you find something missing, Please provide feedback in comment box so that I can take corrective action.

Please SUBSCRIBE to YouTube channel Embedkari  for further discussion on Embedded Systems.  I recommend to  use laptop/PC with headphone or at least Tablet for  watching related YouTube video.

Key Takeaway First WiFi  project with ATtension commands. Generally ESP-01 comes with default ESP8266 AT firmware which has complete TCP/IP stack. This firmware takes care of DHCP as well.AT commands are used to control GSM phone or Modem.

How ESP-01 gets IP address ?   ESP-01 firmware is set by default as DHCP(Dynamic Host Configuration Protocol) client. It broadcasts the DHCP Discover message after power-on . You may refer to following link to understand this process.

wire4

If you observe the traffic using FREE Wireshark tool,You will notice ARP from ESP8266 to itself immediately after getting IP address. It is followed by  Gratuitous ARP which has both source & destination IPs are same. This is a good method to check IP conflicts. 

wire5

wire6

After this  IGMPv2  (Internet Group Management Protocol) membership report.  A membership report message is sent by a  host whenever it joins a multicast group, and when responding to Membership Queries sent by an IGMP router. 

wire7

How to use AT commands ?
  • AT+command? to know the existing value  e.g. AT+CWJAP? 
  • AT+command=val to set new value e.g. AT+CWJAP=ssid,password
  • AT+command to execute a command if no parameter required e.g. AT+CWLAP
  • Here CWLAP to get available local access points and CWJAP to connect to local access point and
How to configure ESP-01 as WiFi Server ?

 Step1: To configure ESP as a server first we must enable multiple connections to it using CIPMUX  i.e.  AT+CIPMUX=1

Step2: Then we should configure the server using command CIPSERVER  i.e Configure as Server 

AT+CIPSERVER=<par><port number>

  • par=1 (open server)
  • par=0 (close server)

e.g. : AT+CIPSERVER=1,5678    

wifia2

Step3: The IP address can be obtained by CIFSR i.e.  AT+CIFSR

wifia3

If two IP addresses are obtained this means CWMODE is set as 3. Here 192.168.4.1 is the default IP for the ESP8266 acting as access point (AP).

Take a note of MAC addresses (From Actual experiment Not in the above picture), I noticed only one bit b1 changed . 

wire3

Step4: Now suppose if the STAIP is 192.168.1.207 as shown above, Check the connectivity using ping 192.168.1.207 from command prompt of Windows.

Step5: Open browser with http://ip:port   i.e. http://192.168.1.207:5678 in this case. A message appears on the terminal window stating that the connection has been accepted.

wifia4

 

Step6: Now to send data over the link use the command AT+CIPSEND=0,4. Here ‘4’ indicates the number of characters to be send. You will get a > sign . Type four characters blindly at this. After typing a message will be displayed saying SEND OK . These characters are received in the terminal window

wifia6

We may use Wireshark tool to capture this .

Wire1

Here is the complete packet (Ethernet,IP,TCP)

wire2

Step7: In the end, to close the link between browser and ESP, the command AT+CIPCLOSE=0 should be used

 

References:

          AT Commands List for ESP8266

 

Thanks for reading till end. I am trying to improve usability of my  site. Did you find this discussion helpful ? If so,  Please subscribe to YouTube channel Embedkari as well for additional embedded related stuff.

 

 

 

 

 

 

 

 

 

 

 

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.