Recent Posts

#7 Introduction to ESP01 WiFi Module Commands | Arduino Mega


IoT Tutorial #7 [ Arduino Mega Tutorials #7]

Here, I will explain step by step (Manually) how you can send data to the server using ESP01 Wi-Fi Module. (Not using any Program)


Basic knowledge of communication layers is as follows:


Communication Layers:
Application Layer : Generate Msg Signal (Eg. Serial Monitor)
Network Layer      : Assign Source and Destination IP Address to Msg
Data Link Layer    : Data packet will be framed bit by bit
Physical Layer       : Transmitted / Received via medium.

Follow these steps:
  1. Connect ESP01 Module in configuration mode
    PIN Diagram of ESP01: (This module works on 3.3v) (NOT 5v)
    +---------------------------+
    | |=| |=| |=|============== |
    | | | | | | |    ANTENA     |
    | | |=| |=| | Facing ur side|
    | ========================= |
    |                           |
    | GND   GPIO0   GPIO2   RxD |
    |  o      o      o       o  |
    |                           |
    |  o      o      o       o  |
    | TxD   CH_PD    RST    Vcc |
    +---------------------------+
    Connections for configuration:
    ESP01      Arduino
    Vcc    ->  3.3V
    GND    ->  GND
    TxD    ->  Tx0
    RxD    ->  Rx0
    CH_PD  ->  3.3V
  2. Open Arduino Serial Monitor and Set Baud Rate = 115200 and select "Both NL and CR" Option

  3. Type following AT commands in given Sequence
    FORMAT:
    ---------------------------
    <Command>
    :Explanation
    --<Expected Output>
    ---------------------------



    AT
    :Attention Command
    --OK
    AT+CWMODE=1  
    :Setting Mode=1
    --OK
    AT+CWLAP
    :Searching for all available Access Points
    --<List of Available Wi-Fi access points>
    AT+CWJAP="<SSID Name>","<password>"
    :To Connect to any Access Point
    Eg. AT+CWJAP="SuiteUp","123456789"
    --WIFI CONNECTED
    --WIFI GOT IPs
    --OK
    AT+CWJAP?  
    :To check to which SSID we are connected
    --<Connected WiFi SSID Name>
    AT+CIFSR
    :To check IP & MAC addr of the WiFi Module
    --<Static IP Address>
    --<Static MAC Address>



    AT+CIPMUX=0
    :To set Mux = 0
    --OK
    AT+CIPSTART="TCP","google.com",80
    :We are asking module to start TCP IP Communication with google.com at port no. 80
    --CONNECT
    --OK
    AT+CIPSEND=18
    :Send 18 Bytes of data
    --OK
    > (prompt is opened)
    This will open a prompt like ">". Then you can send the data using GET command in that prompt as shown below:
    GET /HTTP/1.0\r\n\r\n
    :Send API string 
    --Recv 18 bytes
    --SEND OK
    you can check: "/HTTP/1.0\r\n\r\n" This string contains 18 character.

    If we mention fewer bytes in the previous command then send more no. of byte then the server will accept only mentioned no. of byte and ignore remaining bytes.

    Instead of "/HTTP/1.0\r\n\r\n", you can call APIs to send the data to the server and make the graph or do the analysis and post work.

    If your ESP01 module isn't working as expected and you need to reset it to default, you can use the following command:
    AT+RESTORE
    : To Restore all settings to Default
    --OK

    To understand better Watch the demonstration video below.
Demonstration:








Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.

Feel free to ask doubts in the comment section. I will try my best to solve it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks and Regards,
-Akshay P. Daga

4 comments:

  1. That is really nice to hear. thank you for the update and good luck. Unique wifi names

    ReplyDelete
  2. Hello.. oke it works..but can you give me simple sketch to turn on a led from android apps?

    ReplyDelete
  3. Thank you for this fascinating post, I am happy I observed this website on Google. Not just content, in fact, the whole site is fantastic. IP Address

    ReplyDelete