Reading register off I2C slave Arduino

Hi, my first question.
I want to use Arduino as I2C slave. This Arduino will decode IR remote signals and store the decoded values. Whenever there is data it will interrupt

I want to use another Arduino as master. When the master sees the interrupt, it will read the values stored in the slave Arduino.

So the question is (by using the wire library) what address to use in the I2C message to tell the slave to send the stored data?

Thanks in advance.

If by "address" you're referring to the I2C slave address, then pick whatever 7-bit address you want.

If you only want to have one type of data exchange (ie. the slave only ever sends the last decoded IR signal when requested), then you can use a simple requestFrom() on the master and a onRequest() handler on the slave.

In the examples included in the IDE for the Wire library, the "master_reader" example would be representative of the master side. The "slave_sender" would be representative of the slave side. In the examples the slave address is 2 and the master and slave expect that 6 bytes will always be sent.

If you only have a single IR reader/decoder, then you may be better off reversing the master/slave roles. Let the decoder be the master and simply do a send to the "main" Arduino whenever a code is received. If the main Arduino is the slave, then you get the built-in interrupt that data has arrived and you don't have to use an external interrupt signal.

In this case the "master_writer" example would apply to your decoder, and the "slave_receiver" would apply to the main Arduino.

If you want to have a more complex interaction wherein the main Arduino can selectively request different types of data or operations, then you'll need to develop your own protocol that sends a command to the decoder which then interprets it and responds accordingly.

Many thanks for the clarification. I was referring to the "data" address in the slave. I can see that if I reverse the order, it would be simplier, but the master arduino has to be the master as there are other I2C slaves. I was thinking "data adress" is in other I2C devices like an I/O extender.

I think the requestFrom()/onRequest() would be sufficient, but I'll have to study that some more...

Thanks again.