Language: EN

detalles-del-esp8266-diferencias-con-arduino

Hardware details and pins of the ESP8266

We continue with the SoC ESP8266 to discuss some of the hardware details of the ESP8266 and ESP12E (in the previous post we saw their pinout and that they are essentially equivalent), and their differences compared to an Arduino board.

The first thing to note is that the ESP8266 lacks many hardware functions that Atmel processors include. Along with the Wi-Fi management, the SoC has to divide its resources among all these functions. Even though it is faster than an Arduino, it is an overload of work, which in some applications can be a problem.

The next thing to point out is that, as we saw in the introductory post, the ESP8266 lacks internal Flash memory. The memory where we store the program is included in the module, but outside the SoC, and they communicate with each other via SPI. This means that there are modules with different amounts of memory, and we will not be able to use the GPIO pins that communicate with the memory (we will see this below).

Power Supply

The power supply of the ESP8266 is at 3.3V, supplying a voltage higher than 3.6V will destroy the SoC. Although many development boards include voltage regulators to power the board at 5V, or from the USB.

Regarding whether the rest of the ESP8266 pins are tolerant to 5V, there has been much debate. According to the Datasheet (which changed depending on versions) it was not very clear, but it was understood that they were not. However, currently, statements from Espressif and user experiments allow us to say that the GPIO pins of the ESP8266 are tolerant to 5V when functioning as digital input.

The maximum current that the digital pins can supply or absorb is 12mA. In comparison, most Arduino models can supply 20-40mA.

Regarding the analog-to-digital converter (ADC), the maximum voltage they can register is 0-1V. Supplying more than 1V to the ADC will damage it. However, some development boards include dividers to expand the range to 0-3.3V. You will have to check the ADC measurement range on each board.

The CHIP_EN pin controls the on or off of the SoC, being on when it is in HIGH. The EXT_RSTB pin controls the Reset of the ESP8266, activating when it is in LOW.

Boot

The ESP8266 has 3 boot modes:

  • UART Bootloader, to upload a program via UART to the flash memory.
  • Boot Sketch, executes the last program uploaded to the flash memory.
  • SDIO, which is not used when programming with Arduino.

To start in one mode or another, the pins GPIO15, GPIO0, and GPIO2 must be properly configured according to the following table:

ModeGPIO15GPIO0GPIO2
Uart Bootloader0V0V3.3V
Normal Boot0V3.3V3.3V
SDIO3.3Vxx

In most development boards there will be systems that manage the state of these pins for us. However, whether we want to use the ESP8266 (or the ESP12E) independently, as in the case of a development board, we must take the following into account:

  • GPIO15 is always pulled down, so we cannot use its Pull-Up resistance.
  • GPIO0 is set to HIGH during operation.
  • GPIO2 cannot be set to LOW during boot.

Connectivity

Digital Inputs and Outputs (GPIO)

The ESP8266 has 17 I/O pins (GPIO, General Purpose Input/Output pins). These can act as output providing a voltage of 0V or 3.3V (LOW and HIGH). When acting as input, they can recognize a voltage of 0V or 3.3V supplied to the GPIO.

When acting as an output, the maximum current that each GPIO can supply (or absorb) is 12mA.

As previously mentioned, currently we can say that they are tolerant to 5V (although I do not take responsibility for blowing up your board), so using an input to measure a voltage of up to 5.8V should not damage it.

Regarding internal Pull resistances, like Arduino, the pins GPIO0 to GPIO15 have Pull-Up resistances. While GPIO16 has a Pull-Down resistance.

In addition, of the 17 GPIO we cannot use all of them. In fact, we can use quite a few, which is another important limitation compared to Arduino.

Analog Outputs (PWM)

Unlike Arduino, the ESP8266 does not have hardware PWM, instead it has to emulate it by software. This has the advantage that we can use PWM on all GPIO, but it also means a calculation load for the ESP8266. The default frequency is 1kHz, but it can be changed.

Analog Inputs (ADC)

The ESP8266 has a 10-bit resolution ADC. The ADC has its own pin, independent of the GPIO. The input range of the ADC is 0-1V, attempting to measure a voltage higher than 1V will damage the ADC. However, we have seen that many boards have dividers that expand the range to measure from 0-3.3V.

Communication

Serial (UART)

The ESP8266 has 2 UARTs by hardware:

  • UART0 on pins 1 and 3 (TX0 and RX0).
  • UART1 on pins 2 and 8 (TX1 and RX1).

However, pin 8 is used to connect to the flash memory so, in practice, the UART1 port can only use pin TX1 (it can only send, not receive).

On the other hand, UART0 also has access from pins 15 and 13 (RTS0 and CTS0).

I2C Bus

The ESP8266 does not have hardware for I2C, so it has to emulate it by software. That means we can use I2C with almost any GPIO pin, but again it means a load for the processor.

By default, the library uses the GPIO4 and GPIO5 (SDA and SCL). The maximum speed is 450kHz.

SPI Bus

The ESP8266 has 2 SPI by hardware, but one is used to connect to the flash memory. Therefore, the ESP8266 has 1 available SPI (HSPI) that can act as both Master and Slave.

The pins used are GPIO14 (CLK), GPIO12 (MISO), GPIO13 (MOSI), and GPIO15 (SS).