I have been working on a project where i have 2 arduinos, one gets a data from nrf24l01 module (i2c slave) and the other one (i2c master) requests the received data via i2c and controls 4 motors depending on the nrf24l01 data. The problem is the following: i know that slave receives data from nrf24l01 as it should, so no problem there, but when the master requests data (exactly 4 bytes) the slave sometimes sends identical bytes - all the exact value the last array byte holds. Sometimes it works perfectly, but then sometimes it happens one transmittion is successful but the second one is false, sometimes it happens all of the sent data is false.
I have both i2c wires pulled up with two resistors, both 3K3.
The way this works exactly is - the slave first gets a value from radio module, then signals the master that its ready for transfer (i did this so the master doesnt interfere with slave while its getting info from radio) . When the master sees the signal is high, it requests data. When data is transfered the slave turns off the signal and goes on to get data from radio again. So slave loops like that. In the meanwhile, when master gets the data from the slave, it then processes the data and makes an output (at this moment its just serial.print).
I will also post the code and the serial output.
Some things to note:
The rate of successful transfers vs the false ones also depends on which serial prints i comment/uncomment. So i assume it has to do something with timing?
master.ino (2.35 KB)
slave.ino (1.29 KB)
