Switching between i2c and A4/A5

Hello!
I would like to know if you can read alternatively data from the i2c bus and the 6 analog inputs, on a Uno R4. Can the i2c lines be "silenced" so that A4 and A5 can do their analog input job, and then switch back to the i2c, reading only the dedicated sda/scl pins?
I tried, without success, things like :

Wire.begin()
// Using i2c
...
Wire.end()

// Trying to switch from i2c to Analog Input
pinMode(A4, INPUT); digitalWrite(A4, LOW);
pinMode(A5, INPUT); digitalWrite(A5, LOW);

From what I have read it is impossible for previous Uno versions, but hopefully it is different for R4.
Thank you

Welcome to the forum

If you tell us which R4 board you have I will move your topic to a more relevant forum category

What about the loading on the I2C buss (A4/A5) from the I2C modules?

I don't think that's feasible, as the I2C switching will mess up your analog signal and your analog signal will mess up the I2C.

More sensible solution: get a Nano, and use A0, A1, A2, A3, A6 and A7 for your analog readings leaving A4 and A5 free for I2C communication.

It is the R4 Wifi

You mean the resistances? I use 2 pull-ups (sda to 3.3V and scl to 3.3V), I haven't chosen yet, but it seems to work fine between 0.5 kOhm and 1 kOhm.

Yes, I thought about it... I will have too look into it. Thanks

Topic moved to the UNO R4 WiFi category of the forum

Hmm, actually with A4/A5 only, you can connect and handle either i2c or analog sensors, and with A4/A5 + sda/scl pins, you can do the very same thing?
If I understand it correctly, it seems strange that they added these 2 pins.

If the I2C device operates at 3.3v, you can use the 2nd I2C bus on the qwiic connector.

Awesome! I didn't know that there was a second i2c bus. I will try that soon : )
Thanks

I have the R4WiFi board, but I cannot check Wire1 functionality due to lack of the special QWIIC 4-pin Connector Cable. The Board could have a 4-pin normal header in parallel with QWIIC connector.

You do need to be careful, the I2C on the qwiic connector is not 5v tolerant.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.