nrf24l01 won't transmit

(I posted an earlier query relating to this in the general electronics section but I don’t actually know whether it is an electronics issue)

I am trying to get two nrf24l01 units to communicate with each other. I am using these ones:

http://www.ebay.co.uk/itm/New-Mini-NRF24L01-SMD-1-27MM-RF-wireless-transceiver-module-Small-Size-/161235999728?pt=LH_DefaultDomain_0&hash=item258a6a1bf0

which are smaller than the ones normally used (eg these http://www.ebay.co.uk/itm/4pcs-NRF24L01-2-4GHz-Antenna-Wireless-Transceiver-Module-for-Arduino-New-JT1-/291029588078?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item43c2b7186e

I am using this tx code:

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


int msg[1];
RF24 radio(9,10); 

const uint64_t pipe = 0xE8E8F0F0E1LL;


void setup(void)
{
  Serial.begin(9600);
  printf_begin();
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipe);
  radio.printDetails();
}

void loop(void)
{
  for (int txdigit=0; txdigit<7; txdigit++) {
    radio.printDetails();
    msg[0] =txdigit;
    radio.write(msg, 1);
    delay(3000);
  }
}

And this rx code:

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


int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int lastmsg = 1;

void setup(void)
{
 Serial.begin(9600);
 radio.begin();
 radio.setDataRate(RF24_250KBPS);
 radio.openReadingPipe(1,pipe);
 radio.startListening();

}

void loop(void)
{
 if (radio.available())
 {
   bool done = false;  
   while (!done)
   {
     done = radio.read(msg, 2); 
     Serial.println(msg[0]);
   }
 }
}

I cannot however get the units to transmit. They receive OK (if I transmit from the larger units). In each case the units are connected to a Uno via a breadboard. The connections are the same whether in tx/rx mode, and the fact that I can transmit from the bigger units using exactly the same code/connections is puzzling.

PrintDetails does not suggest anything wrong.

I have tried altering the datarate, to no effect.

I wonder whether there is a capacitance issue. I have tried putting various combinations of electrolytic and ceramic capacitors across the supply to the nrf24l01 units but it makes no difference, and to be honest I have no idea what the correct values might be. Also there is no improvement if i power from batteries. The fact that the Uno is connected to the nrf24l01 via flying leads and jumpers is not ideal but I don’t know what else to do.

Just very occasionally, when I reset the transmitting Uno, I get one or two messages sent across, but it is very rare.

I am running out of ideas here and hope someone else might have some.

Hello i had the same problem with another small nrf unit using similar code, however with this code it worked better for me. The small unit still did not behave 100% but a lot better anyway. you might have better luck with your unit give it a try will ya.

And for the cap question a electrolyte with 10Uf+ should be enough, maybe add a small 0,1Uf ceramic just in case.

I changed the ce, csn to pins 9 and 10 so the code should be OK to go without changes.

good luck man.

SPI_rf24L01.zip (7.68 KB)

Thanks very much, I will let you know how it goes (though not for a day or two unfortunately)

Thank you so much - this does seem to work. Even without capacitors. Amazing. Now I must see whether I can get the code to work on a ATTINY84

nice i am happy the code helped you, just for curiosity what are you trying to make?

It's for a remote sensor that has to be very small. Can you help me again - when you say you changed the code so CE and CSN are 8 and 9, I can't see where CE and CSN are defined in that code. Previously I was defining those pins with the RF24 radio line and I want to change them to implement on the ATTINY84, but I can't see where you did it.

Sorry, I've seen it - it's in nRF24L01.h

good you found it, i am guessing this will be a battery powered sensor here is a few free tips

deepest sleep mode on nrf: ( takes less then 1ua).

//Power upp
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); //pwr upp (only OK for TX)
delayMicroseconds(1700); //necessary delays from nrf data sheet
digitalWrite(CE, 1);
delayMicroseconds(500);


//send stuff here

//Power down
delayMicroseconds(900);//wait for retransmissions before sleep, maybe a bit longer necessary 
digitalWrite(CE, 0);
delayMicroseconds(75);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x00);   //pwr down
delayMicroseconds(75);

change to 250kps mode for better range
in
TX_Mode(void)
SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x27);

use 3 byte address
SPI_RW_Reg(WRITE_REG + SETUP_AW,0X01);//3byte address instead of 5

change this too:

unsigned char TX_ADDRESS[TX_ADR_WIDTH] =
{
0xb1,0x43,0x15
}; // Define a static TX address

and use as small payload as possible
#define TX_ADR_WIDTH 3 // unsigned chars TX(RX) address width<< change this to 3 from 5
#define TX_PLOAD_WIDTH 2 // unsigned chars TX payload

and of course sleep on the attiny too but i guess you have that covered already.

Well these are the most important parts that i wish i knew when i built by first nrf sensor, best of luck man

Thanks, that's helpful. Yes I can do the low power stuff on the ATTINY. But not quite at that stage yet - still having some small problems on the Unos, eg can get them to transmit/receive in one direction but can't get them to switch the other way round. There's something odd about the Status but I haven't had time to work out what's going wrong yet.

I have a easy alternative way to send back a payload without having to change tx/rx role,
use the auto acc to send back a payload.

if you add/change this in the code it will send out a payload as usual but when RX receive it will add a payload to the auto reply.
And the TX side will print it out.

just a detail the aa payload you add in the first loop will not be sent that loop but in the next one, so the aa will be 1 step behind.

Might still be of some help i hope

OK here it is add/change this on the RX:

#define TX_ADR_WIDTH    3   // 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH  3  // 32 unsigned chars TX payload

unsigned char TX_ADDRESS[TX_ADR_WIDTH]  = 
{
  0x34,0x43,0x10
}; // Define a static TX address



void RX_Mode(void)
{
  digitalWrite(CEq, 0);

  SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // Use the same address on the RX device as the TX device
   SPI_RW_Reg(WRITE_REG + SETUP_AW,0X01);   // 3 bit adress
  SPI_RW_Reg(WRITE_REG + EN_AA, 0x01);      // Enable Auto.Ack:Pipe0
  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  // Enable Pipe0
  SPI_RW_Reg(WRITE_REG + RF_CH, 40);        // Select RF channel 40
  SPI_RW_Reg(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH); // Select same RX payload width as TX Payload width
  SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x27);   // TX_PWR:0dBm, Datarate:250k, LNA:HCURR
  SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f);     // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:RX. RX_DR enabled..
 SPI_RW_Reg(WRITE_REG + 0x1C, B00000001);     //dynamic payload pip0
  SPI_RW_Reg(WRITE_REG + 0x1D, B00000110);     //enable dynamic payload and aa payload
  digitalWrite(CEq, 1);                             // Set CE pin high to enable RX device
  //  This device is now ready to receive one packet of 16 unsigned chars payload from a TX device sending to address
  //  '3443101001', with auto acknowledgment, retransmit count of 10, RF channel 40 and datarate = 2Mbps.
}


void loop() 
{
  for(;;)
  {
    unsigned char status = SPI_Read(STATUS);                         // read register STATUS's value
    if(status&RX_DR)                                                 // if receive data ready (TX_DS) interrupt
    {
      SPI_Read_Buf(RD_RX_PLOAD, rx_buf, TX_PLOAD_WIDTH);             // read playload to rx_buf
      SPI_RW_Reg(FLUSH_RX,0);  

      tx_buf[0]=rx_buf[0]+1;//send with aa
      tx_buf[1]=rx_buf[1]+1;
      tx_buf[2]=rx_buf[2]+1;
      SPI_Write_Buf(B10101000,tx_buf,TX_PLOAD_WIDTH);//payload to send with next aa

      for(int i=0; i<TX_PLOAD_WIDTH; i++)
      {
          Serial.print(" ");
          Serial.print(rx_buf[i]);                              // print rx_buf
      }
      Serial.println(" ");

    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);                             // clear RX_DR or TX_DS or MAX_RT interrupt flag
    delay(100);
  }
}

and change this on the TX side

#define TX_ADR_WIDTH    3   // 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH  3  // 32 unsigned chars TX payload

unsigned char TX_ADDRESS[TX_ADR_WIDTH]  = 
{
  0x34,0x43,0x10
}; // Define a static TX address


void TX_Mode(void)
{
  digitalWrite(CEq, 0);

  SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);    // Writes TX_Address to nRF24L01
  SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack
 
 SPI_RW_Reg(WRITE_REG + SETUP_AW,0X01);   // 3 bit adress
  
  SPI_RW_Reg(WRITE_REG + EN_AA, 0x01);      // Enable Auto.Ack:Pipe0
  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  // Enable Pipe0
  SPI_RW_Reg(WRITE_REG + SETUP_RETR, B00101010); // 750us + 86us, 10 retrans...changed this from 500 t0 750
  SPI_RW_Reg(WRITE_REG + RF_CH, 40);        // Select RF channel 40
  SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x27);   // TX_PWR:0dBm, Datarate:250kbps, LNA:HCURR
  SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);     // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:TX. MAX_RT & TX_DS enabled..
  SPI_RW_Reg(WRITE_REG + 0x1C, B00000001);     //dynamic payload pip0
  SPI_RW_Reg(WRITE_REG + 0x1D, B00000110);     //enable dynamic payload and aa payload
SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);
  digitalWrite(CEq, 1);
}



void loop() 
{
  int k = 0;
  for(;;)
  {
    for(int i=0; i<TX_PLOAD_WIDTH; i++)
        tx_buf[i] = k++;  
  
  Serial.print("sending: "); 
        for(int i=0; i<TX_PLOAD_WIDTH; i++)
      {
          Serial.print(" ");
          Serial.print(tx_buf[i]);                              // print rx_buf
      } 
      Serial.println("");        
    unsigned char status = SPI_Read(STATUS);                   // read register STATUS's value
    if(status&TX_DS)                                           // if receive data ready (TX_DS) interrupt
    {
      SPI_RW_Reg(FLUSH_TX,0);                                  
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);       // write playload to TX_FIFO
    }
    if(status&MAX_RT)                                         // if receive data ready (MAX_RT) interrupt, this is retransmit than  SETUP_RETR                          
    {
      SPI_RW_Reg(FLUSH_TX,0);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);      // disable standy-mode
    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);                     // clear RX_DR or TX_DS or MAX_RT interrupt flag
   
    delay(8);//wait for re transmitts lower rt count and you can lower this too
    status = SPI_Read(STATUS);  
  
  //Serial.print("status = ");    
  //Serial.println(status,HEX);
  
    if(status==B01100000)//data ready and aa rescieved
    {

    SPI_Read_Buf(RD_RX_PLOAD, rx_buf, TX_PLOAD_WIDTH);
    SPI_RW_Reg(FLUSH_RX,0); 
     Serial.print("rescieving: ");
      for(int i=0; i<TX_PLOAD_WIDTH; i++)
      {
          Serial.print(" ");
          Serial.print(rx_buf[i]);                              // print rx_buf
      } 
      Serial.println("");  
    }

    delay(5000);
  }
}

I’m having a bit of trouble with the power up and down. I’ve cut down and modified the sketch so that it simply transmits digits 1 - 10 on a loop (using the ATTINY84). The CE and CSN pins are changed (and now defined within the sketch itself). This all works fine until I use the power up and power down code that you gave. Then it doesn’t transmit at all. I’ve messed around with the delays to see whether they might be too short but it doesn’t seem to make any difference. The code is below. Can you see any issues?

#include <SPI.h>
#include "API.h"
#define CE 10
#define CSN 2


//***************************************************
#define TX_ADR_WIDTH    3   // 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH  2  // 32 unsigned chars TX payload

unsigned char TX_ADDRESS[TX_ADR_WIDTH]  = 
{
 0xb1,0x43,0x15
}; // Define a static TX address

unsigned char rx_buf[TX_PLOAD_WIDTH] = {0}; // initialize value
unsigned char tx_buf[TX_PLOAD_WIDTH] = {0};
//***************************************************
void setup() 
{
  pinMode(CE,  OUTPUT);
  pinMode(CSN, OUTPUT);
  SPI.begin();
  delay(50);
  init_io();                        // Initialize IO port
  unsigned char sstatus=SPI_Read(STATUS);
  TX_Mode();                       // set TX mode
}

void loop() 
{
//Power up

SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); //pwr upp (only OK for TX)
delayMicroseconds(1700); //necessary delays from nrf data sheet
digitalWrite(CE, 1);
delayMicroseconds(500);
  
      for (int i=1; i<11; i++){        
      tx_buf[0]=i;
      unsigned char sstatus = SPI_Read(STATUS);                   // read register STATUS's value
      if(sstatus&TX_DS)                                           // if receive data ready (TX_DS) interrupt
        {
        SPI_RW_Reg(FLUSH_TX,0);                                  
        SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);       // write playload to TX_FIFO
        }
      if(sstatus&MAX_RT)                                         // if receive data ready (MAX_RT) interrupt, this is retransmit than  SETUP_RETR                          
        {
        SPI_RW_Reg(FLUSH_TX,0);
        SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);      // disable standy-mode
        }
      SPI_RW_Reg(WRITE_REG+STATUS,sstatus);                     // clear RX_DR or TX_DS or MAX_RT interrupt flag
//Power down

delayMicroseconds(5000);//wait for retransmissions before sleep, maybe a bit longer necessary 
digitalWrite(CE, 0);
delayMicroseconds(200);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x00);   //pwr down
delayMicroseconds(200);

      delay(1000);
      }
    
}

//**************************************************
// Function: init_io();
// Description:
// flash led one time,chip enable(ready to TX or RX Mode),
// Spi disable,Spi clock line init high
//**************************************************
void init_io(void)
{
//  digitalWrite(IRQ, 0);
  digitalWrite(CE, 0);			// chip enable
  digitalWrite(CSN, 1);                 // Spi disable	
}

/************************************************************************
**   * Function: SPI_RW();
 * 
 * Description:
 * Writes one unsigned char to nRF24L01, and return the unsigned char read
 * from nRF24L01 during write, according to SPI protocol
************************************************************************/
unsigned char SPI_RW(unsigned char Byte)
{
  return SPI.transfer(Byte);
}

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

/**************************************************
 * Function: SPI_RW_Reg();
 * 
 * Description:
 * Writes value 'value' to register 'reg'
/**************************************************/
unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
{
  unsigned char status;

  digitalWrite(CSN, 0);                   // CSN low, init SPI transaction
  SPI_RW(reg);                            // select register
  SPI_RW(value);                          // ..and write value to it..
  digitalWrite(CSN, 1);                   // CSN high again

  return(status);                   // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: SPI_Read();
 * 
 * Description:
 * Read one unsigned char from nRF24L01 register, 'reg'
/**************************************************/
unsigned char SPI_Read(unsigned char reg)
{
  unsigned char reg_val;

  digitalWrite(CSN, 0);                // CSN low, initialize SPI communication...
  SPI_RW(reg);                         // Select register to read from..
  reg_val = SPI_RW(0);                 // ..then read register value
  digitalWrite(CSN, 1);                // CSN high, terminate SPI communication

  return(reg_val);                     // return register value
}
/**************************************************/

/**************************************************
 * Function: SPI_Read_Buf();
 * 
 * Description:
 * Reads 'unsigned chars' #of unsigned chars from register 'reg'
 * Typically used to read RX payload, Rx/Tx address
/**************************************************/
unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
{
  unsigned char sstatus,i;

  digitalWrite(CSN, 0);                   // Set CSN low, init SPI tranaction
  sstatus = SPI_RW(reg);       	    // Select register to write to and read status unsigned char

  for(i=0;i<bytes;i++)
  {
    pBuf[i] = SPI_RW(0);    // Perform SPI_RW to read unsigned char from nRF24L01
  }

  digitalWrite(CSN, 1);                   // Set CSN high again

  return(sstatus);                  // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: SPI_Write_Buf();
 * 
 * Description:
 * Writes contents of buffer '*pBuf' to nRF24L01
 * Typically used to write TX payload, Rx/Tx address
/**************************************************/
unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
{
  unsigned char sstatus,i;

  digitalWrite(CSN, 0);                   // Set CSN low, init SPI tranaction
  sstatus = SPI_RW(reg);             // Select register to write to and read status unsigned char
  for(i=0;i<bytes; i++)             // then write all unsigned char in buffer(*pBuf)
  {
    SPI_RW(*pBuf++);
  }
  digitalWrite(CSN, 1);                   // Set CSN high again
  return(sstatus);                  // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: TX_Mode();
 * 
 * Description:
 * This function initializes one nRF24L01 device to
 * TX mode, set TX address, set RX address for auto.ack,
 * fill TX payload, select RF channel, datarate & TX pwr.
 * PWR_UP is set, CRC(2 unsigned chars) is enabled, & PRIM:TX.
 * 
 * ToDo: One high pulse(>10us) on CE will now send this
 * packet and expext an acknowledgment from the RX device.
 **************************************************/
void TX_Mode(void)
{
  digitalWrite(CE, 0);
  
  SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x27); 
  SPI_RW_Reg(WRITE_REG + SETUP_AW,0X01);//3byte address instead of 5
  
  
  SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);    // Writes TX_Address to nRF24L01
  SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack

  SPI_RW_Reg(WRITE_REG + EN_AA, 0x01);      // Enable Auto.Ack:Pipe0
  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  // Enable Pipe0
  SPI_RW_Reg(WRITE_REG + SETUP_RETR, 0x1a); // 500us + 86us, 10 retrans...
  SPI_RW_Reg(WRITE_REG + RF_CH, 40);        // Select RF channel 40
  SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);   // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR
  SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);     // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:TX. MAX_RT & TX_DS enabled..
  SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);

  digitalWrite(CE, 1);
}

i will test the code tomorrow on a attiny44 i have somewhere with a fast look the only strange thing i found are this you are writing to the same register twice

void TX_Mode(void)
{
  digitalWrite(CE, 0);
  
 here>>>>>>>>>>>>>> SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x27); 
  SPI_RW_Reg(WRITE_REG + SETUP_AW,0X01);//3byte address instead of 5
  
  
  SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);    // Writes TX_Address to nRF24L01
  SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack

  SPI_RW_Reg(WRITE_REG + EN_AA, 0x01);      // Enable Auto.Ack:Pipe0
  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  // Enable Pipe0
  SPI_RW_Reg(WRITE_REG + SETUP_RETR, 0x1a); // 500us + 86us, 10 retrans...
  SPI_RW_Reg(WRITE_REG + RF_CH, 40);        // Select RF channel 40
here>>>>>>            SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);   // TX_PWR:0dBm, Datarate:2Mbps,           LNA:HCURR
  SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);     // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:TX. MAX_RT & TX_DS enabled..
  SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);

  digitalWrite(CE, 1);
}

remove this line: SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); // TX_PWR:0dBm,

might be the only problem not sure but i will give it a try tomorrow and see.

i just saw something else the first time the code run you are writing the the register with ce high add this last in setup

digitalWrite(CE, 0);

might be it not sure anyway try it

Thanks, none of these are the issue, I don’t think. The duplicate line in the TX_Mode() had the effect of making it transmit at 2MB rather than at 250k but since the receiver was also receiving at the higher speed it didn’t matter. I’ve now corrected it in both. Setting the CE pin low in setup() should make it go into standby, but then it goes into tx mode in the loop() so it doesn’t make any difference really.
The only thing that stops it working is the power down code so something is wrong there. I need to look at the datasheet I think (drastic measures)>

If you try to get it working on the ATTINY44 you may need to get a different SPI library because true SPI isn’t implemented on the ATTINY chips. Unfortunately I can’t remember where I got mine from. I think I needed a different core too.

I found the problem, look at where this for loop ends

for (int i=1; i<11; i++){        
      tx_buf[0]=i;
      unsigned char sstatus = SPI_Read(STATUS);                   // read register STATUS's value
      if(sstatus&TX_DS)                                           // if receive data ready (TX_DS) interrupt
        {
        SPI_RW_Reg(FLUSH_TX,0);                                  
        SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);       // write playload to TX_FIFO
        }
      if(sstatus&MAX_RT)                                         // if receive data ready (MAX_RT) interrupt, this is retransmit than  SETUP_RETR                          
        {
        SPI_RW_Reg(FLUSH_TX,0);
        SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);      // disable standy-mode
        }
      SPI_RW_Reg(WRITE_REG+STATUS,sstatus);                     // clear RX_DR or TX_DS or MAX_RT interrupt flag
//Power down

delayMicroseconds(5000);//wait for retransmissions before sleep, maybe a bit longer necessary 
digitalWrite(CE, 0);
delayMicroseconds(200);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x00);   //pwr down
delayMicroseconds(200);

      delay(1000);
      }

So just change the for loop or move it up to the start of the program and its all working perfect with sleep and all, i just tried it and it just sent 250 payloads no problem.

The thing with the 2mps vs 250kps, I never got that small payloads to work with 2mps so stick with 250k

so happy coding man and good luck

Oh yes! Thanks.