I am trying to connect the wireless module nrf24l01 with the gyro mpu-6050. Each works perfectly on its own. However, when connecting both to a single atmega328 (in order to send over wireless the gyro data), the code runs for between 30 seconds and 5 minutes.
I have seen many people have issues, none of the suggestions have worked, but it seems like it is more about the combination than the mpu itself. I have not had any errors, in that all the attempts have uploaded fine.
Some things I have tried (If you have experience with this device, im sure you will know what i am referring to ): Changing clock rates from 24 to 12, and 400 to 200 Changing the header file for mpu from 100 hz to 20 hz and back Adding pullup and pulldown resistors on sla/sda Using external variable power supply to make sure exact voltage Powering devices off arduino 3.3 and external 3.3 Running code without using serial reader on computer and just transmitting data
Edit:
After more debugging, I reduced the issue (I think). As each module works fine independently, i thought there could be a code issue. It seems though, that the issue is the combination of buffers. I don't think this is exactly right, but to us it seems like the gyro needs to run quickly to stop the risk of causing the arduino to hang(even though we clear the buffer).
The second part is the wireless. It seems like the code is looking by default for an acknowledgment the package is received. This slows down the broadcasting. So, if we disable the ack requirement, the gyro becomes stable. However, the receiver stops receiving any packets at all. If someone knows why, please explain.
So what we thought would work is by sending only some packets as the write with ack on a particular pipe. This way, the gyro will be able to run stably, and the data can sometimes be sent and we can see if this is really the problem. Again, this does not get recognized by the receiver at all.
Questions: Does it make sense that the buffers are working against eachother, and this is not solvable through hardware. Is there a clear reason why the receiver can not find packets that are being sent, just without the ack requirement?