NRF24 ack payload not sending packets

Hi im having hard time to get this thing to work.

On receiver its seams to work counting but not sending it back to transmitter

here is my code

Receiver:

/*  
A basic receiver using the nRF24L01 module to receive 4 channels and convert them to PPM.
 */

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

////////////////////// PPM CONFIGURATION//////////////////////////
#define channel_number 6  //set the number of channels
#define sigPin 2  //set PPM signal output pin on the arduino
#define PPM_FrLen 27000  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PPM_PulseLen 400  //set the pulse length
//////////////////////////////////////////////////////////////////

int ppm[channel_number];

const uint64_t pipeIn =  0xE8E8F0F0E1LL;

RF24 radio(8, 9);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
};

MyData data;

void resetData() 
{
  data.throttle = 0;
  data.yaw = 128;
  data.pitch = 128;
  data.roll = 128;
  
  setPPMValuesFromData();
}

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.yaw,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.roll,     0, 255, 1000, 2000);  
  ppm[4] = 1000;
  ppm[5] = 1000;
}

/**************************************************/

void setupPPM() {
  pinMode(sigPin, OUTPUT);
  digitalWrite(sigPin, 0);  //set the PPM signal pin to the default state (off)

  cli();
  TCCR1A = 0; // set entire TCCR1 register to 0
  TCCR1B = 0;

  OCR1A = 100;  // compare match register (not very important, sets the timeout for the first interrupt)
  TCCR1B |= (1 << WGM12);  // turn on CTC mode
  TCCR1B |= (1 << CS11);  // 8 prescaler: 0,5 microseconds at 16mhz
  TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
  sei();
}

void setup()
{  
   Serial.begin(9600);
  resetData();
  setupPPM();
  
  // Set up radio module
  radio.begin();
  radio.setAutoAck(1); 
  radio.enableAckPayload();
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
        // Either endpoint can set to false to disable ACKs

  radio.openReadingPipe(1,pipeIn);
  radio.startListening();
}

/**************************************************/

unsigned long lastRecvTime = 0;


void recvData()
{  
   
  static int  packetscount = 0;
  while ( radio.available() ) {        
    radio.read(&data, sizeof(MyData));
    lastRecvTime = millis();
        
  }
   radio.writeAckPayload(1,&packetscount,sizeof(packetscount));
       ++packetscount;
 
  Serial.print(" Y = ");      
   Serial.println(packetscount);
}

/**************************************************/

void loop()
{
  
  recvData();
  
  
   
 
       
  
    
  unsigned long now = millis();
  if ( now - lastRecvTime > 1000 ) {
    // signal lost?
    resetData();
  }
  
  setPPMValuesFromData();
}

/**************************************************/

ISR(TIMER1_COMPA_vect){
  static boolean state = true;

  TCNT1 = 0;

  if ( state ) {
    //end pulse
    PORTD = PORTD & ~B00000100; // turn pin 2 off. Could also use: digitalWrite(sigPin,0)
    OCR1A = PPM_PulseLen;
    state = false;
  }
  else {
    //start pulse
    static byte cur_chan_numb;
    static unsigned int calc_rest;

    PORTD = PORTD | B00000100; // turn pin 2 on. Could also use: digitalWrite(sigPin,1)
    state = true;

    if(cur_chan_numb >= channel_number) {
      cur_chan_numb = 0;
      calc_rest += PPM_PulseLen;
      OCR1A = (PPM_FrLen - calc_rest);
      calc_rest = 0;
    }
    else {
      OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen);
      calc_rest += ppm[cur_chan_numb];
      cur_chan_numb++;
    }     
  }
}

Regards

and Transmitter:

/*  
A basic 4 channel transmitter using the nRF24L01 module.
*/


//==========================
#include <nRF24L01.h>
#include <RF24.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RF24_config.h>
//============================

//================================
#include <Wire.h>
#include <SPI.h>
//==============================


#define OLED_MOSI   4
#define OLED_CLK   5
#define OLED_DC    2
#define OLED_CS    3
#define OLED_RESET 5
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

static const unsigned char PROGMEM logo16_glcd_bmp[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF,
0x00, 0x00, 0x00, 0x01, 0xE0, 0x01, 0xE0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x00, 0x06,
0x00, 0x00, 0x18, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x18, 0x00, 0x00, 0x06, 0x00,
0x00, 0x30, 0x00, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00,
0x01, 0x00, 0x00, 0x60, 0x00, 0x00, 0x01, 0x80, 0x00, 0x48, 0x00, 0x00, 0x04, 0x80, 0x00, 0x48,
0x00, 0x00, 0x04, 0x80, 0x00, 0x48, 0x00, 0x00, 0x04, 0x80, 0x00, 0x48, 0x00, 0x00, 0x04, 0x80,
0x00, 0x6C, 0x00, 0x00, 0x04, 0x80, 0x00, 0x24, 0x00, 0x00, 0x09, 0x80, 0x00, 0x24, 0x00, 0x00,
0x09, 0x00, 0x00, 0x34, 0xFC, 0x0F, 0xCB, 0x00, 0x00, 0x1D, 0xFE, 0x1F, 0xEE, 0x00, 0x00, 0x1D,
0xFE, 0x1F, 0xEC, 0x00, 0x00, 0x0D, 0xFC, 0x0F, 0xEC, 0x00, 0x0C, 0x0C, 0xFC, 0x0F, 0xC4, 0x0C,
0x0E, 0x08, 0xF8, 0x07, 0xC4, 0x14, 0x19, 0x08, 0x70, 0xC3, 0x84, 0x22, 0x11, 0x88, 0x01, 0xE0,
0x04, 0x62, 0x30, 0xC4, 0x01, 0xF0, 0x0C, 0xC3, 0x20, 0x7E, 0x03, 0xF0, 0x1F, 0x81, 0x40, 0x1F,
0x83, 0xF0, 0x7C, 0x00, 0x7F, 0x03, 0xE3, 0x31, 0xF0, 0x1F, 0x09, 0xC1, 0xF0, 0x03, 0xE0, 0xE6,
0x00, 0x70, 0xD0, 0x02, 0xC3, 0x80, 0x00, 0x1C, 0x98, 0x02, 0x4E, 0x00, 0x00, 0x07, 0x87, 0xF8,
0x78, 0x00, 0x00, 0x01, 0xB8, 0x07, 0x60, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0x40, 0x00, 0x00, 0x03,
0x91, 0x22, 0x70, 0x00, 0x00, 0x0E, 0x8F, 0x3C, 0x5C, 0x00, 0x00, 0x38, 0xC0, 0x40, 0xC7, 0x10,
0x0F, 0xE0, 0xC0, 0x00, 0xC1, 0xFC, 0x08, 0x01, 0xE0, 0x01, 0xE0, 0x04, 0x0C, 0x06, 0x18, 0x06,
0x18, 0x0C, 0x06, 0x18, 0x0F, 0xFC, 0x06, 0x18, 0x02, 0x30, 0x00, 0x00, 0x03, 0x10, 0x03, 0x20,
0x00, 0x00, 0x01, 0x10, 0x01, 0x40, 0x00, 0x00, 0x00, 0xB0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x60,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xFF, 0x00, 0x8C,
0xCF, 0x0E, 0xB8, 0xB1, 0xE2, 0xEF, 0xD9, 0xDB, 
};
   
const uint64_t pipeOut = 0xE8E8F0F0E1LL;

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
};

MyData data;

void resetData() 
{
  data.throttle = 0;
  data.yaw = 128;
  data.pitch = 128;
  data.roll = 128;
}

int pushButton = 6;

void setup()
{
  Serial.begin(9600);
   pinMode(pushButton, INPUT);
  digitalWrite(pushButton, HIGH);
  display.clearDisplay();
  delay(1000);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.drawBitmap(30, 16,  logo16_glcd_bmp, 48, 48, 1);
  delay(6000);
  display.clearDisplay();
  
  radio.begin();
  radio.setAutoAck(1); 
   radio.enableAckPayload();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);

  resetData();
}

/**************************************************/

// Returns a corrected value for a joystick position that takes into account
// the values of the outer extents and the middle of the joystick range.
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}

void loop()
{
 
 int buttonState = digitalRead(pushButton);
 int throttle = analogRead(A0);
 int  yaw      = analogRead(A1);
 int  pitch    = analogRead(A2);
 int  roll     = analogRead(A3);
  
  int Speed = map(throttle, 121, 925, 0, 100);
  int Speed1 = map(yaw, 121, 925, 0, 100);
  int Speed2 = map(pitch, 121, 925, 0, 100);
  int Speed3 = map(roll, 121, 925, 0, 100);
 
  
  // The calibration numbers used here should be measured 
  // for your joysticks using the TestJoysticks sketch.
  data.throttle = mapJoystickValues( analogRead(0), 13, 524, 1015, true );
  data.yaw      = mapJoystickValues( analogRead(1),  1, 505, 1020, true );
  data.pitch    = mapJoystickValues( analogRead(2), 12, 544, 1021, true );
  data.roll     = mapJoystickValues( analogRead(3), 34, 522, 1020, true );
  
  radio.write(&data, sizeof(MyData));
  static int  nx = 0;
   
   if ( radio.isAckPayloadAvailable() )
    {
      radio.read(&nx, sizeof(nx));
    
    }
    
     switch (buttonState) {
  case 0: 
   display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Throttle:  ");
  display.println(Speed);
   display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(30,8);
  display.print("Yaw: ");
  display.println(Speed1);
  display.setTextColor(WHITE);
  display.setCursor(20,16);
  display.print("Pitch: ");
  display.println(Speed2);
  display.setTextColor(WHITE);
  display.setCursor(24,24);
  display.print("Roll: ");
  display.println(Speed3);
  display.display();
  display.clearDisplay();
  break;
  
  case 1: 
  
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println(" Golden Freddy!");
  display.setTextColor(WHITE);
  display.setCursor(0,10);
  display.println("Dangyras!");
  display.setCursor(0,20);
  display.print("Dangyras!");
  display.println(nx);
  display.display();
  display.clearDisplay();
  
   Serial.print(" Y = ");      
   Serial.println(nx);
  break;
  }
   
}

same problem here.I have spent days so far with this issue with no luck.

I have some modules that do the right job, which have a cover over the chip. The ones with the normal chip, the squared RF24L01+, all of them have problems receiving.

I've tried to block interferences with aluminum, change the programming, change the address to be compound with alternating 0s and Is... No luck.

It is very frustrating because I have a program wick needs reliable communication and it only works with five of twenty NRF24L01+ modules
:cry: :cry: :cry:

Rastaman

I noticed in your TX code you didn't state a stopListening command. From what I understand that is needed to set your TX into tx mode. Just a thought not sure if it has any significance.