1
\$\begingroup\$

I am trying to connect an ESP8266 module to an Arduino. Giving the fact that ESP8266 runs at 3.3V and the Arduino at 5V i need a logic level converter from 5V to 3V3.

Is there a way i can build one using discrete components? I searched the web and found recommendations for TXS0104E / 74LVC245 / BSS138, unfortunately none of the local shops sell them.

Although the 3.3V TX pin from the ESP8266 does not require a logic converter since Arduino will read the 3V3 signal as HIGH, i would like to add some protection for the wifi module. Is a 3.3V zenner diode a wise choice for this?

\$\endgroup\$
  • 1
    \$\begingroup\$ Sorry, I don't want to dig through a datasheet to figure stuff out that you should already have figured out: What is the data transfer rate? What rise and fall times are required? And do you need one-directional or bi-directional translation? \$\endgroup\$ – The Photon Feb 14 '17 at 16:47
  • \$\begingroup\$ Then please, both of you, by all means, skip this question. If you are so full of yourself that you feel the need to tell a newbie how wrong is he is that he omitted some specs, or how writing "3V3" instead of "3.3 V" deserves a downvote, you are clearly incapable of helping anyone, not to mention you don't understand the purpose of the voting system. Thanks again for everyone who took the time to answer my question. \$\endgroup\$ – private Feb 15 '17 at 10:42
  • \$\begingroup\$ @OlinLathrop I did it \$\endgroup\$ – FarO Feb 17 '17 at 18:48
  • \$\begingroup\$ For info: Arduino works at 3.3V as well, and you can run it at 16 MHz at 3.3V without issues (usually) if it's ok for you to run it out of specs. \$\endgroup\$ – FarO Feb 17 '17 at 18:49
  • \$\begingroup\$ @Olaf: Actually you didn't. "3V3" is still there. In any case, even if you were to fix it for the OP, it wouldn't mean anything. It only teaches the OP that other people will fix messes for him. He won't learn to do it right next time by being made to fix it this time. In this case, the OP spent more time reacting childishly instead of fixing the problem, so he clearly has no interest in better communication. \$\endgroup\$ – Olin Lathrop Feb 17 '17 at 18:55
1
\$\begingroup\$

You can use any N-Channel MOSFET, not just BSS138.
It is pretty simple. This is bidirectional level converter:

schematic

simulate this circuit – Schematic created using CircuitLab

UPDATE:
By "any" I meant any jellybean small signal mosfet. Simply with low Vgs voltage threshold.

\$\endgroup\$
  • 1
    \$\begingroup\$ You cannot just use any MOSFET; most have a too-high gate threshold. \$\endgroup\$ – CL. Feb 14 '17 at 18:19
  • \$\begingroup\$ You are right. I meant any jellybean small signal mosfet. I will update it. \$\endgroup\$ – Chupacabras Feb 14 '17 at 18:35
  • \$\begingroup\$ Will IRF510PBF / IRL540NPBF be a suitable replacement? \$\endgroup\$ – private Feb 14 '17 at 21:10
  • \$\begingroup\$ No, IRF510PBF / IRL540NPBF are not suitable. Those are power mosfets. They are beefy and costly to do just level conversions. IRL540NPBF will work, it has Vgs less than 2V. But it is better to use smaller mosfets for this task. \$\endgroup\$ – Chupacabras Feb 14 '17 at 21:18
  • \$\begingroup\$ I found one more that i think will work IRLU120NPBF and is 30% cheaper than IRL540NPBF. \$\endgroup\$ – private Feb 15 '17 at 9:09
0
\$\begingroup\$

Check if your inputs are 5V tolerant. If not, check if the ESP8266's inputs are diode protected first.

If not, I'd recommend connecting a diode between your 3.3V input and 3.3V supply (A on the input, K on the 3.3V supply).

You should also add a resistor in series with your 5V output to reduce the current when the 5V outputs a logic high.

You need to check however that you input accepts the resulting voltages etc

PS: This does not take many other aspects that you should take into account, like the signal frequencies for example.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.