I v been working with I2C for a while now. Can the slave decide when to pass data? Obviously the master is the device that normally decides when to request data but shouldnt it be the other way around? If a slave device is typically used to collect data, then when that data is available, send it to the master.
So as usual with programming i v tried to work around this. I have tried setting a boolean variable on the slave to only allow the data to send when i want. So the master is set to constantly request data from the slave but in the slave method "onRequest" i only allow data to send when a boolean variable is true. This sometimes has unexpected results which I tried setting the boolean to volatile as its a changing variable in an interrupt but still get strange results.
How are people generaling sending from a slave WHEN you want to? I thought there would be an easier way of doing such a basic task?