Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)

Target Amount: $2000
Amount Raised: $123

Donations Received

X

ESP8266 Testing

Created on: 12 December 2016

How to test an ESP8266 WiFi module to see that it is working. An ESP-05 module is used in this basic test, but the test should work with any ESP8266 module (ESP-01, ESP-02, ESP-03, ESP-04, ESP-05, ESP-06, ESP-07, ESP-08, etc.).

If you are thinking "I just bought an ESP8266 module and want to hook it up and check that it works" then this is probably the test that you will want to run first.

Testing is done by sending AT commands to the ESP8266 and checking that it responds as expected. AT commands are sent from a terminal window on a PC to the module. An Arduino Due is used to connect the ESP8266 WiFi module to a PC. The Arduino IDE Serial Monitor window is used to send AT commands to the ESP8266 and to see the response from the module.

It is also possible to do the same test using a USB to serial TTL cable such as those offered by FTDI. The commands can then be sent from any serial terminal program.

ESP8266 Test Hardware Setup

An Arduino Due is used in this test because it can deliver enough current from the 3.3V pin to power the ESP8266 module. The Due also has 3.3V I/O pins which make it compatible with the logic levels on the ESP8266 pins.

Note:

  • ESP8266 modules must be powered from 3.3V only.
  • 3.3V logic levels must be used on the pins.
  • ESP8266 chip pins are NOT 5V tolerant.

See more information on the ESP8266 ESP-05 pinout and power requirements.

Connect the ESP8266 module to the Arduino Due as shown in the block diagram below.

ESP8266 ESP-05 WiFi Module Connected to Arduino Due block diagram

ESP8266 ESP-05 WiFi Module Connected to Arduino Due

It is very easy to connect the ESP8266 module to the Arduino Due as the block diagram shows. Two wires are used for power (3.3V and GND). The transmit and receive signals of the UART on the Arduino and UART on the ESP-05 cross over – i.e. transmit from one UART connects to receive on the other and vice versa. The photo below shows the ESP8266 module connected to an Arduino Due using an electronic breadboard.

ESP8266 ESP-05 on Breadboard Connected to an Arduino Due

ESP8266 ESP-05 on Breadboard Connected to an Arduino Due

Amazon.com

Amazon.co.uk

Arduino Due Test Code Sketch

The Arduino Due program is simply used to relay commands and responses between a PC's USB port and the ESP8266 module. The sketch below must be loaded to the Arduino and then AT commands can be sent to the ESP8266 and responses displayed in the Arduino IDE Serial Monitor window.

The sketch simply receives data from the Serial Monitor window via the Arduino USB port and sends it to the UART receive pin on the ESP8266. When the ESP8266 sends a response, the Arduino relays the response back to the Serial Monitor window.

/*
 * Uses Arduino Due to redirect terminal commands to the ESP8266
 * USB cable connected to PROGRAMMING port of Due
 * ESP8266 connected to UART 1 of Due
 * 
 * http://startingelectronics.org/articles/ESP8266-testing/
 * 
 * Date: 5 December 2016    Author: W. Smith
 */

void setup() {
  Serial.begin(115200);   // USB serial port of Due (PROGRAMMING)
  Serial1.begin(115200);  // ESP8266 on Serial Port 1 of Due (UART 1)
}

char rx_byte = 0;

void loop() {
  // send terminal byte to ESP8266
  if (Serial.available() > 0) {
    rx_byte = Serial.read();
    Serial1.print(rx_byte);
  }
  // send ESP8266 byte to terminal
  if (Serial1.available() > 0) {
    rx_byte = Serial1.read();
    Serial.print(rx_byte);
  }
}

Testing the ESP8266 WiFi Module

With the above sketch loaded to the Arduino Due and the hardware connected as shown above, power up the Arduino from the USB port of a PC. Open the Serial Monitor window from the Arduino IDE and change the following settings at the bottom of the Serial Monitor window:

  • Both NL & CR – send both a newline and carriage return character at the end of a command.
  • 115200 baud – baud rate of communication set to 115200

If you are using a different module, the baud rate settings may be different. If the module returns unreadable characters or garbage, try changing the baud rate. This will need to be changed in the sketch as well and then the sketch reloaded – i.e. change the baud rate in both the sketch and the serial monitor window.

Here are some commands that can be used to test the module. Type them in at the top of the Serial Monitor window and then press Enter to send. A response should then be displayed.

AT       - attention

AT+GMR   - version info

AT+RST	 - reset

AT+CWLAP - list of available APs

How to use the Arduino IDE Serial Monitor window and sending of commands and the responses are shown in the video below. AT+CWLAP shows a list of WiFi access points that the module has discovered.

Can't see the video? View on YouTube →