When compared with some other microcontroller boards, the ESP8266 is slightly more complex to hook up to a serial port for programming. See how...
Table of contents
Introduction to the ESP-01
This post will show how to connect the ESP-01 module to a breadboard and FTDI programmer for ‘flashing’ purposes.
The ESP8266 is the microcontroller chip that is used on the ESP-01 module/microcontroller board. The chip has at least two different boot modes: ‘normal mode‘ and ‘programming mode‘. ‘Programming’ (or ‘flashing’) refers to uploading any (custom or default) software (or firmware) to the ESP8266’s flash memory.
Flashing will overwrite the previous programming/firmware (including the AT command set if that was flashed). The breadboard setup in this post will allow booting into programming mode which will allow a module to be flashed with new firmware.
To be able to flash new firmware onto an ESP-01 module, it needs to be connected to a programming device containing a copy of the firmware (e.g. a PC). An FTDI USB to TTL serial converter module will be used as a communication module.
- Get the ESP-01 module (blue) from BangGood or Amazon.com
- Get the ESP-01S module (black) from Amazon or BangGood
- Get the Basic Arduino Uno R3 Starter Kit from Amazon.com or BangGood
ESP8266 programming mode vs. normal mode
The ESP8266 can either boot up in ‘programming’ mode or in ‘normal’ mode. While (and only while) booting up, the status of GPIO0 and GPIO2 is seen as input pins (i.e. not as to output pins) and their voltage status is used to check which mode the ESP8266 needs to enter.
Apart from the Tx and Rx connections, the main difference between the wiring for ‘programming’ mode (UART) and normal operational mode (flash) is the connection of GPIO0 to GND.
To boot into ‘normal’ operational mode, the status of GPIO0 and GPIO2 needs to be HIGH (which is their default status, i.e. they are connected to a pull-up resistor).
To enter ‘programming’ (or bootloader) mode, GPIO0 needs to be connected to ground where it is being pulled down to LOW. GPIO15 should also be grounded, but does not need any consideration here and will not be discussed for this post.
TTL serial connection
The ESP8266 has a built-in UART (universal asynchronous receiver/transmitter) which can be used for TTL serial communication and/or flashing the chip.
To be able to use the UART, a 3.3V USB to TTL serial converter is required. The USB to TTL serial converter must be able to supply at least 300 mA. For the purpose of this post, the FTDI USB to TTL serial converter module which has a 3.3/5V jumper will be used. It will supply 500 mA through its Vc pin.
The FTDI USB to TTL serial converter module has a mini-B USB port which is connected to a programming device with a USB input. The other end has breakout pins (Tx, Rx, Vc and GND) that are connected to the ESP-01 module.
The pins on the FTDI USB to TTL serial converter module are clearly marked. The FTDI pins are also breadboard-friendly.
- Get the FT232RL FTDI USB To TTL Serial Converter Module from Amazon.com or BangGood
- Get the 6 Pin FTDI FT232RL USB To Serial Cable from Amazon.com or BangGood
- Get the Microelectronics Starter Kit from Amazon.com or BangGood
The ESP-01(S) module
The pins on the ESP-01 are not marked:
To make the ESP-01 breadboard-friendly two, 10mm 4 Pin 2.54mm stackable long legs female connector headers can be used. The legs can be bent and the two parts can be ‘superglued’ together.
Connecting the ESP-01 with the FTDI USB to TTL serial converter module
The FTDI USB to TTL serial converter module is used as a power source and to program the ESP-01. To use the FTDI USB to TTL serial converter module as an ESP-01 programmer, the connections need to be as follows:
The connection can be made directly, for example by using modified 30 cm female-to-female breadboard jumper wire cables or indirectly using a breadboard. The breadboard solution (see earlier) takes a little more time, but is easier to use, looks neater, is upgradable and a is little more sustainable.
When connecting to an ESP-01, the working voltage of the FTDI USB to TTL serial converter module needs to be set to 3.3V (instead of 5V). In some modules, this can be done by changing the jumper on the board itself.
The breadboard can be wired with solderless breadboard jumper cables. On the top left corner, an optional 6 pin 2.54mm stackable long legs female connector header that is bent inwards can be used to connect the FTDI USB to TTL serial converter module. This will allow the module to lie flatter instead of perpendicular to the board. The 4 pin 2.54mm stackable long legs female connector headers are where the ESP-01 will be plugged into.
In addition to 3.3V DC (red wire) and ground (black wire), this configuration connects the Tx/Rx (yellow/green wires) of the FTDI USB to TTL serial converter module to RX/Tx of the ESP-01.
On the ESP-01, both Vcc and CH-PD need to be connected to 3.3V DC (red wires) and GPIO0 needs to be connected to ground as well (brown/bottom wire).
As mentioned earlier, by grounding GPIO0 it is being pulled down to low which makes it boot into programming mode.
This board will allow the ESP-01 to boot up in program mode, and only program mode. It works well, but when it comes to testing, the ESP-01 has to be transferred to another board.
Rebooting is also only possible by disconnecting the USB cable from the FTDI USB to TTL serial converter module(i.e. disconnecting the entire setup, which often crashes the operating system).
To overcome these shortcomings, a reset switch and an SPDT slide switch can be added:
To be able to reset the board, a tactile pushbutton is wired between the ESP-01’s GND and the RESET pin (purple wire). The tactile button should be normally open (NO) so that when it is pressed, the connection is made.
Finally, an SPDT slide switch can be used to connect GPIO0 to ground (or not). This will allow switching between program mode and normal boot mode. After switching, the reset button can be pressed to enter that state.
Programming can start immediately after all the components have been added to the breadboard.
Conclusion
This post showed how to connect the ESP-01 module to a breadboard and FTDI programmer. By using 2 10mm 4 Pin 2.54mm stackable long legs female header connectors and the correct pinout, the ESP-01 can be connected to a breadboard for prototyping.