Error dynamic payload with NRF24L01 and tmrh20 librairy

Hello,

I am trying to send string between two arduino using NRF24L01 and the tmrh20 library. So i use the code from Dynamic_payload_example and simplify it but it still not working. I know my wiring is correct as it work with static payload.

So the code to send the data is :
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(8,9);

// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
// Leave open to be the 'ping' transmitter
//
// Topology
//
// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

const int min_payload_size = 4;
void setup(void)
{

Serial.begin(115200);

Serial.println(F("RF24/examples/pingpair_dyn/"));

//
// Setup and configure rf radio
//
radio.begin();
// enable dynamic payloads
radio.enableDynamicPayloads();
// optionally, increase the delay between retries & # of retries

radio.openWritingPipe(pipes[0]);
radio.printDetails();
}
void loop(void)
{Serial.print(F("Now sending length "));
static char send_payload[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ789012";

radio.write( send_payload, min_payload_size );
delay(1000);
}

And the receiver is :

// ON the NodeMcu the CE ies connecte to D2 which mean GPIO4 for the arduino CSN is on D8 which is 15 for the arduino

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

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
RF24 radio(4,15);
const int min_payload_size = 4;
char receive_payload[min_payload_size];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
radio.begin();
// enable dynamic payloads
radio.enableDynamicPayloads();
radio.openReadingPipe(1,pipes[0]);
radio.startListening();
radio.printDetails();

}

void loop() {
// put your main code here, to run repeatedly:
while ( radio.available() )
{
// Fetch the payload, and see if this was the last one.
uint8_t len = radio.getDynamicPayloadSize();

/*
// If a corrupt dynamic payload is received, it will be flushed
if(!len){
continue;
}
*/
radio.read( receive_payload, len );
// Put a zero at the end for easy printing
receive_payload[len] = 0;
// Spew it
Serial.print(F("Got response size="));
Serial.print(len);
Serial.print(F(" value="));
Serial.println(receive_payload);
// First, stop listening so we can talk
radio.stopListening();
// Send the final one back.

radio.startListening();
}
}

But the receiver doesn't receive anything it just print the radio details. Any idea ?

Have a look at this Simple nRF24L01+ Tutorial. I have deliberately made the examples simpler than the TMRh20 examples.

The second example uses the ackPayload feature and that automatically uses dynamic payloads

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

...R

Hello,

I tried to execute the first code of your script however i get failed on the Tx at all time.

vdiallonort:
I tried to execute the first code of your script however i get failed on the Tx at all time.

You must use my programs as a pair - are you doing that?

If you are then please post the programs that YOU have uploaded to YOUR Arduinos and also please make a pencil drawing showing how YOU have everything connected and post a photo of the drawing.

...R