nRF24L01 connectivity issue - works, then does not work

Hi.

I’m working on RC car: TX and RX communicate nicely, then suddenly stops working.

Details:

    • Joystick controller (TX) and Car (RX). 2 transceivers
    • Car is on a Mega. Controller is on a Nano
    • Powered by external DC and proper precautions with regulators for the arduinos and radios
    • Note: behavior also occurs if connected directly to my PC for power
    • 10uf capacitor soldered on (vcc / gnd) on RX and TX
    • All connections good and checked (with multimeter). On the right pins, etc. Soldered on to pcp boards so secure. Continuity checked as well
    • Physical distance does not matter. I have tested at various distances
    • Data rate does not matter. I have tested at various rates (256, 1MB, 2MB)
    • Tried with and without ack. Same results inconsistent results (works, then doesn’t work)
    • Have tried multiple transceivers. Can rule out faulty module(s)
    • I am using high channels to avoid interference from home devices
    • NF24 by TMRh20 v1.3.3 lib

TX Code - NANO

const byte CEPIN = 9;                // pin for radio
const byte CSNPIN = 10;               // pin for radio


//  Joystick direction
struct Direction{
  int xSpeed = STOP_SPEED;
  int ySpeed = STOP_SPEED;
  int Button = 1;
};

//create an RF24 object
RF24 GV_radio(CEPIN, CSNPIN);  // CE, CSN
//address through which two modules communicate.
const byte GV_address[6] = "00001";


void setup() {
  Serial.begin(9600);
  printf_begin();
  initRadio();
}


void initRadio(){
  GV_radio.begin();
  GV_radio.openWritingPipe(GV_address);
  GV_radio.setChannel(123);
  GV_radio.setPALevel(RF24_PA_MIN);  
  GV_radio.setDataRate(RF24_1MBPS);
//  GV_radio.disableDynamicPayloads();
//  GV_radio.setAutoAck(false);  
  GV_radio.stopListening();     //Set module as transmitter  
}


void loop() {
  getDirection();
}


void getDirection(){
  Direction d;
  d.xSpeed = analogRead(JOYSTICKXPIN); 
  d.ySpeed = analogRead(JOYSTICKYPIN); 
  d.Button = digitalRead(JOYSTICKBUTTONPIN);

  if(!GV_radio.write(&d, sizeof(Direction))){    //  When it fails, it fails HERE
    GV_radio.printDetails();
  }
}

RX Code - MEGA

//  Joystick direction
struct Direction{
  int xSpeed = STOP_SPEED;
  int ySpeed = STOP_SPEED;
  int Button = 1;
};

const byte CSNREMOTEPIN = 44;            // pin for remote radio
const byte CEREMOTEPIN = 49;             // pin for remote radio

RF24 GV_RemoteRadio(CEREMOTEPIN, CSNREMOTEPIN);  // CE, CSN
const byte GV_RemoteAddress[6] = "00001";

void setup() {
  Serial.begin(9600);
  printf_begin();
  remoteRadioInit();
}


void remoteRadioInit(){
//  Radio remote            
  GV_RemoteRadio.begin();
  GV_RemoteRadio.openReadingPipe(0,GV_RemoteAddress);  
  GV_RemoteRadio.setChannel(123);
  GV_RemoteRadio.setPALevel(RF24_PA_MIN);
  GV_RemoteRadio.setDataRate(RF24_1MBPS);
//  GV_RemoteRadio.disableDynamicPayloads();
//  GV_RemoteRadio.setAutoAck(false);  
  GV_RemoteRadio.startListening();            //Set module as reciever  
}


void loop() {
  Direction d;

  if(GV_RemoteRadio.available()){   //  When it fails, it fails HERE
    d = unpackTransmission();      //  Unpack transmission from the joystick
    d = steer(d);
  }else{
     GV_RemoteRadio.printDetails(); 
  }
}


Direction unpackTransmission(){
  Direction d;
  d.xSpeed = STOP_SPEED;
  d.ySpeed = STOP_SPEED;
  d.Button = -1;
  
  GV_RemoteRadio.read(&d, sizeof(Direction));
  return d;   
}

Behavior in Code:

When it doesn’t work, write() returns false on TX. On RX, available() also returns false.

Print Details below. I have been looking at this too long and can’t see it:

TX - NANO

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x3130303030 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x3130303030
RX_PW_P0-6 = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x7b
RF_SETUP = 0x01
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN

RX - MEGA

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x3130303030 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x01
RF_CH = 0x7b
RF_SETUP = 0x01
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN

Thank you.

An inadequate 3.3v power supply is a common problem with nRF24s. I don't have a nano myself but from reading Forum Threads it seems that they are unable to provide enough 3,3v power for an nRF24. I have a Mega clone that has the same problem.

If you suspect a power problem try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

Test your ability to communicate with some of the programs from this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R