I2C pullup resistors - 1 master with 6 Slave

Hallo,
I have a circuit (I2C) with one Master (Ardu Mega) and 6 Slaves (Ardu mini pro).
I found out that you normally use 4,7KOhm resistors.
Can I use 4,7KOhm for my circuit?

Best regards

How long are the wires for SDA and SCL, and what kind of wires or cables are used ?
If they are very short then 4k7 is okay.

Worst case, you need a slightly stronger pullup... so you grab a 3.9K instead.

But keep in mind that (to be helpful...) many suppliers of small boards add integrated pullups on the boards but you really only want the bus to be "pulled up" in one place.

If your slaves have integrated pullups, consider finding a way to disable them. (de-solder)

The cable (SDA and SCL) are 8 cm long between each devices. Total 40 cm long. Cross-section is 0.14mm²

And the pieces of cable are not flat ribbon cable with SDA and SCL next to each other ? Because SDA and SCL next to each other in a ribbon cable is not good.
The 4k7 is okay. A little less is a little better, so 3k9 is also okay, or even 2k7 or 2k2 if you want to run the I2C bus at 400kHz.

It’s not flat ribbon, its normal round cable

I found this: pullup resistor value for I2C | Forum for Electronics

A pullup resistor of 1k is outside the specifications for the I2C, don't use such a low value.

Here is a super awesome tutorial : Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino

What is important is the capacitance of the wires. You want a low capacitance.

With ribbon cables the wires are very close and so has a high stray capacitance. Ordinary wires just floating above the board are good.

Thank you for the answer.

My last question is, is this wiring ok?
Google says yes

http://www.pixhost.org/show/67/31081168_w1-kopie.jpg

Yes, that's okay. The Arduino Mega has the I2C at other pins.

The Arduino Mega has 10k pullup resistors on the board, and every Arduino has internal pullup resistors enabled for I2C. Your total pullup will be: 4k7 // 10k // 7 times 50k = 2k2
Calculation : 1/(1/4.7 + 1/10 + 7/50) - Google Search

and every Arduino has internal pullup resistors enabled for I2C.

Not quite right.
The standard I2C library distributed with the IDE does this. There are other libraries like:-

It has other advantages too, like being able to transfer much more data at a single call, and also change the bus speed.

and also change the bus speed.

News : now TwoWire class has a function "setClock" regrettably undocumented.

file Wire.h

public:
TwoWire();
void begin();
void begin(uint8_t);
void begin(int);
** void setClock(uint32_t);**
./././././

Wire is an auto instancied object of TwoWire class
file Wire.h :

class TwoWire : public Stream
{
./././
}

extern TwoWire Wire;

News : now TwoWire class has a function "setClock" regrettably undocumented.

If it is undocumented then for all intents and purposes it isn't there.

Standard I2C devices are 100khz/400pf/3mA.
AFAIK Arduinos are able to match FM+ I2C devices (400khz/4000pf,30mA).
Much lower value pullup resistors are allowed (<330ohm).
Google "Fast Mode Plus I2C". There is an NXP document explaining the limits.

40cm of wiring shouldn't be a problem with the Mega's 10k onboard pullup resistors and the other internal ones.
If your wiring is ok, no extra resistors should be needed.
Leo..

@Grumpy

If it is undocumented then for all intents and purposes it isn't there.

If I translate correctly your words in French (I can mistake) : this function is not documented so do not use it

I don't agree
Question: who is responsible for Wire -> I do not think it is Arduino because Wire belongs to Wiring IDE.
IMHO Wire authors have improved Wire class, but Arduino Web responsibles did not realize it and did not report.
It is an issue.

@Wawa
NXP UM10204

  1. Bus speeds
    Originally, the I2C-bus was limited to 100 kbit/s operation. Over time there have been
    several additions to the specification so that there are now five operating speed
    categories. Standard-mode, Fast-mode (Fm), Fast-mode Plus (Fm+), and High-speed
    mode (Hs-mode) devices are downward-compatible — any device may be operated at a
    lower bus speed. Ultra Fast-mode devices are not compatible with previous versions
    since the bus is unidirectional.

Bidirectional bus:
– Standard-mode (Sm), with a bit rate up to 100 kbit/s
– Fast-mode (Fm), with a bit rate up to 400 kbit/s
– Fast-mode Plus (Fm+), with a bit rate up to 1 Mbit/s
– High-speed mode (Hs-mode), with a bit rate up to 3.4 Mbit/s.

Unidirectional bus:
– Ultra Fast-mode (UFm), with a bit rate up to 5 Mbit/s

AVR microcontroler supports data rates up to 400 kHz (Datasheet)
I use the Wire setClock function to test I2C ( two nano one master and one slave). I2C works fine until 533 kHz.

Grumpy_Mike:
If it is undocumented then for all intents and purposes it isn't there.

Some people would say if it is in the code it is documented. Header files are human readable. Maybe poorly advertised would be a better description?

Though, I don't see that functin on the github version:
https://github.com/Seeed-Studio/LinkIt-ONE-IDE/blob/master/hardware/arduino/mtk/libraries

/Wire/Wire.h

TwoWireStatus status;

// TWI clock frequency
static const uint32_t TWI_CLOCK = 100000;

// Timeouts (
static const uint32_t RECV_TIMEOUT = 100000;
static const uint32_t XMIT_TIMEOUT = 100000;

If I translate correctly your words in French (I can mistake) : this function is not documented so do not use it

No you do not translate my words correctly.

If it is not documented, then nobody can use it because nobody knows about it. It is a secrete.

Some people would say if it is in the code it is documented.

Just because some people say something does not make it true. Some people say we never went to the Moon but that doesn't make the proposal true.

Grumpy_Mike:
No you do not translate my words correctly.

If it is not documented, then nobody can use it because nobody knows about it. It is a secrete.
Just because some people say something does not make it true. Some people say we never went to the Moon but that doesn't make the proposal true.

The code is a document though. It is human readable. The point is what you consider documented. Again, I'm not sure where he gets his example from because the header file I pulled up doesn't seem to have that function. Probably a case of someone having modified or forked the 'official' IF there is an official header file?

outofoptions:
Again, I'm not sure where he gets his example from because the header file I pulled up doesn't seem to have that function.

I have the version of "Wire" included with the IDE V1.6.5, and it has the 'setClock()' function declared in the "Wire.h" header, (and defined in the cpp file, of course). It's not just 'forked' versions that have it.
It doesn't have a version number as such, but it was written in 2006, last modified 2012.

void TwoWire::setClock(uint32_t frequency)
{
    TWBR = ((F_CPU / frequency) - 16) / 2;
}

The one on GitHub that you linked to is for the Due only, not the standard distribution version for UNO, Mega etc:-

  • TwoWire.h - TWI/I2C library for Arduino Due
  • Copyright (c) 2011 Cristian Maglie c.maglie@bug.st.
  • All rights reserved.

Well, this is bizarre. I'm using the package for Debian 'stable'. I'm not even sure what version I'm using as they seem to have their own thing going on. Under version they have 2:1.0.5+dfcg2.-4 whatever that means. (I've been wondering if I should just download the tarball because I've thought about getting a DUE and this doesn't have 'board manager' in the tools) My .h and .cpp have the same dates as yours but nothing about the set clock.

Does your system have the a file like this?

/usr/share/doc/arduino-core/reference/Wire.html

I suppose we could consider that the official documentation. Still, there is evidence that maybe the file got added to without being documented at some point. I doubt the Debian packager simply stripped stuff out of the files.

Just looked. If you check out this page the wire library was changed as recently as ARDUINO 1.6.6 - 2015.11.03.

and

ARDUINO 1.5.7 BETA - 2014.07.07
Added Wire.setClock(..) method (Kristian Sloth Lauszus)

I guess I'll definitely downloading the tarball cuz I'm well behind based on that.