I2C best practice

Hi Guys,

I'm about to setup a I2C network with 2 Arduino's in a master/slave configuration. The slave will have 2 interrupt driven sensors attached, and one sensor watched in the loop, to count pulses.

I need to get the counts back to the master. What is the best way to do this?

1) Slave sends every x seconds it's counter values to the master 2) Master polls every x seconds the slave upon which replies back to the master

Goal is to have a much resources available as possible on the slave for the interrupts (don't wanna miss pulses).

Master will also poll a bunch of 1-wire temp sensors, and probably have a RF433 transmitter and receiver on board. It will send all values (from the temp sensors and the counter coming from the slave) over serial to a database on a pc.

Any help from experienced people appreciated.

Greetings, EriSan500

Hi EriSan500.

Not overly experienced with i2c but i think you've answered your own question.

...in a master/slave configuration

The slave will only 'talk' when 'questioned'. That would lead to option 2.

2) Master polls every x seconds the slave upon which replies back to the master

My understanding is that a slave can not initiate a transmission. It could however 'ask' for attention with another wire connected to the master.

Jeroen

Just remember that I2C was developed for use over very short distances.

I2C is short for IC to IC so it's original intention was to facilitate communication between IC's on the PCB.

You will potentially invite trouble if you try to use I2C over longer distances.

Would 5-10 meter cause any problem?

EriSan500

Yes anything over a meter is a problem.