2

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?

Harry Svensson
  • 8,139
  • 3
  • 33
  • 53
Delta
  • 513
  • 6
  • 20
  • 1
    115.2 kBaud is not really high speed. Here someone simulated the same circuit and found that it works comfortably even at 2 MHz: https://electronics.stackexchange.com/a/367055/31091 The link also contains a detailed explanation of the circuit and its frequency-limiting factors. – Geier Dec 25 '18 at 13:20
  • 2
    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. – Chris Stratton Dec 25 '18 at 14:11

1 Answers1

5

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.

Peter Smith
  • 21,923
  • 1
  • 29
  • 64
  • 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. – Chris Stratton Dec 25 '18 at 14:09
  • I had problems using a voltage divider. For some reason I could not exchange data through it. – Delta Dec 25 '18 at 14:30