ESP8266 ESP-05 WiFi Module – Getting Started

I recently purchased three ESP8266 ESP-05 WiFi modules. These are very cheap WiFi modules costing around $4 USD each, so are ideal for hobbyists, makers and hackers to use in various projects. My idea was to try to get an Arduino web server working on WiFi as a cheap alternative to using an Ethernet shield or WiFi shield.

Although the same module is available from several suppliers, the particular module that I bought was from SainSmart: SainSmart Neu ESP8266 Esp-05 Remote Serial Port WIFI Transceiver Wireless Module AP+STA

ESP8266 ESP-05 WiFi Module

ESP8266 ESP-05 WiFi Module

ESP8266 ESP-05 Pinout and Documentation

The supplier web page for the ESP8266 ESP-05 had no pinout for the module and no documentation. Some of the information on the web page for the module was also completely wrong, for example they state that the module has 5V compatible I/O, however this is wrong. The I/O pins only work with 3.3V logic and are not 5V tolerant.

They also state “on board antennae”, but this module does not have an on board antennae, it has a connector for an external antennae.

ESP8266 ESP-05 Pinout

After some searching on the web I found a pinout diagram for the 5 pin version of the ESP8266 ESP-05. A new article with pinout and power requirements for the ESP-05 is now available on the Starting Electronics website.

ESP8266 Documentation

The manufacturer of the ESP8266EX chip found on the ESP-05 and other modules is the Espressif company. Documentation for the module must be taken from the ESP8266EX datasheets on the Espressif website. Look under Documentation on the ESP8266 resource page where you will find datasheets, user guides, application notes, technical references, etc.

Getting Started with the ESP8266 ESP-05 WiFi Module

You bought a ESP8266 5-pin ESP-05 module, now what? Here are the steps necessary to get the module working for the first time. Once you have a basic understanding of the module and where to find further information you will be able to start your own project development.

Soldering the Header

The module comes with a separate 5-pin header that must be soldered into the module. After the header is soldered to the module it is easy to use the module in a breadboard.

ESP8266 ESP-05 with Header Soldered

ESP8266 ESP-05 with Header Soldered

The following video shows how to solder the header to the module.

 

Aerial / Antennae

I found that the module works fine without an aerial / antennae as long as it is near enough to the WiFi router that it is connecting to. Connecting a wire to the aerial connector does give it more range and picks up the second WiFi router that I have on the other side of the house.

Testing the Module

Use the pinout diagram to correctly connect the ESP8266 module power and UART data pins. An Arduino Due is ideal for testing the module. This is because a Due can supply enough current from its 3.3V pin and works with 3.3V logic. The Arduino Due is therefore completely compatible with the ESP8266 module.

The article on testing the ESP8266 ESP-05 module using an Arduino Due shows how to connect the ESP8266 module to the Due and test it. Use this article to get started with sending AT commands to the WiFi module.

Documentation and Staring your Own Projects

Once you have the ESP8266 module working, it is a matter of sending the correct AT commands to the module to set it up for your project.

Find example AT commands in the ESP8266 AT Command Examples document.

Find all of the AT commands in the ESP8266 Instruction Set document.

How to Use Arduino Serial Ports

Arduino boards such as the Uno, MEGA2560 and Due all have a serial port that connects to the USB device port on the board. This port allows sketches to be loaded to the board using a USB cable. Code in a sketch can use the same USB / serial port to communicate with the PC by using the Arduino IDE Serial Monitor window, or a Processing application for example. The USB port appears as a virtual COM port on the PC.

This article shows how to use Arduino serial ports when additional serial ports are needed for a project.

Arduino Serial Ports Available

The serial port for programming the Arduino mentioned above is a hardware serial port. The microcontroller on the Arduino board has a hardware serial port built-in, so that after the port has been initialized by software, a byte sent to the port will be sent out serially by the hardware.

The Arduino Uno has only one hardware serial port because the microcontroller used on the Uno has only one built-in serial port. The Arduino MEGA 2560 and Arduino Due both have 3 extra hardware serial ports.

Serial Port Technical Details

The hardware serial ports referred to here are UART (Universal Asynchronous Receiver Transmitter) ports. They may be referred to as USART (Universal Synchronous Asynchronous Receiver Transmitter) ports in the microcontroller documentation if they are configurable in both synchronous and asynchronous modes.

Arduino Uno Serial Port

This image shows the only serial port available on the Arduino Uno highlighted in red. The port connects through a USB chip to the USB device port.

Arduino Uno Serial Port

Arduino Uno Serial Port

Arduino MEGA 2560 and Due

Both the MEGA 2560 and Due have 4 serial ports in total. One that connects through a USB port chip to the USB device port on the board and three extra serial ports that connect to pins on one of the pin headers of the board.

Arduino Due Serial Ports

Arduino Due Serial Ports

 

Arduino MEGA 2560 Serial Ports

Arduino MEGA 2560 Serial Ports

Pins 0 and 1 of the Due and MEGA connect serial port 0 through to the USB device port so that these Arduino boards are compatible with the pin numbering of the Uno and therefore with Arduino shields.

The extra serial ports are ports 1 to 3 with each port having a transmit and receive pin.

It is important to be aware that the MEGA 2560 serial port pins use 5V voltage levels, but the Due uses 3.3V voltage levels.

How to Use Additional Arduino Serial Ports

An extra serial port can be used on an Arduino Uno, but must be simulated in software by using the SoftwareSerial library.

Arduino Uno

The following code is taken from the article on serial communications with the GT-511C3 fingerprint scanner which connects the fingerprint scanner to a software serial port on an Arduino Uno.

#include <SoftwareSerial.h>

SoftwareSerial gtSerial(8, 7); // Arduino RX, Arduino TX

void setup() {
  Serial.begin(9600);    // serial / USB port
  gtSerial.begin(9600);  // software serial port
}

byte rx_byte = 0;        // stores received byte

void loop() {
  // check if byte available from USB port
  if (Serial.available()) {
    rx_byte = Serial.read();
    // send a byte to the software serial port
    gtSerial.write(rx_byte);
  }

  // check if byte available on the software serial port
  if (gtSerial.available()) {
    // get the byte from the software serial port
    rx_byte = gtSerial.read();
    Serial.write(rx_byte);
  }
}

To use the software serial port, first the header file for the software serial library must be included.

#include <SoftwareSerial.h>

Next create the software serial port, selecting the Arduino pins to use for receive (RX) and transmit (TX). Here pin 8 has been set as the receive pin and pin 7 as the transmit pin.

SoftwareSerial gtSerial(8, 7);

The software serial port had been given the name gtSerial which will be used in the sketch to refer to this serial port.

The port can now be checked for incoming data.

if (gtSerial.available()) {

If data is available, it can be read from the port.

rx_byte = gtSerial.read();

Data bytes can also be sent on the port.

gtSerial.write(rx_byte);

How to Use Additional Serial Ports on the Arduino MEGA 2560 and Due

The additional hardware ports on the Arduino MEGA 2560 and Due can be used in the same way as the main USB serial port is used in sketches, only changing the name of the port. The USB serial port, or serial port 0 is referred to as Serial in sketches. To use serial port 1, the name changes to Serial1. Serial ports 2 and 3 are referred to as Serial2 and Serial3.

This sketch shows serial port 3 being used which transmits on pin 14 of the MEGA or Due and receives on pin 15.

void setup() {
  // initialize serial ports
  Serial.begin(9600);    // USB serial port 0
  Serial3.begin(9600);   // serial port 3
}

byte rx_byte = 0;        // stores received byte

void loop() {
  // check for data byte on USB serial port
  if (Serial.available()) {
    // get byte from USB serial port
    rx_byte = Serial.read();
    // send byte to serial port 3
    Serial3.write(rx_byte);
  }
  // check for data byte on serial port 3
  if (Serial3.available()) {
    // get a byte from serial port 3
    rx_byte = Serial3.read();
    // send the byte to the USB serial port
    Serial.write(rx_byte);
  }
}

The additional serial ports are immediately available in the sketch without having to include any libraries.

Serial port 3 must first be initialized to the desired baud rate.

Serial3.begin(9600);

The port can be checked for incoming data.

if (Serial3.available()) {

If a byte has arrived on the serial port, it can be read.

rx_byte = Serial3.read();

A byte can be written to the serial port.

Serial.write(rx_byte);

Arduino Serial Port Resources

Arduino Website References for Software and Hardware

Projects, Articles and Tutorials

Can’t Find Arduino Due in Board List of IDE

Can’t find Arduino Due on the menu and therefore can’t load a sketch to the board? The Arduino Due does not appear in the board list of the Arduino IDE under the tools menu. Boards are normally listed under Tools → Board in the Arduino IDE, but if you can’t find the Arduino Due on the Board menu, additional software must be installed from within the IDE.

The Arduino Due used to have a separate IDE, but was later merged with the main Arduino IDE software. It is now a requirement to install the extra software in order to be able to program the Due.

Can’t Find Arduino Due on the Menu in the Arduino Software

In the image below, the Arduino Due is missing from the menu. The steps below show how to solve the problem and get the Arduino Due board listed on the menu.

Can't find Arduino Due on the menu - Arduino Due missing

Arduino Due Does not Appear in Board List of Menu

Installing Software for the Arduino Due

The following screen captures show how to install the software for the Arduino Due.

1. Boards Manager

Select the Boards Manager menu item from the Arduino IDE menu.
Tools → Board → Boards Manager …

Arduino IDE Boards Manager

Arduino IDE Boards Manager

2. Select Arduino SAM Boards

Click the Arduino SAM Boards item in the Boards Manager dialog box and then click the Install button.

Select Arduino SAM Boards

Select Arduino SAM Boards

It will take some time to install the software, depending on how fast the Internet connection is. After installation, click the Close button in the dialog box.

Programming the Arduino Due

After installation, the Arduino Due board will appear on the Board menu. Select Arduino Due (Programming Port) to allow Arduino sketches to be loaded to the board from the Arduino IDE. The USB cable must be plugged into the USB port labelled PROGRAMMING on the bottom of the board.

Arduino Due Programming Port

Arduino Due Programming Port