I2C routing

Hello, I have routed I2C lines as shown:


The circuit with resistors and mosfets is a level converter

Here is an image with the front layer visible

Will there be any problems with this? The trace below the I2C lines is the data line of a DHT22 (Digital Humidity and Temperature sensor with single wire communication)

Thanks!

Not sure without seeing a schematic, but you might struggle with MOSFET level shifters on I2C.

The data line has to be bidirectional so that the slave can at least ACK a byte.

Depending on voltages and part specs, you might not need it. A lot of 3.3v micros have 5v tolerant pins for I2C, and a lot of 5v slaves will have a Vih low enough for a 3.3v ‘1’.

Ahh sheesh, mosfet level shifting for i2c was first proposed in 97 by Philips, who designed i2c a few years prior. Fully bidirectional. Use low vgsth devices.

DSA-492462.pdf (80.9 KB)

3 Likes

Well looks pretty decent, though clearance kinda tight near a sot23 and does your i2c go to wrong pins at the right, or maybe silk is wrong?

I used the DHT on some balloon flights – giant package and a goofy-ass interface but worked pretty well.

There is nothing special about routing I2C, it’s pretty much low speed signals and without steep flanks. If you want to improve it, then move those lines apart from each other to reduce capacitive coupling.

For the rest, your GND plane is quite bad. Pretty much random routing and what’s left is turned into pieces of GND plane. Learn what the use of a GND plane is, why it is important, and how to do it properly on a PCB. In short, your circuit will probably still work, but it’s horrible for EMC.

I’m using RPi4 and Arduino. It seems RPi is not 5V tolerant.

Yeah I changed the pins later and forgot to change the silkscreen. Thanks

Well, I used GND vias for that. Don’t know if that’s bad. Can you suggest me how to route (these are all low frequency signals from sensors by the way). or suggest resources where PCB routing is given in detail? Thanks

Oh I need to separate the I2C lines with GND in between? How much space do you suggest?

The first goal concerning GND, is to have a single continuous GND plane on one of the layers (Usually bottom, but because you already have SMT stuff on the bottom layer (Why?) using the Front layer in this case may be a bit simpler. In a 2-layer design this is often not possible. The next best is (already a compromise) to keep all interruptions of the GND plane as few and as short as possible (less then 5mm or so)

Rick Hartley has made an excellent youtube video about GND planes. It is 2 hours and some 9 minutes long, and it is worth watching a few times. That is how important GND planes are in a PCB design.

Using via “stitches” to connect a patchwork of GND sections together is far from ideal, but still better then nothing.

It’s not the “frequency” of signals, but the steepness of signal flanks that counts. Arduino Nano is a fairly old and low speed microcontroller, and it’s edges are not particularly fast, the edges from the Raspi would be a lot faster. For your project, the cables hanging off the board are probably a bigger issue. They both easily pick up noise and work as antenna’s. For a robust / industrial level of PCB design, you have to consider all such things (for example add series dampening resistors and TVS diodes), but for some hobby level tinkering, it’s mostly “meh, it probably works without such stuff”.

For I2C the main goal is to reduce capacitive coupling. You do not have to put GND in between the wires, but separating them by a few mm is good practice. With I2C you should also always verify that your pullups are strong enough to ensure data integrity for your signals. If you have an oscilloscope, you should definitely verify this. If you don’t have an oscilloscope, consider buying one. (But buy something decent, anything below EUR250 is probably more of a toy then an oscilloscope).

Just a quick question, why not GND on both planes?
As for only components on the bottom side, I thought it might reduce costs. There’s just not enough room to fit them all on the top

Thanks for that - Learn something new every day!

I followed your tutorial about database libraries yesterday, and it worked a treat. Well written, with plenty of supplementary screen shots. You should start a whole series of short tutorials - maybe call them the “Oh Shish” series, to be read munching a kebab.

I’ve never really had to mix logic voltage levels, especially on comms buses like I2C.

1 Like

I have used the mosfet level shifter in several designs, it works reliably