SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By moscardo
#197322
Hi everybody and Merry Christmas to you all.
I've a question regarding the RaspberryPi 3 Model B.

In the installation I'm working on, I need to connect 8 of them and I must do this using the I2C protocol.
I'm using the I2C port 0 actually (pin 27 and 28, called ID_SD and ID_SC respectively) since I cannot use the other one.

I've tried to read as much documentation as I could about the topic and I know that these pins are not meant to be used this way:


Image


Nevertheless it (almost) seems to work and now I have the PIs acting as masters, pulling information from a single Arduino UNO board, which is their slave (poor guy :P )!


Image


My question is about the pullup resistors.

I know that the I2C bus drivers are “open drain”, so I must take care for the signal to return high when not in use.
The problem here is that Arduino and the PIs are operating at two different voltages (isn't it?).

As suggested by the same tutorial, in cases like this I can use the "trick" of putting the pullups on the lower voltage device (the RaspberryPi in my case).

The question is:

1. Do these (I2C 0) RaspberryPi pins already have their own internal pullup resistors? Just in case, can these resistors be enabled/disabled?

---

On the Arduino side, I know pins A4 (SDA) and A5 (SCL) already have their own internal pullups, or at least that's what I can say after reading the source code of the Wire library I'm using for the Arduino code.
See the begin and the end functions (inside the Wire.cpp file) which in turns call the twi_init() and twi_disable() functions (see utility/twi.c file).

Here the interested lines of code for twi_init():
Code: Select all
  // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);
and for twi_disable():
Code: Select all
  // deactivate internal pullups for twi.
  digitalWrite(SDA, 0);
  digitalWrite(SCL, 0);
---

If I will explicitly disabled the Arduino internal pullups via code (using the digitalWrite(SDA, 0) and digitalWrite(SCL, 0)), is this hardware configuration going to work (pullpus to 3.3V the Arduino side)?


Image


I'm mean, I've already tried it and it works but I'm not perfectly sure it is the right way to approach the problem. I don't know if I'm damaging my I2C Pi pins and consequently I don't know if this configuration will be sufficiently robust to last for hours/days/months;

The second question which naturally came out is:

2. Am I damaging my pins? Are these pins protected in some way? Do I risk to permanently damage them, maybe with some incorrect voltage on the I2C bus? ( I hope not but actually I think I've already damaged one of my pi using external pullups to 5V the Arduino side).


Sorry for my wall of text. I will highly appreciate any support!
Thank you so much and again
...Merry Xmas.

Nick
By paulvha
#197331
For I2C0 there has been an update. You will need the latest firmware however ( https://www.raspberrypi.org/forums/view ... 0#p1182316). The Arduino does NOT have pull-up resistors on I2C, It would otherwise interfere with the analog sensing. I2C1 (Pin 3 and 5) on the Raspberry have a 1K8 soldered pull-up resistors, I2C0 (pint 27 /28) do NOT. You will have to provide that separate to the 3V3