this is my setup: I have an arduino uno + mpu-6050 + nrf24l01 all attached together and am transmitting data from that mpu-6050 to another arduino with an nrf24l01 attached to it. I got the arduinos to communicate with each other and transmit data ( ypr) wirelessly but it's still laggy and jumpy. Before I was getting FIFO overfull messages but I managed to somewhat fix that. Yet the data being transferred is still not running to stable nor smoothly. PLEASE HELP ME find the problem why these arduinos aren't transferring data fluently and smoothly. I posted the Receiver and transmitter codes down below. Also, I am illustrating the code on Processing 3.2.3, hence the teapot parts. THANK YOU
**************************RECEIVER*****************************************
{
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// format used for the InvenSense teapot demo
#define OUTPUT_TEAPOT
RF24 radio(7, 8);//pin assignment
unsigned long t0;
unsigned long t1;
float ypr[3];
uint8_t teapotPacket[14] = { };
void setup()
{
pinMode(13,OUTPUT);
while (!Serial);
Serial.begin(115200);
radio.begin();
radio.openReadingPipe(1, 0xF0F0F0F0A1LL);
radio.openReadingPipe(2, 0xF0F0F0F0A2LL);
radio.startListening();
t0=0;
}
byte pipeNum=0; //variable to hold which reading pipe sent data
void loop()
{
t1=millis();
/*digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
*/
if (t1-t0>100){
if (radio.available(&pipeNum))
{
typedef struct YPR_RX {
int y;
int p;
int r;
} YPR_RX;
YPR_RX ypr_rx;
//radio.read(&ypr_rx, sizeof(ypr_rx));
// teapotPacket = new uint8_t teapoPacket(radio.getPayload)
radio.read(&teapotPacket, sizeof(teapotPacket));
// radio.read(&teapotPacket, sizeof(radio.getPayloadSize()));
// radio.SetDatarate();
uint8_t newTeapot[14] = {'$', 0x02, teapotPacket[2],teapotPacket[3],teapotPacket[4],teapotPacket[5],teapotPacket[6],
teapotPacket[7],teapotPacket[8],teapotPacket[9], 0x00, 0x00, '\r', '\n' };
Serial.write(newTeapot, 14);
newTeapot[11]++;
Serial.print(newTeapot[2]);
Serial.print("\t");
Serial.print(newTeapot[3]);
Serial.print("\t");
Serial.print(newTeapot[4]);
Serial.print("\t");
Serial.print(newTeapot[5]);
Serial.print("\t");
Serial.print(newTeapot[6]);
Serial.print("\t");
Serial.print(newTeapot[7]);
Serial.print("\t");
Serial.print(newTeapot[8]);
Serial.print("\t");
Serial.println(newTeapot[9]);
/*
Serial.print(ypr_rx.y);
Serial.print("\t");
Serial.print(ypr_rx.p);
Serial.print("\t");
Serial.print(ypr_rx.r);
Serial.print("\t");
Serial.println();
*/
t0=t1;
//Serial.println("X-acceleration");
//int number=atol(text);
//Serial.println(number);
//Serial.println((int)text);
//Serial.println(value);
//delay(100);
}
}
}
}
*********************************TRANSMITTER************************************
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// format used for the InvenSense teapot demo
#define OUTPUT_TEAPOT
RF24 radio(7, 8);//pin assignment
unsigned long t0;
unsigned long t1;
float ypr[3];
uint8_t teapotPacket[14] = { };
void setup()
{
pinMode(13,OUTPUT);
while (!Serial);
Serial.begin(115200);
radio.begin();
radio.openReadingPipe(1, 0xF0F0F0F0A1LL);
radio.openReadingPipe(2, 0xF0F0F0F0A2LL);
radio.startListening();
t0=0;
}
byte pipeNum=0; //variable to hold which reading pipe sent data
void loop()
{
t1=millis();
/*digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
*/
if (t1-t0>100){
if (radio.available(&pipeNum))
{
typedef struct YPR_RX {
int y;
int p;
int r;
} YPR_RX;
YPR_RX ypr_rx;
//radio.read(&ypr_rx, sizeof(ypr_rx));
// teapotPacket = new uint8_t teapoPacket(radio.getPayload)
radio.read(&teapotPacket, sizeof(teapotPacket));
// radio.read(&teapotPacket, sizeof(radio.getPayloadSize()));
// radio.SetDatarate();
uint8_t newTeapot[14] = {'$', 0x02, teapotPacket[2],teapotPacket[3],teapotPacket[4],teapotPacket[5],teapotPacket[6],
teapotPacket[7],teapotPacket[8],teapotPacket[9], 0x00, 0x00, '\r', '\n' };
Serial.write(newTeapot, 14);
newTeapot[11]++;
Serial.print(newTeapot[2]);
Serial.print("\t");
Serial.print(newTeapot[3]);
Serial.print("\t");
Serial.print(newTeapot[4]);
Serial.print("\t");
Serial.print(newTeapot[5]);
Serial.print("\t");
Serial.print(newTeapot[6]);
Serial.print("\t");
Serial.print(newTeapot[7]);
Serial.print("\t");
Serial.print(newTeapot[8]);
Serial.print("\t");
Serial.println(newTeapot[9]);
/*
Serial.print(ypr_rx.y);
Serial.print("\t");
Serial.print(ypr_rx.p);
Serial.print("\t");
Serial.print(ypr_rx.r);
Serial.print("\t");
Serial.println();
*/
t0=t1;
//Serial.println("X-acceleration");
//int number=atol(text);
//Serial.println(number);
//Serial.println((int)text);
//Serial.println(value);
//delay(100);
}
}
}