Arduino and ESP-01, voltage divider and pin pulled high

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
I have an Arduino Uno connected to an ESP-01 to provide a wifi connection.
A simple voltage divider (2k and 3k resistors) converts 3.3V on the GPIO pins on the ESP-01 to 5V on the Arduino pins.
The problem is that the ESP-01 pins are pulled low in this circuit and it won't boot properly. I tried a smaller resistor to pull pins high and it *seems* to work, but is there a downside to do it like that?
Or is there a better way to translate 3.3V to 5V? I realize that an output pin on the ESP-01 doesn't have to be translated to 5V to get an Arduino pin high, but input is my issue.
 

Papabravo

Joined Feb 24, 2006
21,225
That is because voltage dividers don't work the way you think they do with a low impedance load. What made you think they would work in this application? Did you do ANY analysis?
You need to use a level shifter. I recommend parts that work off of any supply voltage from 1.65 V to 5.5V with TTL thresholds (0.8V and 2V)

https://www.onsemi.com/pub/Collateral/MC74VHC1G50-D.PDF

1.6¢ each in quantity
 
Last edited:

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
That is because voltage dividers don't work the way you think they do with a low impedance load. What made you think they would work in this application? did you do ANY analysis?
I'm quite a n00b at electronics, that is why I ask...
The voltage divider works fine if i connect it *after* the esp has booted.
So, how shall I do it? I have a level shifter, but I don't know how to connect it...
 

Papabravo

Joined Feb 24, 2006
21,225
I'm quite a n00b at electronics, that is why I ask...
The voltage divider works fine if i connect it *after* the esp has booted.
So, how shall I do it? I have a level shifter, but I don't know how to connect it...
OK, so why are you trying to run a marathon, before you've learned to crawl and walk?
What is your level shifter. Can you provide a datasheet, or a link to one.
 

djsfantasi

Joined Apr 11, 2010
9,163
I have an Arduino Uno connected to an ESP-01 to provide a wifi connection.
A simple voltage divider (2k and 3k resistors) converts 3.3V on the GPIO pins on the ESP-01 to 5V on the Arduino pins.
The problem is that the ESP-01 pins are pulled low in this circuit and it won't boot properly. I tried a smaller resistor to pull pins high and it *seems* to work, but is there a downside to do it like that?
Or is there a better way to translate 3.3V to 5V? I realize that an output pin on the ESP-01 doesn't have to be translated to 5V to get an Arduino pin high, but input is my issue.
Just curious. Admitting that you are learning, I have question for you.

Do you understand how a voltage divider works when translating from a 5V input signal to a 3.3V output signal? If R1 and R2 form a voltage divider, what are a set of possible values that will make this work?

Now, imagine you have a 3.3V signal. Can you use a voltage divider to scale this up to a 5V signal? What is a possible set of values for R1and R2?
 

KeithWalker

Joined Jul 10, 2017
3,093
I have successfully interfaced 3.3 volt devices with a 5 volt arduino using a resistive divider. It works well once you have the right values for that particular device. It does take a little experimentation with the values because some data inputs draw a little more current than others. I have even used the arduino internal 10 Kohm input pull-up resistor with a 15Kohm resistor to ground, and on occasions I have got away with a single series 1Kohm resistor between the arduino output and the 3 volt device input.
You are correct about not needing anything in the lines from the 3 volt device to the arduino input. Level shifters are available but they are a pain to wire up to the two supplies. I have some but never use them. Keep experimenting.
Regards,
Keith
 

Papabravo

Joined Feb 24, 2006
21,225
As an aside, it might help you to realize that ALL the digital inputs you will ever see, beside all the ones you won't have at least two critical specifications:
  1. The minimum voltage the input will recognize as a '1'. In datasheets this value is called Vih (minimum voltage for input high)
  2. The maximum voltage the input will recognize as a '0'. In datasheets this value is called Vil (maximum voltage for input low)
These voltages are often referred to as "threshold" voltages.

If your next question is: "What happens in between the thresholds", then you're smarter than the average bear. (OK Yogi)
The answer is that the behavior is undefined or unspecified. This is not really a problem if the transition through the no man's land between the thresholds happens quickly enough. The next question is how quick is quick enough. I don't have a precise answer for all cases but it should be very much less than the period of the signal.
 

Papabravo

Joined Feb 24, 2006
21,225
I have successfully interfaced 3.3 volt devices with a 5 volt arduino using a resistive divider. It works well once you have the right values for that particular device. It does take a little experimentation with the values because some data inputs draw a little more current than others. I have even used the arduino internal 10 Kohm input pull-up resistor with a 15Kohm resistor to ground, and on occasions I have got away with a single series 1Kohm resistor between the arduino output and the 3 volt device input.
You are correct about not needing anything in the lines from the 3 volt device to the arduino input. Level shifters are available but they are a pain to wire up to the two supplies. Keep experimenting.
Regards,
Keith
Fine for hacking and experimenting. Bad for systems somebody might have to depend on with serious consequences for failure. I assure it is far less expensive to design for reliable operation than it is to get a field service call at 3AM.
 

Papabravo

Joined Feb 24, 2006
21,225
Because the pin on the ESP-01 has a path to GND that is in PARALLEL to the 3K. So tell me Herr Doktor, what is 3K in parallel with 220Ω ? Now what is the voltage on the ESP-01 pin? Hint: it is a good deal less than 3.3 volts!!
 

ericgibbs

Joined Jan 29, 2010
18,849
hi S,
The 'active' level shifters are bi-directional,ie: 5V down to 3.3V or 3.3V up to 5V and also give a faster pulse edge.
For passive down shifters I use a 2K and 3k3 divider where appropriate.

Is the project now working.?
E
 

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
Either way I need to pull the pins high, would the correct way to do it be a smaller resistor to 3.3V?
Or use pins that don't need pullup?
 

ericgibbs

Joined Jan 29, 2010
18,849
hi S,
I use the Arduino running at 5V , with peripherals requiring 3.3V logic levels.
If the MCU to peripheral can tolerate a resistive divider I use a 2K/3.3k divider.
The MCU input pin can recognise a 3.3V incoming signal as a logic High.

For SPI, which are running at say 20MHz , I find the active BSS138 level shifter gives a more reliable result.

Don't use very low values for the divider resistances.

E
 

KeithWalker

Joined Jul 10, 2017
3,093
I match resistive level dividers to devices by starting with resistors with a ratio of 2:3, e.g. 2.2K and 3.3K. I connect it across the 5 volt line with 2.2K to +. I then connect the device to the 3.3volt supply with 5V- and 3V- connected together. I connect a device input pin to the junction of the resistors and measure the voltage. If it is too low, I increase the value of the 3.3K resistor until I have the correct value to give approximately 3 volts at the junction. I then use that value of divider for all the input pins for that device. This has worked for me without fail.
Regards,
Keith
 

sagor

Joined Mar 10, 2019
910
5V from a pin on the Arduino and a 3k/2k divider will get 3.3V = high on the ESP-01. I don't see how that can fail. Enlighten me...
The circuit works, but I guess I'm learning something new.

The level shifter is this one (sorry, swedish): https://www.electrokit.com/produkt/nivaomvandlare-2-kanaler-bidirektionell/
Tried it but it does nothing. Might be dead...

And this is all learning/fiddling/tinkering.
From that same web site, I use an identical bi-directional level shifter similar to:
https://www.electrokit.com/produkt/nivaomvandlare-4-kanaler-bidirektionell/
for my NEO-6M GPS module to Arduino Mega2560. Works fine at 19200 baud. People say the GPS module is "tolerant" of 5V, but I just didn't want to risk "bad electronics". The one you show seems to have separate RX/TX connections, but that makes me wonder if it really is bi-directional or not.
 

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
From that same web site, I use an identical bi-directional level shifter similar to:
https://www.electrokit.com/produkt/nivaomvandlare-4-kanaler-bidirektionell/
for my NEO-6M GPS module to Arduino Mega2560. Works fine at 19200 baud. People say the GPS module is "tolerant" of 5V, but I just didn't want to risk "bad electronics". The one you show seems to have separate RX/TX connections, but that makes me wonder if it really is bi-directional or not.
The RX channels on mine are not bidirectional, they only consist of voltage dividers, to convert 5V to 3.3V.
 
Top