I checked my hardware after i was just gunna say yeah i can use the examples and noticed the connector i made was not holding tight to the NRF so i swaped out for a new one on my UNO and ran ping and worked fine. changing delay(10) will fail transmit/rec both even (11) or no delay. the 5,1000 was from trying to achieve less fail by telling it not to retransmit more than 5 times and wait 1 sec in between tries.
TX (uno)
Now sending 87...ok...Got response 87, round-trip delay: 24
Now sending 1112...ok...Got response 1112, round-trip delay: 22
Now sending 2135...ok...Got response 2135, round-trip delay: 21
Now sending 3158...ok...Got response 3158, round-trip delay: 21
Now sending 4179...ok...Got response 4179, round-trip delay: 23
Now sending 5202...ok...Got response 5202, round-trip delay: 23
RX(Mega2560)
Got payload 87...Sent response.
Got payload 1112...Sent response.
Got payload 2135...Sent response.
Got payload 3158...Sent response.
Got payload 4179...Sent response.
Got payload 5202...Sent response.
so i got excited and tried the old code.
but when i got back to the previous TX/RX code it is choppy send/rec and some fails. also if i chage it to even 11ms much less 1000 it is %100 fail agin.
Full code as it sits.
#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.setDataRate(RF24_2MBPS);
// radio.setCRCLength(RF24_CRC_16);
// radio.setPayloadSize(14 * sizeof(byte));
// radio.setChannel(80);
radio.setAutoAck(true);
// radio.setRetries(15,15);
radio.openReadingPipe(1,0xF0F0F0F0E1LL);
radio.openWritingPipe(0xF0F0F0F0D2LL);
radio.stopListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
}
struct imuBuff_t{
float imuRoll;
float imuPitch;
float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
//////////////////////////////
imuBuff.imuRoll = 31.99; //
imuBuff.imuPitch = -150.82; //Temp Values
imuBuff.imuYaw = 3.60; //
//////////////////////////////
TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){
bool ok = radio.write((byte *) &imuBuff, sizeof(imuBuff));
if (ok)
printbuffs();
else
printf("failed.\n\r");
delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
Serial.print(imuBuff.imuRoll);
Serial.print(",");
Serial.print(imuBuff.imuPitch);
Serial.print(",");
Serial.print(imuBuff.imuYaw);
Serial.println();
}
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.setDataRate(RF24_2MBPS);
// radio.setCRCLength(RF24_CRC_16);
// radio.setPayloadSize(14 * sizeof(byte));
// radio.setChannel(80);
radio.setAutoAck(true);
//radio.setRetries(15,15);
radio.openReadingPipe(1,0xF0F0F0F0D2LL);
radio.openWritingPipe(0xF0F0F0F0E1LL);
radio.startListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
}
struct IMU_t{
float imuRoll;
float imuPitch;
float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
imuBuff.imuRoll = 0;
imuBuff.imuPitch = 0;
imuBuff.imuYaw= 0;
RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
if ( radio.available() )
{
bool ok = radio.read((byte *)&imuBuff, sizeof(imuBuff));
if (ok)
printbuffs();
else
printf("failed.\n\r");
}
delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
Serial.print(imuBuff.imuRoll);
Serial.print(",");
Serial.print(imuBuff.imuPitch);
Serial.print(",");
Serial.print(imuBuff.imuYaw);
Serial.println();
}
TX
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
failed.
failed.
31.99,-150.82,3.60
RX
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60