Error dynamic payload with NRF24L01 and tmrh20 librairy


hello,

i trying send string between 2 arduino using nrf24l01 , tmrh20 library. use code dynamic_payload_example , simplify still not working. know wiring correct work static payload.

so code send data :
#include <spi.h>
#include "nrf24l01.h"
#include "rf24.h"


/* hardware configuration: set nrf24l01 radio on spi bus plus pins 7 & 8 */
rf24 radio(8,9);

// sets role of unit in hardware.  connect gnd 'pong' receiver
// leave open 'ping' transmitter
//
// topology
//
// radio pipe addresses 2 nodes 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 , configure rf radio
  //
  radio.begin();
  // enable dynamic payloads
  radio.enabledynamicpayloads();
  // optionally, increase 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 receiver :


// on nodemcu ce ies connecte d2 mean gpio4 arduino csn on d8 15 arduino


#include <spi.h>
#include "nrf24l01.h"
#include "rf24.h"


// radio pipe addresses 2 nodes 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 setup code here, run once:
serial.begin(115200);
radio.begin();
// enable dynamic payloads
radio.enabledynamicpayloads();
radio.openreadingpipe(1,pipes[0]);
radio.startlistening();
radio.printdetails();

}

void loop() {
  // put main code here, run repeatedly:
while ( radio.available() )
    {
      // fetch payload, , see if last one.
      uint8_t len = radio.getdynamicpayloadsize();

      /*
      // if corrupt dynamic payload received, flushed
      if(!len){
        continue;
      }
      */
      radio.read( receive_payload, len );
      // put 0 @ end 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 can talk
      radio.stoplistening();
      // send final 1 back.
     
      radio.startlistening();
    }
}

but receiver doesn't receive print radio details. idea ?

have @ simple nrf24l01+ tutorial. have deliberately made examples simpler tmrh20 examples.

the second example uses ackpayload feature , automatically uses dynamic payloads

and please modify post , use code button </>
code: [select]
so code looks this , easy copy text editor. see how use forum code long me study without copying text editor.

...r


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Error dynamic payload with NRF24L01 and tmrh20 librairy


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor