A footnote about ESP8266 5V tolerance

05.05.2022 16:28

The other day I've been reading the instructions for a project involving the ESP8266 chip. In the part that describes connecting one of the ESP8266's GPIO pins to a 5V logic level line this comment stuck out:

As the ESP8266 is 5V-tolerant, [...] there shouldn't be any issues, however I haven't had time to test this for longer periods of time. Therefore, if the ESP burns out after a while, just add a voltage divider or something.

It never occurred to me that the GPIO pins of the ESP8266 would be able to work with 5V levels directly. I've done a few projects with this IC and I always considered it a purely 3.3V device that requires a level shifter to work with 5V logic. Normally, 5V tolerance of pins is advertised in some prime real estate in a microcontroller datasheet. On the other hand, ESP8266's datasheet doesn't mention it explicitly. Even the specification of voltage levels for digital IO is kind of vague about it:

From the "Digital IO Pads" section of the ESP8266 datasheet.

Image by Espressif Systems

The table says that the maximum input voltage for a high logic level on a digital pin is 3.6V. However the paragraph below also talks about pins having some protection against over voltage. My understanding is that there's a circuit that shunts current from a pin to ground when the pin voltage reaches 6V, similar to a Zener diode. Snap-back might be a mistranslation of fold-back. In any case, the difference between 6V breakdown and 5.8V hold voltage doesn't seem that significant. What good is this protection if the maximum allowed voltage is only 3.6V?

After searching the web a bit I came across a 2016 post on Hackaday. The article and comments give a good overview of what's known about this. In short, official documentation is vague, experience on the topic is mixed but many people believe that pins are indeed 5V tolerant.

I wanted to quickly check this. As people discussed in the Hackaday comments, a digital pin that only accepts voltages up to the supply voltage will normally have an ESD protection diode connected from the pin to the supply. Such a pin will start sinking current when voltage on it exceeds supply plus a diode voltage drop. That is where the typical 3.6V specification for VIH maximum comes from: a 3.3V supply plus 0.3V Schottky diode drop. On the other hand, a pin that can tolerate higher voltages will instead have a Zener diode to ground, or some other circuit that performs a similar function. In that case, the pin will only sink current at higher voltages.

I connected a spare ESP-01 module to my curve tracer. I measured the I-V curve of the GPIO2 pin since that one is not connected to any external pull-up or pull-down resistors on this module. The module was powered from a development board with a 3.3V supply voltage. I used a simple Arduino program that just called pinMode(2, INPUT). This ensured that the pin was set to high impedance and not sourcing or sinking current, except for any protection circuit on it.

Measurements of the ESP8266 digital pad with a curve tracer, forward polarity.

This was the result of my measurement. In the forward polarity the pin started sinking significant current at around 6.6V. The slight current ramp at lower voltages is an artifact of my instrument and isn't a real current sinking into the pin.

I didn't see any fold-back characteristic. However I was using a 1 kΩ load resistance on the curve tracer. The load resistance prevents a rapid current increase during the measurement. This might have prevented the fold-back circuit from working and I didn't want to risk the chip by going to higher currents. In any case, the 6.6V threshold strongly points towards the pin not having an ESD diode to the supply line and hence being intentionally designed to handle higher voltages than 3.6V.

Measurements of the ESP8266 digital pad with a curve tracer, reverse polarity.

In the reverse polarity, the pin started to source current at around 0.5V, as expected for an internal diode connected from the pin to ground. This diode is also mentioned in the datasheet.

In conclusion, it seems that indeed the digital pins on the ESP8266 have provisions for tolerating voltages higher than the supply. This doesn't necessarily mean that they will also work reliably at those voltages. Even if they will, I would still want to avoid using 5V levels directly. The ESP8266 bootloader likes to put various pins in output mode. A 5V level on a 3.3V-powered output pin is certainly not healthy, regardless of whether the pin tolerates such a level in input mode.

This slide deck from ST goes into some more detail on how 5V-tolerant pins are implemented internally and lists some pitfalls associated with their use. Though I have no idea if Espressif used the same implementation approach as ST.

Posted by Tomaž | Categories: Analog | Comments »