1

This topic have been covered in various places, but I still think it hasn't been thoroughly explained anywhere. Doing google search on connecting Arduino to Raspberry Pi via i2c gives for example, this page.

While apparently this should work, there is a factual error there: on arduino side, pins used for i2c do have internal pull ups, and they are activated by Wire library.

Digging further, I've found following information:

However, it turns out that these are weak (high-resistance) pull-ups; the Pi has strong pull-ups which dominate those on the Arduino, making direct connection safe.

What does safe mean? And how weaker are those pullups compared to raspberry pi ones?

Let's check:

  • rpi i2c pullup: 1K8
  • arduino i2c pullup: 20K-50K from datasheet (if I'm looking correctly, I'm using ATmega8), though the above page states 10K.

What can I make of those values? My (intuition rather than) basic knowledge hints me something along the lines:

If the i2c is floating, it means the 5V is connected with 3.3V and there are only those pullups along the way, so:

  • calculate voltage drop between 5 and 3.3: 1.7V.
  • calculate voltage drop across rpi pullup proportionally to voltage drop across arduino pullup: 1800 / 30000 = 0.06, meaning 0.102V across rpi pullup and 1.598 across arduino pullup, so the actual pulled up voltage is gonna be 3.3V + 0.102V = 5V - 1.598V = 3.402V?

Though I'm pretty sure I'm doing some terrible math here and someone is gonna have good laugh:)

So, my question is not whether it's safe (as it's been proved), but rather why is it safe considering the internet resources are inaccurate on this matter.

3
  • 1. And your question is? I have done this and it works. 2. What makes you think the Arduino pullups are enabled? Even if they were, I²C would not work reliably. 3. I haven't checked your calculation, but even if you put 3.402V it wouldn't matter. It only becomes an issue if the voltage exceeds a diode voltage drop.
    – Milliways
    Jan 14, 2015 at 3:19
  • Well, my question is to find out why is it safe, cause it's been tested and proven, yet always backed by some erroneous/informal claims. The pullups are enabled, check 'twi_init' helper function in Wire library source.
    – Bartosz
    Jan 14, 2015 at 6:10
  • You math seems correct. Try calculation the amount of current. It will be in the micro-amps. Combined with the low voltage, you get a few micro-watt in power. Not enough to do any kind of damage. I think that is how they came to the conclusion it's safe.
    – Gerben
    Jan 14, 2015 at 12:35

1 Answer 1

1

If you are sure to disable pull up on arduino side you are safe, as i2c works in open-drain mode, but the logic level "high" of arduino is about 3.2v, so it would be unstable.

Otherwise i2c pin of rasp are NOT 5v tolerant, so you must be sure the voltage on the bus does not exceed operative limit; as you calculated ~3.5v should be good on raspi, but please check on datasheet.

Also, you should check the total current on the bus, but as atmega resistor as so high,it should not pose a problem with raspi (but may give problem with passive i2c, that you can solve with a external pull up)

1
  • But I have no idea whether I calculated it correctly...
    – Bartosz
    Jan 14, 2015 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.