open drain setup with level converter

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

open drain setup with level converter

Post by pidou46 » Tue Apr 27, 2021 9:45 am

Hello,

I have a device with momentary switches, this device is powered with 0/+5V.

I would like to simulate switch press with external mcu : ESP32

I know that esp32 pins can be configured in open drain mode to simulate a switch, but has the device to control is powered with grater voltage than esp32 should handle should I have to use a level converter?

My thought is that I should. I have some TSX0108E board laying around, according to data-sheet it should be fine to work in open drain mode but I doesn't manage to do it.
I don't understand how to make it work in open drain mode.

Do you have some advices for the setup ?

Should I connect the TSX0108E's OE pin to GND or VCCA with or without resistor ?

Should I drive the esp32 pin in open drain mode or as an output ?

How can I check if this setup work ?
With ohmmeter beetwen GND and TSX's output ? I should see the value changing from ~0_ohm and ~infinite_ohm right ?
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: open drain setup with level converter

Post by Roberthh » Tue Apr 27, 2021 11:48 am

I would use a single transistor/resistor inverter (e.g. 2N7000) in that case. Easy to set-up, robust.

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: open drain setup with level converter

Post by pidou46 » Tue Apr 27, 2021 12:55 pm

Thanks for your answer Roberthh,

Image

According to the 2n7000 specification, how should I wire it ?

1: Source -> ground
2: Gate -> Esp32 pin (set as an output 0 or 3.3v)
3: Drain -> switch pin
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: open drain setup with level converter

Post by Roberthh » Tue Apr 27, 2021 2:03 pm

Yes, that's a good wiring. You can also add a resistor between Drain and 5V, unless that already exists on the target board. So you would write a 1 to the GPIO port to get a low value and Drain, and a 0 to get a high impedance of the 2N7000.

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: open drain setup with level converter

Post by pidou46 » Tue Apr 27, 2021 3:58 pm

Thanks
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

Post Reply