had never used .setRetries it before and saw it in a demo and looked it up on github had not saw the last statement about 15 max.
i did setup the radios like the pingpair example and they failed %100 of the time. it's a packet size issue so i had to change the packets and if i dont have * sizeof(byte) in there it fails. so as it stands only thing that works for the following sketchs is. SetpayloadSize(20 * sizeof(byte)); {anything above 20 works so 21 22 23 24}
TX
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(48,49);
void setup(){
Serial.begin(57600);
//**************Start Transiever (NRF24L01) config**************
printf_begin();
printf("\n\rRadio Setup\n\r");
radio.begin();
radio.setRetries(15,15);
radio.setDataRate(RF24_2MBPS);
radio.setCRCLength(RF24_CRC_16);
radio.setPayloadSize(24 * sizeof(byte));
radio.setChannel(100);
radio.setAutoAck(true);
radio.openReadingPipe(1,0xF0F0F0F0E1LL);
radio.openWritingPipe(0xF0F0F0F0D2LL);
radio.stopListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
}
struct StructBuff_t {
float imuRoll;
float imuPitch;
float imuYaw;
unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
float roll = random(-150,150);
float pitch = random(-150,150);
float yaw = random(0,360);
unsigned int ap = random(0,75);
StuffStructBuff(roll,pitch,yaw,ap);
TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){
bool ok = radio.write((byte *) &StructBuff, sizeof(StructBuff));
if (ok)
printbuffs();
//printf("ok...\n\r");
else
printf("failed.\n\r");
delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
Serial.print(StructBuff.imuRoll);
Serial.print(",");
Serial.print(StructBuff.imuPitch);
Serial.print(",");
Serial.print(StructBuff.imuYaw);
Serial.print(",");
Serial.print(StructBuff.AP);
Serial.println();
}
void StuffStructBuff(float inRoll, float inPitch, float inYaw, unsigned int inAP){//**Working**
StructBuff.imuRoll = inRoll;
StructBuff.imuPitch = inPitch;
StructBuff.imuYaw = inYaw;
StructBuff.AP = inAP;
}
RX
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(8,9);
void setup(){
Serial.begin(57600);
//**************Start Transiever (NRF24L01) config**************
printf_begin();
printf("\n\rRadio Setup\n\r");
radio.begin();
radio.setRetries(15,15);
radio.setDataRate(RF24_2MBPS);
radio.setCRCLength(RF24_CRC_16);
radio.setPayloadSize(24 * sizeof(byte));
radio.setChannel(100);
radio.setAutoAck(true);
radio.openReadingPipe(1,0xF0F0F0F0D2LL);
radio.openWritingPipe(0xF0F0F0F0E1LL);
radio.startListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
}
struct StructBuff_t {
float imuRoll;
float imuPitch;
float imuYaw;
unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
if ( radio.available() )
{
bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
if (ok)
printbuffs();
// printf("ok...\n\r");
else
printf("failed.\n\r");
}
delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
Serial.print(StructBuff.imuRoll);
Serial.print(",");
Serial.print(StructBuff.imuPitch);
Serial.print(",");
Serial.print(StructBuff.imuYaw);
Serial.print(",");
Serial.print(StructBuff.AP);
Serial.println();
}
TX output
-127.00,-41.00,0.00,65
failed.
-23.00,79.00,160.00,37
failed.
failed.
-34.00,85.00,97.00,26
failed.
-71.00,-101.00,99.00,21
failed.
35.00,95.00,308.00,16
failed.
58.00,94.00,28.00,65
failed.
-128.00,16.00,189.00,74
failed.
RX
-127.00,-41.00,0.00,65
-23.00,79.00,160.00,37
-34.00,85.00,97.00,26
-71.00,-101.00,99.00,21
35.00,95.00,308.00,16
58.00,94.00,28.00,65
-128.00,16.00,189.00,74
so size of the struct is 20 it seems. as for the timing man it's slow bout 1.5 updates per sec was hoping for 3 or 4 per sec.