Electronic – Slave wants to send data to Master in I2C

embeddedfirmwaremicrocontroller

I have an I2C interface with multiple Slaves and a Single master. If master wants to communicate with any of the slave it sends its address and read from the same.
But what should be done if one of the slave wants to communication with the master?

Best Answer

Case 1: Slave has an interrupt pin

You need to connect this interrupt pin to master microcontroller. Every time the slave has some data, it should raise an interrupt. At that point, master will read the available data.

Case 2: Slave doesn't have an interrupt pin

Polling is the only option in this case. Master keeps reading all the slaves at regular interval and keeps comparing the received data with old one. If the data has changed, master will take appropriate action. You need to decide the interval according to your application.