[SOLVED] pipes supprting auto ack NRF24L01

hi all

i am trying to build a base station that can receive from 5 transmitters using UNO and NRF24L01

auto ack feature is working only when i use pipes 0,1 and 5 the other pipes do not work

tx code

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

/*
This sketch sends a string to a corresponding Arduino
with nrf24 attached.  It appends a specific value 
(2 in this case) to the end to signify the end of the
message.
*/
#define WHICH_NODE 5

const uint64_t wAddress[] = {0x7878787878LL, 0x7878787877LL, 0x7878787876LL, 0x7878787875LL, 0x7878787874LL, 0x7878787873LL };

 const uint64_t PTXpipe = wAddress[WHICH_NODE];   // Pulls the address from the above array for this node's pipe
  
int ackMessg[1];
byte ackMessgLen = 1;

RF24 radio(8,10);

byte arr[32] ;
 uint8_t* hash;
 
void printHash(uint8_t* hash) {
  
  for (int i=0; i<32; i++) {
     //(String)hash = (String) ID + (String) hash;
    Serial.print("0123456789abcdef"[hash[i]>>4]);
    Serial.print("0123456789abcdef"[hash[i]&0xf]);

  }
  Serial.println();
}

void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  
  radio.enableAckPayload();
 // radio.setRetries(3,5); // delay, count
  radio.openWritingPipe(PTXpipe); 
//  radio.stopListening();
  
}
void loop()
{
  byte arr[32] ;
  char xx[21];
String str ="12345678901234567890";
str.toCharArray(xx, 21);
 

Sha256.initHmac((uint8_t*)xx,21);
//Serial.println(xx);
  Sha256.print("node 1");

 hash=Sha256.resultHmac();
  
 
for( int j=0;j<32;j++)
{arr[j]=hash[j];

  }

 byte arr1[33];
   memcpy( arr1, arr ,32);

    
 //byte arr1[33]="12345678901234567890123456789012";

bool rslt;
 
rslt=radio.write(arr,sizeof(arr));

   
if ( radio.isAckPayloadAvailable() ) {
 radio.read(ackMessg,ackMessgLen);
 Serial.print("Acknowledge received: ");
 Serial.println(ackMessg[0]);
 }
    

 
 
}

Rx code

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

/*
This sketch receives strings from sending unit via nrf24 
and prints them out via serial.  The sketch waits until
it receives a specific value (2 in this case), then it 
prints the complete message and clears the message buffer.
*/
byte pipeNum = 0;

int ackData[1] = {5};
byte ackLen = 1;

RF24 radio(8,10);
 const uint64_t rAddress[] = {0x7878787878LL, 0x7878787877LL, 0x7878787876LL, 0x7878787875LL, 0x7878787874LL, 0x7878787873LL };


byte theMessage[32] = "";

void setup(void){
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.enableAckPayload();
 
  radio.openReadingPipe(5,rAddress[5]);
 
  radio.startListening();
}

void loop(void)
{
       
  while (radio.available(&pipeNum))
  {
      radio.read( theMessage , 32 );
      
      Serial.print("received : ");
      for(int x=0;x<32;x++)
      Serial.print(theMessage[x],HEX);
      Serial.print(" from ");
      Serial.print(pipeNum);
      Serial.println();
      
      radio.writeAckPayload(5, ackData, ackLen);
      
     
    
}}

thx in advance for your help

this topic talked abt the same problem but he did not mention how did he solve that

Are you using genuine transceivers? The chinese copies have been known to cause issues.
Are you using decoupling capacitors between VCC and GND pins?
Are you using tmrh20's RF24 library? Do you have the same issue when using the example sketches?

I can't see any reason why you need anything other than pipe 0 or 1 in either of your programs.

The only purpose of pipes is to separate incoming messages from several transmitters. But as you are using ackPayload that is not relevant - which is the beauty of the ackPayload concept.

...R
Simple nRF24L01+ Tutorial

hi samIm93

i am using tmrh RF24 library,and using UNO original board,but i think the NRF24l01 is a Chinese clone ,and no capacitors between VCC and ground

hi robbin2

i want to use a separate pipe line for each transmitter inorder to send ack for each msg to the corresponding transmitter
and i know forsure ur tutorial for NRF24l01

mestek123:
i want to use a separate pipe line for each transmitter inorder to send ack for each msg to the corresponding transmitter
and i know forsure ur tutorial for NRF24l01

I think you have got your concepts mixed up.

You say you have 1 base station and 5 slaves. (Base and slave are better concepts because all of the devices are both transmitters and receivers).

When the base station sends a message it can only do so on Pipe 0 and when any of the slaves responds with an ackPayload it must be received by the base station on Pipe 0.

As each slave is only receiving a message from the single base station the slave does not need multiple pipes.

If I have not understood your system properly then please post a simple diagram to make things clearer.

...R

i have a base and 3 slaves (may b expanded to 5 slaves),the base is required to send an ack for each slave and determine which slave has sent a specific packet

this is a simple diagram

if u have a nother method that i can tell which slave has sent a specific packet of 32bytes to the base kindly tell me

mestek123:
i have a base and 3 slaves (may b expanded to 5 slaves),the base is required to send an ack for each slave and determine which slave has sent a specific packet
...SNIP....
if u have a nother method that i can tell which slave has sent a specific packet of 32bytes to the base kindly tell me

Can you include an ID as part of the packet? A different value for each slave.

More generally I would turn the workings on its head and have the base initiate communication with each slave in turn. Then the slave can send the data to the base in the ackPayload. As the base knows which slave it called it will be perfectly clear which of them sent the data.

I have not needed to work with different pipes in my applications. But AFAIK they are only relevant for the receiver. if you don't want to do it as in the previous paragraph you can set the base unit to receive on a different address for each pipe. Then each slave sends the data to one of the addresses and it will be put into the appropriate pipe for that address. That way the base knows which slave sent it. But IMHO the system in the previous paragraph is much simpler and avoids the risk of two slaves sending at the same time and the data colliding and being garbled. Although there are several pipes there is only one wireless receiver.

The idea of pipes can be a bit confusing. Think of them as 6 shelves onto which the mail for different residents in an apartment block can be placed. All the letters come through the same mail slot and when they fall on the floor someone picks them up, looks at the name of the recipient and puts them on the correct shelf or shreds them if they are for a recipient who lives in another block.

...R

sending the id in the payload will require sending two packets as the data that i need to send is 32 bytes and NRF42L01 has a 32 payload only

how can i use different pipelines and i h ave only 3 pipelines working out of the 6 without a reasonable cause

Firstly, I still use the archaic terms 'master' and 'slave'. I trust everybody will know what I mean even if I am not trendy ::slight_smile:

Secondly, I am working on a master/multiple-slave system using UNOs and nRF24L01+s. My addressing style is the same as the one posted by mestek123 in post #7

Thirdly, robin2 describes the communication system I am trying as below in post #8

Robin2:
... you can set the base unit to receive on a different address for each pipe. Then each slave sends the data to one of the addresses and it will be put into the appropriate pipe for that address. That way the base knows which slave sent it.

Now, my problem with that is that when I try to use slaves 2-5 all mayhem breaks loose with slaves reading and trying to respond to transmissions which were never intended for them. I have been battling this problem for some months now. Fortunately, CaptainJack appears to have encountered the same problem and to have come up with a solution in this other thread. Unfortunately, he did not include the magical addresses which solved his problem.

I have read through CaptainJack's posting several times and I believe it holds the key to this blockage I have faced. Can someone please:

1: explain in finer detail what CaptainJack wrote

The code does pick the "2" as the LSB to shift out to the NRF (thinking address[4] is the LSB), 
but instead of setting the address to "recv2" we get "2ecv1".

2: show me addresses which grant the solution as CaptainJack described in

My solution was to adapt the code so address runs from LSB to MSB, and for pipe 2-5 it 
uses address[0] to write for the LSB for one of the pipes 2-5.

Those two things can mean the end of a long, frustrating road for me, and I will be very grateful indeed.

mestek123:
sending the id in the payload will require sending two packets as the data that i need to send is 32 bytes and NRF42L01 has a 32 payload only

how can i use different pipelines and i h ave only 3 pipelines working out of the 6 without a reasonable cause

I wonder is this the problem (from the nRF24L01+ datasheet)

Maximum three ACK packet payloads can be
pending.

...R

hi robin2

i have not used more than 2 ack packets at a time,but in general pipes from 2-4 are not working without a proper reason

vagulus:
Firstly, I still use the archaic terms 'master' and 'slave'. I trust everybody will know what I mean even if I am not trendy ::slight_smile:

Now, my problem with that is that when I try to use slaves 2-5 all mayhem breaks loose with slaves reading and trying to respond to transmissions which were never intended for them. I have been battling this problem for some months now. Fortunately, CaptainJack appears to have encountered the same problem and to have come up with a solution in this other thread. Unfortunately, he did not include the magical addresses which solved his problem.

this is the problem that i am facing now and i am trying to solve but have not achieved the clue yet

It appends a specific value
(2 in this case) to the end to signify the end of the
message.

This is completely pointless. And the byte that is being used for the '2' could be used for an ID.

The nRF24 sends and receives the entire message as a block - it is either all received, or none of it is received.

I also notice that you have Sha256 stuff. If the purpose of that is to improve reliability I reckon it is quite unnecessary as the nRF24 has a lot of in-built error checking.

For exploring the problem with the inability to use certain pipes can you create minimal programs that just send and receive a simple message so that I can try it on my nRF24s

...R

Robin2:
For exploring the problem with the inability to use certain pipes can you create minimal programs that just send and receive a simple message so that I can try it on my nRF24s

...R

that is a good choice i will try it now

still facing the same problem after using a simple program to send using pipe"2"

I know that all pipes are able to acknowledge and three of them can use ack-payload at a time.

mestek123:
still facing the same problem after using a simple program to send using pipe"2"

Post the ****** programs so we can see them - and maybe try them.

…R

Whandall:
I know that all pipes are able to acknowledge and three of them can use ack-payload at a time.

pipes 2-5 dusn work at all not just receiving ack