We have introduced ESP-WROOM-02 in our last article. Today, we will go one step further and test its wifi function. “AT command” through the Arduino serial monitor can be used to test wifi communication on the ESP-WROOM-02. This time, we will use this AT command to display a list of access points and try to connect these access points.
Please note that ESP8266 ESP-WROOM-02 board was used in this article.
Today’s Electronic Recipe
Estimated time to complete: 60 minutes
ESP8266 ESP-WROOM-02 1,2,etc. (or ESP-WROOM-02 Development Board 1,2,3,etc.)
First, let’s connect 3.3V power supply to ESP-WROOM-02. As described in the previous article, ESP-WROOM-02 consumes approximately 80 mA current to operate. When power is taken from the 3.3V FTDI cable that connects ESP-WROOM-02 to PC, in some cases it can only supply about 50 mA at the maximum, so power is provided by using an adapter, separately from the power supply.
The connection is as follows. Please note that RX and TX are reversely connected to RX and TX cables, respectively.
Figure 1 ESP8266 ESP-WROOM-02 wiring
Figure 2. Current measures about 70 mA
If the FTDI cable is not 3.3V, but has a 5V version, you can convert the communication signal from 5V to 3.3V by using a logic level conversion module etc, so it can be used with a 5 V cable I can do it.
If the FTDI cable is 5V instead of 3.3 V, you can use a logic level converter to convert communication signal from 5V to 3.3V, so it can still be used with 5V cable.
Figure 3. Example of logic level converter (MM-TXS 01)
Try operating ESP-WROOM-02 with AT command
ESP-WROOM-02 is in the mode that can confirm the operation with the AT command at the time of purchase. We can check the operation using Arduino serial monitor.
1. Launch Arduino and click on “Tools” → “Serial monitor” to display the serial monitor.
2. When you press the reset button on the ESP-WROOM-02 while the serial monitor open, if the wiring is done correctly, ready will appear after special character strings on the serial monitor as shown below. There is no problem if these characters are displayed. If nothing is displayed, make sure the wiring is done correctly and the is supplied properly. Also, since it is necessary to match the format of the communication signal with ESP-WROOM-02, select “115200 baud” in the lower right corner of the serial monitor.
Figure 4. Reset button on ESP8266 ESP-WROOM-02
Figure 5. Setting bps in serial monitor
Figure 6. Message from ESP-WROOM-02 appears on the serial monitor successfully by pressing the reset button
3. When “ready” is displayed, try sending an AT command to ESP-WROOM-02. Please enter “AT” in the upper column of the serial monitor and press Enter to update. “OK” message will then be displayed.
Figure 7. “AT” command sent to ESP-WROOM-02
4. Next, enter “AT + GMR” and press Enter. With this command, you can check the information regarding current version of SDK and AT command of ESP-WROOM-02.
Figure 8. Checking the setting information with the “AT + GMT” command
This completes the confirming the operation of ESP-WROOM-02.
What is an AT command?
As mentioned earlier, ESP-WROOM-02 at the time of purchase contains firmware that can be operated with the AT command. The following lists what the AT command can do.
Check if the AT command is executable
AT + GMR
Confirm firmware version
Check the firmware version such as SDK and AT command
AT + RST
AT + GSLP
Switch to deep sleep mode
Switch to deep sleep mode
Command echo setting
Display / hide the reply to AT command
ATE 0: Invalid / ATE 1: Valid
AT + CWMODE
Set wifi mode
Set wifi mode. There are three modes: station / softAP / station + softAP.
AT + CWJAP
Connect to wifi
Connect to the wifi access point. Set SSID / PASSWORD as argument.
AT + CWLAP
List of access points
Display a list of connectable access points.
AT + CWQAP
Disconnect the connected wifi.
AT + CWSAP
Set advanced setting of wifi
Set detailed parameters for softAP.
AT + CWLIF
Display connected terminal
Display the IP list of the terminal connected to ESP-WROOM-02.
Wifi connection with ESP – WROOM – 02
Now, let’s set up a wifi connection using the above AT command.
When entering “AT + CWLAP” command in the serial monitor, the list of accessible access points is displayed.
Figure 9. Displaying access point list with “AT + CWLAP” command
When the list is displayed, connect to the access point with “AT + CWJAP” command.
You can specify the access point you want to connect by setting the SSID and password in the command argument.
Figure 10. Connecting to the access point with “AT + CWJAP =”SSID”,”PASSWORD” command
Once “WIFI CONNECTED, WIFI GOT IP” is displayed on the serial monitor, you will be able to successfully connect to the access point and obtain the IP.
The wifi connection test is complete so long as it can check whether connection can be made from another PC connected to the same access point by the ping command
Figure 11. Connection test from another PC to ESP-WROOM-02 (ping transmission)
This completes the tutorial on ESP-WROOM-02 wifi setup. It is now ready for implementation! Next time, we will be writing Arduino program to ESP-WROOM-02 so the wifi module can be used as Arduino MCU.