Can anyone help me on how to correct my program ? I want to transmit value in string form.

I put this to TX code

struct payload_t

 String sensor1;


At the loop part I put this code

String sensor1 = (String(x) + "," + String(y) + "," + String(z)) ;

In the RX part I put this code

 struct payload_t

 String sensor1;

At the loop part

RF24NetworkHeader header;
payload_t payload;

Serial.println("Sensor1 "); 


Below is the Attach picture result of RX code.enter image description here

Thanks in advance :)


Did you actually 'instantiate' the struct in the TX and construct sensor1 as payload.sensor1 = ...? Anyways, there's still a problem.

You are using String in your payload. The third argument to read is the maximum message length that can be stored in payload. In your read call, you passed the size of payload as MAX_LEN. You will receive incomplete payloads since the String object in the RX payload struct has no content in it yet and thus payload's size, which you passed as MAX_LEN, will be less than that of the actual payload that was transmitted. Just ditch the Strings and try:


int vals = {x, y, z};   // guessing they are ints

network.write(header, &vals, sizeof(vals));


int vals[3];
network.read(header, &vals, sizeof(vals));

Serial.print(vals[0]); Serial.print(',');
Serial.print(vals[1]); Serial.print(',');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.