Hello,
I'm using 1 master and 17 slave arduino pro mini. These board communicating via i2c but sometimes later stopping the communication. I'm thinking about this problem caused by pull up resistor. can you help to me this problem ? best regards...
Hello,
I'm using 1 master and 17 slave arduino pro mini. These board communicating via i2c but sometimes later stopping the communication. I'm thinking about this problem caused by pull up resistor. can you help to me this problem ? best regards...
sencersoylu:
I'm thinking about this problem caused by pull up resistor.
18 Arduinos with default internal pull up by the wire library already adds up to the maximum of 3mA of standard I2C.
I2C is basically a short-distance protocol. Need to know the total length and type of wiring, and how it is connected (star, inline).
Tell us more about your project, after reading the "How to post" guidelines.
Leo..
Wawa:
18 Arduinos with default internal pull up by the wire library already adds up to the maximum of 3mA of standard I2C.
I2C is basically a short-distance protocol. Need to know the total length and type of wiring, and how it is connected (star, inline).
Tell us more about your project, after reading the "How to post" guidelines.
Leo..
Thanks for your quick reply Leo. This is my first post thanks for suggestion. Each device has 50cm cable. I connected all devices like parallel.
17 * 50cm = 8.5m. I suppose you mean 'star' with parallel. The master being in the centre.
Never tried I2C comms with that much wiring.
Could be problematic, even with low capacitance wire.
I would have used twisted/unshielded cat-5 (or cat-6), with SCL and SDA on separate pairs (combined with ground). Did you also share 5volt/ground with the master/slaves.
Why did you use this setup.
Leo..
Yes all power supply shared and cable has shielded.
I'm curious about this because I am considering an application which could involve a maximum of 16 I2C slaves (a telephone exchange) but it won't involve so much wiring between the master and the slaves as you have.
@Wawa has already pointed out that the I2C library switches on the pullup resistors on the I2C lines. In your case 18 times approx 30k. That is about 600 ohms.
You can try switching the pullups off on all the slaves by adding this after Wire.begin() in the slave sketches:
// from https://github.com/arduino/ArduinoCore-avr/tree/master/libraries/Wire
// deactivate internal pullups for twi.
digitalWrite(SDA, 0);
digitalWrite(SCL, 0);
and then add two external pullups on the master A4 and A5 of say 2k.
You can also try reducing the I2C clock speed. See Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino and look/search for register TWBR
30k / 18 is 1k66 on my calculator, and just ok for standard I2C (3mA, 400pf).
But an Arduino can do FastMode+ I2C (30mA, 4000pf), so no need to disable internal and still ok to add some external pull up (1k?) to the master.
Shielded cable could be bad in this case. It increases wire capacitance.
Post exactly what you have, and how you have connected it, so we can stop guessing.
void setup() {
Wire.setClock(100000); // is the default speed. Could try to halve that.
}
Leo..
I made an error with the formula for resistances in parallel. @Wawa has the correct value. Sorry.
Wawa:
30k / 18 is 1k66 on my calculator, and just ok for standard I2C (3mA, 400pf).
But an Arduino can do FastMode+ I2C (30mA, 4000pf), so no need to disable internal and still ok to add some external pull up (1k?) to the master.Shielded cable could be bad in this case. It increases wire capacitance.
Post exactly what you have, and how you have connected it, so we can stop guessing.void setup() {
Wire.setClock(100000); // is the default speed. Could try to halve that.
}
Leo..
Ok I will change pull up resistor with 1k. Is it need add setclock ? i know 100000 is default speed.
Don't need that setClock line if you're not going to lower it.
Are you sure the I2C wiring is the problem.
Did you start with one slave, and did that work ok.
Leo..
6v6gt:
I'm curious about this because I am considering an application which could involve a maximum of 16 I2C slaves (a telephone exchange) but it won't involve so much wiring between the master and the slaves as you have.
I'm curious about this as I work in telecoms.... Don't want to hijack this discussion too much though.
For you and the OP, I have I2C working over about 30m of cable with 5 slaves and it works fine. It does run at 15kHz though. I have not tested it to see at what frequency it starts to give errors.
PerryBebbington:
I'm curious about this as I work in telecoms.... Don't want to hijack this discussion too much though.
. . .
A winter project in the concept stage. A telephone exchange to interconnect my small (but growing) telephone collection. It will be dimensioned for 16 phones and will support DTMF dialling, although I may populate only 8 line interface circuits at first. I had the idea when I was doing this: Intercom using two old dial telephones - Exhibition / Gallery - Arduino Forum. I'll publish it when (or maybe if) it is realised.
Wawa:
Don't need that setClock line if you're not going to lower it.Are you sure the I2C wiring is the problem.
Did you start with one slave, and did that work ok.
Leo..
Hi wawa
i think if has wiring problem it doesnt work. All nodes is working when startup but sometime later stoping.