i2c bidirectional voltage level converter (3.3v - 5v)

Thread Starter

robustcode

Joined Jun 3, 2021
2
I have an arduino uno and a 3.3v ic that communicates with i2c, but is only 3.3v compatible. I made a circuit following the diagram at this link: https://circuitdigest.com/tutorial/bi-directional-logic-level-controller-using-mosfet

The circuit seems to work fine when I test it with a multimeter, but when I plug in the i2c lines, and probe the arduino i2c pins, the data pin is not stable, and has a delta of 3.3v instead of 5v which shouldn't be happening. I took a screenshot of the osciloscope, I can also take a picture of my breadboard circuit although it is a bit messy. I am using the mosfet 2n3819 to change the logic level of the data pin and the clock pin has a voltage divider since it doesn't need to have bidirectional communication.
 

Attachments

Irving

Joined Jan 30, 2016
1,540
Your problem is the FET you are using. Its a depletion-mode J-FET not an enhancement-mode MOSFET. The J-FET is ON all the time, a -ve gate voltage turns it OFF. The BS170 device in the linked article is OFF normally, a +ve gate voltage turns it ON.
 

ElectricSpidey

Joined Dec 2, 2017
1,662
I don't know much about Arduino but wont the Arduino I2C pins see 3.3 volts as a logic high?

In that case you should only need 2 resistor pullups to 3.3 volts.
 

Irving

Joined Jan 30, 2016
1,540
I don't know much about Arduino but wont the Arduino I2C pins see 3.3 volts as a logic high?

In that case you should only need 2 resistor pullups to 3.3 volts.
The I2C data line is bidirectional so needs a voltage divider out bound, but that should work inbound as the Arduino input is Hi-Z. This is fine for low-speeds - 100kHz i2c should be ok. Higher speeds or long lines will need the more active solution.

1622745758021.png
 

ElectricSpidey

Joined Dec 2, 2017
1,662
That must be an Arduino thing, the platform I use never pulls any of the pins to VDD only to ground, and the high is provided only by pullups.
 

Irving

Joined Jan 30, 2016
1,540
Arduino GPIO outputs are CMOS totem pole, active pull-up/pull-down and can source/sink 20mA. Inputs are Hi-Z with <1uA input current and optional 100k pull-up.
 

andrewmm

Joined Feb 25, 2011
1,474
These sort of circuits used to be common,
but they are only so reliable, and forget it if you ever want multi master .

There are many IC I2C level translators,
some even buffer the signal, so you can extend the bus

example TCA9517
 

Irving

Joined Jan 30, 2016
1,540
These sort of circuits used to be common,
but they are only so reliable, and forget it if you ever want multi master .

There are many IC I2C level translators,
some even buffer the signal, so you can extend the bus

example TCA9517
Agreed, but if you're just driving the one i2c chip, 4 resistors work ok.

Which Arduino are you using, and what pins,
how have you declared the pins ?
You dont declare the i2c pins, you just include the Wire library.
 

andrewmm

Joined Feb 25, 2011
1,474
Agreed, but if you're just driving the one i2c chip, 4 resistors work ok.


You dont declare the i2c pins, you just include the Wire library.
re arduino and I2C pins
that was the way on the orriginal Arduinos like the Uno,
but now it depends how many I2C ports / alternate pins for the I2C you have

e.g..
the teensey 4.0 https://www.pjrc.com/store/teensy40.html
has 3 ports that can be selected,
which are addressed by the wire.setSDA and setSCL commands.

Even the old DUE had two I2C ports,
 

Irving

Joined Jan 30, 2016
1,540
re arduino and I2C pins
that was the way on the orriginal Arduinos like the Uno,
but now it depends how many I2C ports / alternate pins for the I2C you have

e.g..
the teensey 4.0 https://www.pjrc.com/store/teensy40.html
has 3 ports that can be selected,
which are addressed by the wire.setSDA and setSCL commands.

Even the old DUE had two I2C ports,
I have an arduino uno and a 3.3v ic that communicates with i2c, but is only 3.3v compatible.
 
Top