multihop communication use nrf24l01+

Hi, I try to build a project with 3 nodes, one as master node, a nodeA and a nodeB. all of nodes are use arduino nano and nRF24L01+
first, master node will send the ‘A’ data to nodeA, then nodeA receive data from master node and then send the ‘A’ data again to nodeB

my problem is, when i use 2 nodes, one master node and one nodeA, it works. the nodeA received the ‘A’ data from master node. but when i add one nodeB and try to send the ‘A’ data received by nodeA to nodeB, all i get is just master node showing “Data sent A Acknowledge received” and nodeA didn’t show anything and didn’t send anything to nodeB.

i use RF24 tmrh20 library. code is as below. please, help me. thanks

code of master node:

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

#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char data = 'A';

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

void loop() {
  // put your main code here, to run repeatedly:
      currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send1();
        prevMillis = millis();
    }

}
void send1() {

    bool rslt;
    rslt = radio.write( &data, sizeof(data) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(data);
    if (rslt) {
        Serial.println("  Acknowledge received");
       // updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

code of nodeA :

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

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
const byte toSlaveAddress[5] = {'T','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char data;
char data2 = 'B';
bool newData = false;

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

    Serial.println("Broadcaster Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.openWritingPipe(toSlaveAddress);
    radio.setRetries(3,5); // delay, count
    radio.startListening();

}

void loop() {
  // put your main code here, to run repeatedly:
  getData();
    showData();
    send2();

}

void getData() {

    if ( radio.available() ) {
        radio.read( &data, sizeof(data) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(data);
    }
}

void send2() {
    if (newData == true) {
        radio.stopListening();
            bool rslt;
            rslt = radio.write( &data2, sizeof(data2) );
        radio.startListening();

        Serial.print("Reply Sent ");
        Serial.println(data2);

        if (rslt) {
            Serial.println("Acknowledge Received");
           // updateReplyData();
        }
        else {
            Serial.println("Tx failed");
        }
        Serial.println();
        newData = false;
    }
}

code of nodeB :

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

#define CE_PIN   9
#define CSN_PIN 10
#define led 2

const byte toSlaveAddress[5] = {'T','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char data2;
bool newData = false;

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, toSlaveAddress);
    radio.startListening();

    pinMode(led, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  getData();
    showData();

}

void getData() {
    if ( radio.available() ) {
        radio.read( &data2, sizeof(data2) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        digitalWrite(led,HIGH);
        delay(800);
        digitalWrite(led,LOW);
        Serial.print("Data received ");
        Serial.println(data2);
        newData = false;
    }
}

Your “piggy in the middle” is very like the code in the 3rd example in my Simple nRF24L01+ Tutorial - and is what I would have recommended.

Have you been able to get the pair of programs from that example working? If not, that’s the place to start.

I’m not quite sure what this means

my problem is, when i use 2 nodes, one master node and one nodeA, it works. the nodeA received the ‘A’ data from master node. but when i add one nodeB and try to send the ‘A’ data received by nodeA to nodeB, all i get is just master node showing “Data sent A Acknowledge received”

Do you mean that the posted pair of programs Master and NodeA work while NodeB is powered off, but they stop working when you power up NodeB?

If not, exactly what do you mean?

…R

Robin2:
Have you been able to get the pair of programs from that example working? If not, that's the place to start.

yes, i've been try the program from your tutorial and it's working.

Robin2:
I'm not quite sure what this meansDo you mean that the posted pair of programs Master and NodeA work while NodeB is powered off, but they stop working when you power up NodeB?

If not, exactly what do you mean?

I mean, when i use master node as Transmitter and nodeA as receiver only, it works. the nodeA receive the data from master node. but when i change the program of nodeA, make it as a receiver from master and transmitter to nodeB, it didn't work

zazaa:
I mean, when i use master node as Transmitter and nodeA as receiver only, it works. the nodeA receive the data from master node. but when i change the program of nodeA, make it as a receiver from master and transmitter to nodeB, it didn’t work

Then please post the pair of programs that do work and the revised program that causes the system to fail so that we can put them side by side to see the differences (by the way, that is a hint).

…R