
ESP8266 and Arduino, connection, pinout
- Tutorial
Hi geektimes . The ESP8266 theme, like IoT (the Internet of Things) , is gaining more and more popularity, and Arduino is already taking the initiative by adding these Wi-Fi modules to the list of supported boards.
But how to connect it to arduino? And is it possible to somehow do without arduino at all? Today, this is exactly what will be discussed in this article.
Looking ahead, I’ll say that there will be a second article, already more practical, on the topic of flashing and programming the ESP8266 module in the Arduino IDE development environment . But first things first.

This video fully duplicates the material presented in the article.
At the moment, there are many varieties of this module, here are some of them:

But the pinout ESP01, ESP03, ESP12:

* This picture can be viewed in good quality on off. pighixxx.com website .
Personally, I like version ESP07 the most. At least for the fact that there is a metal screen (it protects the microcircuit from external interference, thereby ensuring more stable operation), its own ceramic antenna, a connector for an external antenna. It turns out by connecting an external antenna, such as a biquadrat , to it, you can achieve a good range. In addition, there are many input / output ports, the so-called GPIO (General Purpose Input Output - general-purpose input-output ports), by analogy with arduino-pins.
Let's get back to ourrams Wi-Fi modules and Arduino. In this article, I will consider connecting the ESP8266 (model ESP01) to the Arduino Nano V3.
But, this information will be relevant for most ESP8266 modules and various Arduino boards, for example, the most popular Arduino UNO.
A few words on the ESP01 legs:

Vcc and GND (in the picture above are 8 and 1) - power , according to the documentation , from 3 to 3.6 V , and GND, can be applied to the Vcc leg ,- land (minus supply). I saw how one person connected this module to two AA batteries (the supply voltage in this case was approximately 2.7 V) and the module was functional. But still, the developers indicated the voltage range in which the module should be guaranteed to work, if you use another, your problems.
Attention! This module is based on 3.3 V logic, and Arduino is mainly 5 V logic. 5 They can easily disable the ESP8266, so it needs to be powered separately from the arduino .
“There is a leg on my arduino where it says 3.3 V, why not use it?”
You probably think. The fact is that the ESP8266 is quite a gluttonous module, and in peaks it can consume currents up to 200 mA, and almost no arduino by default can produce such a current, unless the exception is Arduino Due , in which the current through the 3.3 V line can reach 800 mA with a margin which is enough, in other cases, suggest to use an additional stabilizer 3.3 V, for example AMS1117 3.3 in . Such a shaft both in China and here.

Leg RST 6 - is intended to be “iron” for rebooting the module, briefly feeding a low logic level to it, the module will reboot. Although I neglected this in the video, I advise you to “press” this foot with a 10 kOhm resistor to the power plus, in order to achieve better stability in the module, otherwise I rebooted from the slightest interference.
Leg CP_PD 4 (or in other words EN ) - serves, again, for the "iron" transfer of the module to energy-saving mode, in which it consumes a very small current. Well, again - it will not be superfluous to “squeeze” this leg with a 10 kOhm resistor to the plus of Pitalov. In the video, I stupidly shorted this leg to Vcc, because there was no such resistor at hand.
Feet RXD0 7 TXD0 2 - hardware UART, which is used for flashing, but no one forbids using these ports as GPIO (GPIO3 and GPIO1, respectively). For some reason, GPIO3 in the picture is not labeled, but it is in the datasheet:

By the way, the “Connect” LED is connected to the TXD0 2 leg , and it lights up at a low logic level on GPIO1, well, or when the module sends something via UART.
GPIO0 5 - can be not only an input / output port, but also put the module in programming mode. This is done by connecting this port to a low logic level ("pressed" to GND) and applying power to the module. In the video, I do this with the usual button. After flashing, do not forget to pull out the jumper / press the button (it is not necessary to hold the button during flashing, the module switches to programming mode when it is turned on, and remains in it until the reboot).
GPIO2 3 - I / O port.
And another important point, each GPIO Wi-Fi module can safely provide current up to 6 mAso as not to burn it, be sure to put the resistors in series with the input / output ports on ... Remember Ohm's law R = U / I = 3.3V / 0.006 A = 550 Ohms, that is, 560 Ohms . Or neglect it, and then wonder why it does not work.
In ESP01, all GPIOs support PWM, so you can connect an engine driver to our four GPIOs, that is, GPIO0-3, ala L293 / L298 and steer with two engines, for example boats, or make RGB Wi-Fi stray. Yes, yes, this module has a lot on board, and for simple projects, theviolinistArduino is not needed, only for flashing. And if you use ESP07 then there are generally ports almost like Uno, which makes it possible to confidently do without arduino. True, there is one unpleasant moment, ESP01 does not have analog ports at all, but ESP07 has only one, ADC is called. This of course exacerbates the work with analog sensors. In this case, an arduino analog multiplexer to help.
Everything seems to be explained by pinout, and here is the connection diagram of the ESP8266 to the Arduino Nano:

See the jumper on the Arduino Nano legs RST and GND? This is necessary so that the arduinka does not interfere with the firmware of the module, in the case of connecting the ESP8266 using the Arduino, a prerequisite.
Also, if you connect to Arduino - the RX module should go to the RX arduino, TX - TX. This is because the converter microcircuit is already connected to the arduino legs in a cross order.
An resistive divider consisting of 1 kOhm and 2 kOhm resistors (can be made of two 1 kOhm resistors in series by connecting them) along the RX line of the module is also important. Because arduino is 5 V logic and module 3.3. It turns out a primitive level converter. It must be, because the legs of the RXD TXD module are not tolerant to 5 V.

Well, you can do without arduino at all by connecting the ESP8266 via a regular USB-UART converter. In the case of connecting to arduino, we, in fact, use a standard usb and uart interface converter, bypassing the brains. So why spend money once again, if you can do without arduino at all? Only in this case, we connect the RXD module to the TXD converter, TXD - RXD.
If you are lazy to bother with connecting, messing around with resistors and stabilizers - there are ready-made NodeMcu solutions:

Everything is much simpler here, I stuck the cable into the computer, installed the drivers and programmed, just remember to use the jumper / button on GPIO0 to put the module into firmware mode.
Well, that’s probably all with the theory, the article turned out to be pretty big, and the practical part, ala firmware and module programming, I will publish a little later.
I, on my YouTube channel , opened a whole playlist dedicated to my videos on this Wi-Fi module. The plans have built a typewriter, or a boat, on Wi-Fi control, where instead of the remote control there will be a regular smart. But so far I have not come to this yet, so these are just plans for the future.
Continuation of this article.
Datasheets on:
ASM1117 3.3 B ;
ESP8266EX (microcontroller that is in the module) ;
More links:
Russian-speaking community on ESP8266 ;
Drawn schemes in the program Fritzing ;
Why many do not like Arduino ;
All my publications on geektimes .
By Sergey Sharekin, aka Mr Podelkin.
But how to connect it to arduino? And is it possible to somehow do without arduino at all? Today, this is exactly what will be discussed in this article.
Looking ahead, I’ll say that there will be a second article, already more practical, on the topic of flashing and programming the ESP8266 module in the Arduino IDE development environment . But first things first.

This video fully duplicates the material presented in the article.
At the moment, there are many varieties of this module, here are some of them:

But the pinout ESP01, ESP03, ESP12:

* This picture can be viewed in good quality on off. pighixxx.com website .
Personally, I like version ESP07 the most. At least for the fact that there is a metal screen (it protects the microcircuit from external interference, thereby ensuring more stable operation), its own ceramic antenna, a connector for an external antenna. It turns out by connecting an external antenna, such as a biquadrat , to it, you can achieve a good range. In addition, there are many input / output ports, the so-called GPIO (General Purpose Input Output - general-purpose input-output ports), by analogy with arduino-pins.
Let's get back to our
But, this information will be relevant for most ESP8266 modules and various Arduino boards, for example, the most popular Arduino UNO.
A few words on the ESP01 legs:

Vcc and GND (in the picture above are 8 and 1) - power , according to the documentation , from 3 to 3.6 V , and GND, can be applied to the Vcc leg ,- land (minus supply). I saw how one person connected this module to two AA batteries (the supply voltage in this case was approximately 2.7 V) and the module was functional. But still, the developers indicated the voltage range in which the module should be guaranteed to work, if you use another, your problems.
Attention! This module is based on 3.3 V logic, and Arduino is mainly 5 V logic. 5 They can easily disable the ESP8266, so it needs to be powered separately from the arduino .
“There is a leg on my arduino where it says 3.3 V, why not use it?”
You probably think. The fact is that the ESP8266 is quite a gluttonous module, and in peaks it can consume currents up to 200 mA, and almost no arduino by default can produce such a current, unless the exception is Arduino Due , in which the current through the 3.3 V line can reach 800 mA with a margin which is enough, in other cases, suggest to use an additional stabilizer 3.3 V, for example AMS1117 3.3 in . Such a shaft both in China and here.
Leg RST 6 - is intended to be “iron” for rebooting the module, briefly feeding a low logic level to it, the module will reboot. Although I neglected this in the video, I advise you to “press” this foot with a 10 kOhm resistor to the power plus, in order to achieve better stability in the module, otherwise I rebooted from the slightest interference.
Leg CP_PD 4 (or in other words EN ) - serves, again, for the "iron" transfer of the module to energy-saving mode, in which it consumes a very small current. Well, again - it will not be superfluous to “squeeze” this leg with a 10 kOhm resistor to the plus of Pitalov. In the video, I stupidly shorted this leg to Vcc, because there was no such resistor at hand.
Feet RXD0 7 TXD0 2 - hardware UART, which is used for flashing, but no one forbids using these ports as GPIO (GPIO3 and GPIO1, respectively). For some reason, GPIO3 in the picture is not labeled, but it is in the datasheet:

By the way, the “Connect” LED is connected to the TXD0 2 leg , and it lights up at a low logic level on GPIO1, well, or when the module sends something via UART.
GPIO0 5 - can be not only an input / output port, but also put the module in programming mode. This is done by connecting this port to a low logic level ("pressed" to GND) and applying power to the module. In the video, I do this with the usual button. After flashing, do not forget to pull out the jumper / press the button (it is not necessary to hold the button during flashing, the module switches to programming mode when it is turned on, and remains in it until the reboot).
GPIO2 3 - I / O port.
And another important point, each GPIO Wi-Fi module can safely provide current up to 6 mAso as not to burn it, be sure to put the resistors in series with the input / output ports on ... Remember Ohm's law R = U / I = 3.3V / 0.006 A = 550 Ohms, that is, 560 Ohms . Or neglect it, and then wonder why it does not work.
In ESP01, all GPIOs support PWM, so you can connect an engine driver to our four GPIOs, that is, GPIO0-3, ala L293 / L298 and steer with two engines, for example boats, or make RGB Wi-Fi stray. Yes, yes, this module has a lot on board, and for simple projects, the
Everything seems to be explained by pinout, and here is the connection diagram of the ESP8266 to the Arduino Nano:
See the jumper on the Arduino Nano legs RST and GND? This is necessary so that the arduinka does not interfere with the firmware of the module, in the case of connecting the ESP8266 using the Arduino, a prerequisite.
Also, if you connect to Arduino - the RX module should go to the RX arduino, TX - TX. This is because the converter microcircuit is already connected to the arduino legs in a cross order.
An resistive divider consisting of 1 kOhm and 2 kOhm resistors (can be made of two 1 kOhm resistors in series by connecting them) along the RX line of the module is also important. Because arduino is 5 V logic and module 3.3. It turns out a primitive level converter. It must be, because the legs of the RXD TXD module are not tolerant to 5 V.
Well, you can do without arduino at all by connecting the ESP8266 via a regular USB-UART converter. In the case of connecting to arduino, we, in fact, use a standard usb and uart interface converter, bypassing the brains. So why spend money once again, if you can do without arduino at all? Only in this case, we connect the RXD module to the TXD converter, TXD - RXD.
If you are lazy to bother with connecting, messing around with resistors and stabilizers - there are ready-made NodeMcu solutions:
Everything is much simpler here, I stuck the cable into the computer, installed the drivers and programmed, just remember to use the jumper / button on GPIO0 to put the module into firmware mode.
Well, that’s probably all with the theory, the article turned out to be pretty big, and the practical part, ala firmware and module programming, I will publish a little later.
I, on my YouTube channel , opened a whole playlist dedicated to my videos on this Wi-Fi module. The plans have built a typewriter, or a boat, on Wi-Fi control, where instead of the remote control there will be a regular smart. But so far I have not come to this yet, so these are just plans for the future.
Continuation of this article.
Datasheets on:
ASM1117 3.3 B ;
ESP8266EX (microcontroller that is in the module) ;
More links:
Russian-speaking community on ESP8266 ;
Drawn schemes in the program Fritzing ;
Why many do not like Arduino ;
All my publications on geektimes .
By Sergey Sharekin, aka Mr Podelkin.
PS
A board based on esp32 is already on its way:

http://www.pighixxx.com/test/2015/12/esp32-pinout/
Which is much cooler than esp8266, so we will soon see a boom, I think, of the IoT theme (Internet of things ) .

http://www.pighixxx.com/test/2015/12/esp32-pinout/
Which is much cooler than esp8266, so we will soon see a boom, I think, of the IoT theme (Internet of things ) .