I need to connect ESP32 (3.3 V) and Arduino UNO (5 V) on the UART bus. I used to connect two devices through a 1k resistor and it worked. I want to make a reliable connection.

On the Internet, I found a matching circuit for UART levels based on a BSS138 transistor. enter image description here

Will this scheme work reliably at a transfer rate of 115200 BOD? If it were not, would you advise me a more reliable option?

  • 1
    \$\begingroup\$ 115.2 kBaud is not really high speed. Here someone simulated the same circuit and found that it works comfortably even at 2 MHz: electronics.stackexchange.com/a/367055/31091 The link also contains a detailed explanation of the circuit and its frequency-limiting factors. \$\endgroup\$ – Geier Dec 25 '18 at 13:20
  • 2
    \$\begingroup\$ One resistor is not really a proper solution except when you have a current rating for the protection diodes. But two resistors forming a voltage divider can be a fine solution - more definitive than your proposal except for things that need to run for a long time on battery. But a 5v Arduino wouldn't be suitable for that to begin with. \$\endgroup\$ – Chris Stratton Dec 25 '18 at 14:11

According to a quick simulation, the answer is yes. Note that I have not added any parasitics, but the outputs look ok.

There is an error in your schematic incidentally; the gate of the MOSFET needs to be pulled directly to 3.3V Schematic driving 3.3V side

Driving from the 3.3V side, 5V side output: 5V output driven from 3.3V side

3.3V output when driven from the 5V side has some overshoot (but nothing serious): 3.3V output when driven from 5V side

Timings set for 115200 bit times. The overshoot on the 3.3V side is due to the body diode of the MOSFET which is involved in down shifting but not in up shifting.

  • \$\begingroup\$ While it may work, it's worth noting that this will be weaker than a voltage divider solution on the high side, and not meaningfully better on the low side. \$\endgroup\$ – Chris Stratton Dec 25 '18 at 14:09
  • \$\begingroup\$ I had problems using a voltage divider. For some reason I could not exchange data through it. \$\endgroup\$ – Алекс Гарисон Dec 25 '18 at 14:30

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.