Running I2C signals through the load side of a relay?

Hello everyone!

I'm not new to electronics, but this is my first time messing round with I2C and relays. I was wondering if I could run I2C signals through the load side of the relay and they still come out properly and working. It is a solid state relay if that makes a difference. Could be a dumb question but I just want to make sure. Thanks.

Likely not. What are you trying to accomplish with the relay?

I need to be able to swap between two I2C signals with the press of a push button.

Solid state relay, unlikely. Mechanical relay possibly with the likelihood of problems, such as the bus locking up.

I can think of no good reason to do this. Please describe your project.

Because the 2 signals are coming from two i²c devices which have the same address and cannot be changed?

If so, use a tca9548a multiplexer.

Thanks for your interest. I am making a project where I have a RTC and an OLED display on an Arduino Pro Mini. I need to have a momentary push button that when pressed switches to the RTC lines for the duration of the press. I looked into creating an I2C bus so I could have both at the same time and just switch in code, but I heard that it gets complicated when programming. I also have no clue how to even go about an I2C bus and what resistors etc I would need to create one.

The I2C bus is a bus. That means that several devices can coexist on the bus as long as each device has a unique address. There should be no problem having the RTC and OLED on the bus at the same time.

It makes it much easier to program for a RTC or a LCD if you have a proper library for that particular device. Then the library will have example code showing how to set up the code to talk to the I2C bus and the device.

Post part numbers, data sheets or technical data showing what exact parts that you have and we can recommend appropriate libraries.

Thanks so much, I will find them now.

OLED: AZDelivery 1.3-inch I2C IIC OLED Display SH1106 128x64 (https://www.amazon.co.uk/dp/B07FYG8MZN?psc=1&ref=ppx_yo2ov_dt_b_product_details)

RTC: Adafruit DS3231 Precision RTC Breakout ADA3013 (Adafruit DS3231 Precision RTC Breakout | The Pi Hut)

Board: Arduino Pro Mini 3.3v 8Mhz (https://www.amazon.co.uk/dp/B01DUSDQQ8?psc=1&ref=ppx_yo2ov_dt_b_product_details)

No, you won't need that.

No, it's easy.

2 wires. The devices probably have their own resistors fitted, and if so you won't need to add any.

Oh okay. I was told it got difficult in programming but I believe you over the 6 year old YouTube video I found. How do I join them together? Do I literally just solder both of them onto my board?

The schematic for the Adafruit RTC is here

You can see that it has 2x 10K pull-up resistors connected to the i²c pins.

The OLED display probably has something similar but there is no schematic provided.

What board? Stripboard?

My Arduino.

It can get a little more difficult if each of the devices don't have different addresses from each other, but in your case they do have different addresses.

If they did not have different addresses, and could not be configured to have different addresses, then you would use the multiplexer I suggested earlier. I had to guess what your problem was because you gave so little detail in your question.

Sorry if I'm not being super clear. Its my first post on this forum and I keep forgetting to add all the necessary detail.

You mean your Pro Mini?

No, you cannot solder the other devices directly to it, the pins would not line up!

You could use wires, but that would be just a mess, and could easily break.

I suggest a piece of stripboard for the final build.

But for now, build your prototype on a breadboard.

Oh okay. Good that I came here before starting. I will definitely build my prototype on a breadboard. I always do.

1 Like

Soldering is going to be difficult because its all going to be condensed into a 36x38x12mm box.

In electronics we usually will build the circuit using a convenient method, like a solderless breadboard, for development and testing and when that is done to satisfaction, condense the circuit down and build the final version on strip board or a purpose made PC board. Get it to work first then worry about packaging.