nRF address issue

Members

I want to read data -using a master unit- from units 'B' and 'F' and switch a led on/off on unit 'A'. Unit 'B & F' use ack to return 2 values and work fine.
I am unable to target the address on Unit 'A' to switch a led on/off. Please see line //========nRF=====ADDRESS not working =======

Master program that I want too use: edited version as the character limit is reached

//sample


/*   Due_SubMenu
Data
on/off
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <MCUFRIEND_kbv.h>
//#include <Adafruit_GFX.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

//removed due to caracter limits in forum

//indicates number of slaves, see addresses below in { }
const byte numSlaves = 3;   //Maximum 6 units
const byte slaveAddress[numSlaves][5] = {
  {'R', 'x', 'A', 'A', 'A'}, //2 leds to be switched
  {'R', 'x', 'A', 'A', 'B'}, //2 numbers via ack
  {'R', 'x', 'A', 'A', 'F'}, //2 numbers via ack
};

char dataToSend[32] = "Unit ";
float ackData[2] = { -11.11, -11.11};
bool newData = false;
unsigned long currentMillis;
unsigned long prevMillis = -4000;
unsigned long txIntervalMillis = 4000;

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 365);
Adafruit_GFX_Button on_btn, off_btn, on_btn1, off_btn1, on_btn10, off_btn10,
                    on_btn11, off_btn11, on_btn12, off_btn12, on_btn13, off_btn13;

char currentPage;
int msg[1];
int pixel_x, pixel_y;

bool Touch_getXY(void)
{
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
  }
  return pressed;
}

void setup() {

  //removed due to forum caracter limits
  currentPage = '0'; 

}

// Array of button addresses to behave like a list
Adafruit_GFX_Button *buttons[] = {&on_btn, &off_btn, &on_btn1, &off_btn1,
                                  &on_btn10, &off_btn10, &on_btn11, &off_btn11,
                                  &on_btn12, &off_btn12, &on_btn13, &off_btn13,
                                  NULL
                                 };

bool update_button(Adafruit_GFX_Button * b, bool down)
{
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  return down;
}


bool update_button_list(Adafruit_GFX_Button **pb)
{
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop() {
  PressButton();
}

void PressButton() {
  update_button_list(buttons);
  if (currentPage == '0') { //home screen
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }
  }  //END currentPage==0
 
  //Data====
  if (currentPage == '1')  {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {

      sendA(); //send request for a reading
    }
  }

  //======OnOff=========
  if (currentPage == '2') {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }

    //========nRF=====ADDRESS not working ======================
    if (on_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);
      msg[0] = 001;                   // LED A0=on
      radio.write(msg, 1);
    }
    if (off_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);
      msg[0] = 000;                    // LED A0=off
      radio.write(msg, 1);
    }
    if (on_btn1.justPressed()) {    // unit 1
      radio.openWritingPipe (slaveAddress[0]);
      msg[0] = 101;                 // LED A1=on
      radio.write(msg, 1);          // transmitt button two is pressed

    }
    if (off_btn1.justPressed()) {    // unit 1
      radio.openWritingPipe (slaveAddress[0]);
      msg[0] = 100;                 // LED A1=off
      radio.write(msg, 1);          // transmitt button two is pressed
    }
//==============..................===========================
    if (on_btn2.justPressed()) {       // unit 2
      radio.openWritingPipe(slaveAddress[1]);
      msg[0] = 001;                  // LED A0=on
      radio.write(msg, 1);
    }
    if (off_btn2.justPressed()) {       // unit 2
      radio.openWritingPipe(slaveAddress[1]);
      msg[0] = 000;                     // LED A0=off
      radio.write(msg, 1);
    }
    //===============================================================

  }

  //======info=========
  if (currentPage == '3') {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
  }

} //END PressButton()


void HomePage(){
  currentPage = '0';
  //caracter limit
  
}

void Data() {
  currentPage = '1';
  //caracter limit
  
  sendA();
}



void OnOff(){
  currentPage = '2';
  tft.fillScreen(BLACK);

  on_btn.initButton(&tft,  230, 15, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn.initButton(&tft, 285, 15, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn.drawButton(false);
  off_btn.drawButton(false);
  on_btn1.initButton(&tft,  230, 50, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn1.initButton(&tft, 285, 50, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn1.drawButton(false);
  off_btn1.drawButton(false);
 
  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);
 
}

void Info()  {
  currentPage = '3';
  //caracter limit
  
}

void sendA() {

  tft.fillRect (0, 0, 320, 170, BLACK);
  tft.setCursor(1, 5);
  tft.setTextColor(WHITE);
  tft.setTextSize(2);
  sendB();
}

void sendB() {
  
  for (byte n = 0; n < numSlaves; n++) {
    radio.openWritingPipe(slaveAddress[n]);
    dataToSend[5] = n + '1'; 
    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );

    if (rslt) {
      if ( radio.isAckPayloadAvailable() ) {
        radio.read(&ackData, sizeof(ackData));
        newData = true;
      }
    }

    if (newData == true) {
      tft.print(dataToSend); 
      tft.print(" "); //ln no
      tft.print(ackData[0]);
      tft.print(","); //ln no
      tft.println(ackData[1]);
      tft.println();
      newData = false;
    }
  }

  prevMillis = millis();
}// end sendB

program for Unit 'A & B' are below

/*Rx_OnOff_multi
  Rx UNO
  working corectly 4 Jan 2019
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//   ....UNO ...........CHECK
#define CE_PIN 6  //confirm pin connections for nrf
#define CSN_PIN 7


int msg[1];
RF24 radio(CE_PIN, CSN_PIN);
//const uint64_t pipe = 0xE14BC8F482LL;
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
int LED0 = 2;     // led pin
int LED1 = 3;

void setup(void) {

  Serial.begin(9600);
  radio.begin();
  //radio.openReadingPipe(1, pipe);
  radio.openReadingPipe(1, slaveAddress);
  radio.startListening();
  pinMode(LED0, OUTPUT);
  pinMode(LED1, OUTPUT);
}

void loop(void) {
  if (radio.available()) {

    radio.read(msg, 1);
    Serial.println(msg[0]);
    if (msg[0] == 001) {
      delay(10); digitalWrite(LED0, HIGH);
    }
    if (msg[0] == 000) {
      delay(10); digitalWrite(LED0, LOW);
    }
    if (msg[0] == 101) {
      delay(10); digitalWrite(LED1, HIGH);
    }
    if (msg[0] == 100) {
      delay(10); digitalWrite(LED1, LOW);
    }
  }

  else {
    Serial.println("No radio available");
  }
}
//UNO send 2 vallues via nRF
// SimpleRxAckPayload- the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 6  //confirm pin connections for nrf
#define CSN_PIN 7

const byte thisSlaveAddress[6] = {'R','x','A','A','B'};//unique for each unit A=0 B=1 C=2 D=3 E=4 F=5

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[32]; // this must match dataToSend in the TX
float ackData[2] = {11.09, -120.00}; // the two values to be sent to the master
bool newData = false;

//==============

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRxAckPayload Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.enableAckPayload();
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // pre-load data
    radio.startListening();
}

//==========

void loop() {
    getData();
    showData();
}

//============

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

//================

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        Serial.print(" ackPayload sent ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        newData = false;
    }
}

//================

void updateReplyData() {
    ackData[0] -= 0.01;
    ackData[1] -= 0.01;
    if (ackData[0] < 11.00) {
        ackData[0] = 11.09;
    }
    if (ackData[1] < -120.09) {
        ackData[1] = -120.00;
    }
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // load the payload for the next time
}

I have looked at your programs but I can't relate them to the description of the problem. I'm guessing that you mean communication with slaveA works but communication with slaveB does not.

Can you give more details about how you know there is a problem - such as sample output from the program.

Can you take all the push-button stuff out of a copy of the master code and just make it send a fixed message to each slave in turn - short programs make debugging much easier.

...R

Apologies. I fixed the description at the top. Data is received from B & F. But when a move to another sub menu the on/off is not working unless I do the following:

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

Thanks

fnb111:
unless I do the following:

Is that some arcane incantation on the night of a full moon?

Or, in other words, without seeing the whole program in which that line has an effect it is meaningless.

And, in addition to the program that contains that line (or doesn't) you need to provide information about the behaviour of the Arduino at the other end of the wireless link. Otherwise we are trying to debug one-hand clapping.

...R

This is only an example of the addressing that does work. I had to separate the addresses, When this is loaded to my master DUE:

/*DUE_OnOff_multi
  TX &TFT 2.8" ADAFRUIT 8 bit &nRF
  on/off 2 LED's
  works corectly 4 Jan 2019
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>

//Touchscreen X+ X- Y+ Y- pins
#define YP A5
#define XM A4
#define YM 10
#define XP 11
//tested as correct for new ADAFRUIT screen
#define TS_MINX 150
#define TS_MINY 90
#define TS_MAXX 900
#define TS_MAXY 800

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define BLACK       0x0000
#define NAVY        0x000F
#define DARKGREEN   0x03E0
#define DARKCYAN    0x03EF
#define MAROON      0x7800
#define PURPLE      0x780F
#define OLIVE       0x7BE0
#define LIGHTGREY   0xC618
#define DARKGREY    0x7BEF
#define BLUE        0x001F
#define GREEN       0x07E0
#define CYAN        0x07FF
#define RED         0xF800
#define MAGENTA     0xF81F
#define YELLOW      0xFFE0
#define WHITE       0xFFFF
#define ORANGE      0xFDA0
#define GREENYELLOW 0xB7E0
#define PINK        0xFC9F

#define MINPRESSURE 10
#define MAXPRESSURE 1000
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
Adafruit_GFX_Button on_btn, off_btn, on_btn1, off_btn1, on_btn2, off_btn2,
                    on_btn3, off_btn3, on_btn4, off_btn4, on_btn5, off_btn5;

#define CE_PIN 50  //confirm pin connections for nrf
#define CSN_PIN 51

RF24 radio(CE_PIN, CSN_PIN);
const byte slaveAddressA[5] = {'R', 'x', 'A', 'A', 'A'};
const byte slaveAddressC[5] = {'R', 'x', 'A', 'A', 'C'};
//const uint64_t pipe = 0xE14BC8F482LL;

int msg[1];
int pixel_x, pixel_y;

bool Touch_getXY(void)
{
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
    Serial.println( pixel_x);
    Serial.println( pixel_y);
  }
  return pressed;
}

void setup(void) {
  Serial.begin(9600);
  radio.begin();

  uint16_t ID = tft.readID();
  tft.begin(ID);
  tft.setRotation(1);
  tft.fillScreen(BLACK);
  on_btn.initButton(&tft,  230, 15, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn.initButton(&tft, 285, 15, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn.drawButton(false);
  off_btn.drawButton(false);
  on_btn1.initButton(&tft,  230, 50, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn1.initButton(&tft, 285, 50, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn1.drawButton(false);
  off_btn1.drawButton(false);
  on_btn2.initButton(&tft,  230, 85, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn2.initButton(&tft, 285, 85, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn2.drawButton(false);
  off_btn2.drawButton(false);
  on_btn3.initButton(&tft,  230, 120, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn3.initButton(&tft, 285, 120, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn3.drawButton(false);
  off_btn3.drawButton(false);
  on_btn4.initButton(&tft,  230, 155, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn4.initButton(&tft, 285, 155, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn4.drawButton(false);
  off_btn4.drawButton(false);
  on_btn5.initButton(&tft,  230, 190, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn5.initButton(&tft, 285, 190, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn5.drawButton(false);
  off_btn5.drawButton(false);
  
}// end setup

// Array of button addresses to behave like a list
Adafruit_GFX_Button *buttons[] = {&on_btn, &off_btn, &on_btn1, &off_btn1,
                                  &on_btn2, &off_btn2, &on_btn3, &off_btn3,
                                  &on_btn4, &off_btn4, &on_btn5, &off_btn5 , NULL
                                 };


bool update_button(Adafruit_GFX_Button *b, bool down)
{
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  return down;
}


bool update_button_list(Adafruit_GFX_Button **pb)
{
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop(void) {

  PressButton();
}


void PressButton() {
  //=============================..change button & unit number..UNIT A
  update_button_list(buttons);
  
  if (on_btn.justPressed()) {         // tft button row 1
    radio.openWritingPipe(slaveAddressA);
    msg[0] = 001;                      // LED0=on
    radio.write(msg, 1);
  }
  
  if (off_btn.justPressed()) {        // read button is pressed
    radio.openWritingPipe(slaveAddressA);
    msg[0] = 000;                     // LED0=off
    radio.write(msg, 1);
  }
  
  if (on_btn1.justPressed()) {        // tft button row 2
    radio.openWritingPipe(slaveAddressA);
    msg[0] = 101;                     // LED1=on
    radio.write(msg, 1);
  }
  
  if (off_btn1.justPressed()) {
    radio.openWritingPipe(slaveAddressA);
    msg[0] = 100;                    // LED1=off
    radio.write(msg, 1);
    //===========================...........................UNIT A end
  }
  //=============================..change button & unit number..UNIT C
  
  if (on_btn2.justPressed()) {           // tft button row 1
    radio.openWritingPipe(slaveAddressC);
    msg[0] = 001;                        // LED0=on
    radio.write(msg, 1);
  }
  
  if (off_btn2.justPressed()) {          // read button is pressed
    radio.openWritingPipe(slaveAddressC);
    msg[0] = 000;                        // LED0=off
    radio.write(msg, 1);
  }
  
  if (on_btn3.justPressed()) {            // tft button row 2
    radio.openWritingPipe(slaveAddressC);
    msg[0] = 101;                 // LED1=on
    radio.write(msg, 1);
  }
  
  if (off_btn3.justPressed()) {
    radio.openWritingPipe(slaveAddressC);
    msg[0] = 100;                        // LED1=off
    radio.write(msg, 1);
    // ==========================..........................UNIT C end
  }
}// end PressButton

The led is switched on/off- no issues.

fnb111:
The led is switched on/off- no issues.

Thanks for the update. Glad to see you have figured out a solution.

...R

I did not manage to solve the issue as of yet. The first post "/* Due_SubMenu' is the program I cant get the addressing correct.

 //========nRF=====ADDRESS not working ======================
    if (on_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);
      msg[0] = 001;                   // LED A0=on
      radio.write(msg, 1);
    }
    if (off_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);
[code]

Im unable to target the address of a specific unit in order to switch the led on/off. The address as used in the line ' radio.openWritingPipe (slaveAddress[0]);' compiles correctly but it does not switch the led.

Ive tried replacing the word 'slaveAddress' with the actual address ( {'R', 'x', 'A', 'A', 'A'} ) but it did not compile.

In your "master" program, I don't see where you have instantiated a radio, like RF24 radio(CE_PIN, CSN_PIN);
You can attach a file by going to the bottom of the reply page (not quick reply), clicking "attachments", then "browse", find the file in your file system, select it and click "open".

fnb111:
I did not manage to solve the issue as of yet.

That does not surprise me - but you have to admit that my interpretation of your Reply #7 was reasonable - "The led is switched on/off- no issues."

Unfortunately until you take the trouble to provide comprehensive information about your problem, including answering my earlier questions, I don't know how to help.

Snippets of information like in Reply #10 may mean something to you because you have the whole picture in your head but they are meaningless to me because I don't have all the background info.

...R

/*   Due_SubMenu
  
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <MCUFRIEND_kbv.h>
//#include <Adafruit_GFX.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 
#define LCD_CD A2 
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define YP A5
#define XM A4
#define YM 10
#define XP 11

#define TS_MINX 150
#define TS_MINY 90
#define TS_MAXX 900
#define TS_MAXY 800

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define BLACK       0x0000
#define CYAN        0x07FF
#define DARKCYAN    0x03EF
#define DARKGREY    0x7BEF
#define GREEN       0x07E0
#define LIGHTGREY   0xC618
#define MAGENTA     0xF81F
#define RED         0xF800
#define WHITE       0xFFFF
#define YELLOW      0xFFE0

#define MINPRESSURE 10
#define MAXPRESSURE 1000

#define CE_PIN  50  //nrf24
#define CSN_PIN 51  //nrf24
RF24 radio(CE_PIN, CSN_PIN);

const byte numSlaves = 3;  
const byte slaveAddress[numSlaves][5] = {
  {'R', 'x', 'A', 'A', 'A'}, //on/off
  {'R', 'x', 'A', 'A', 'B'}, //Data
  {'R', 'x', 'A', 'A', 'F'}, //Data
};

char dataToSend[32] = "Unit ";
float ackData[2] = { -11.11, -11.11};
bool newData = false;
unsigned long currentMillis;
unsigned long prevMillis = -4000;
unsigned long txIntervalMillis = 4000;

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 365);
Adafruit_GFX_Button on_btn, off_btn, on_btn1, off_btn1, on_btn2, off_btn2, on_btn3, off_btn3,
                    on_btn4, off_btn4, on_btn10, off_btn10, on_btn11, off_btn11 ,
                    on_btn12, off_btn12, on_btn13, off_btn13;

char currentPage;
int msg[1];
int pixel_x, pixel_y;

bool Touch_getXY(void)
{
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
    
  }
  return pressed;
}

void setup() {

  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.enableAckPayload();
  radio.setRetries(10, 8);

  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  tft.setTextColor(WHITE);
  HomePage();
  currentPage = '0'; 

}

Adafruit_GFX_Button *buttons[] = {&on_btn, &off_btn, &on_btn1, &off_btn1, &on_btn2, &off_btn2,
                                  &on_btn3, &off_btn3, &on_btn4, &off_btn4,
                                  &on_btn10, &off_btn10, &on_btn11, &off_btn11 , &on_btn12, &off_btn12,
                                  &on_btn13, &off_btn13, NULL
                                 };


bool update_button(Adafruit_GFX_Button * b, bool down)
{
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  return down;
}


bool update_button_list(Adafruit_GFX_Button **pb)
{
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop() {
  PressButton();
}

void PressButton() {
  update_button_list(buttons);
  if (currentPage == '0') { 
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }
  }  
 
  
  if (currentPage == '1')  {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {

      sendA(); 
    }
  }

  if (currentPage == '2') {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }


    if (on_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);//address not working correctly
      msg[0] = 001;                   // LED A0=on
      radio.write(msg, 1);
    }
    if (off_btn.justPressed()) {       // unit 1
      radio.openWritingPipe (slaveAddress[0]);//address not working correctly
      msg[0] = 000;                    // LED A0=off
      radio.write(msg, 1);
    }
    if (on_btn1.justPressed()) {    // unit 1
      radio.openWritingPipe (slaveAddress[0]);//address not working correctly
      msg[0] = 101;                 // LED A1=on
      radio.write(msg, 1);          // transmit button two is pressed

    }
    if (off_btn1.justPressed()) {    // unit 1
      radio.openWritingPipe (slaveAddress[0]);//address not working correctly
      msg[0] = 100;                 // LED A1=off
      radio.write(msg, 1);          // transmit button two is pressed
    }



    if (on_btn2.justPressed()) {       // unit 2
      radio.openWritingPipe(slaveAddress[1]);//address not working correctly
      msg[0] = 001;                  // LED A0=on
      radio.write(msg, 1);
    }
    if (off_btn2.justPressed()) {       // unit 2
      radio.openWritingPipe(slaveAddress[1]);//address not working correctly
      msg[0] = 000;                     // LED A0=off
      radio.write(msg, 1);
    }
    if (on_btn3.justPressed()) {    // unit 2
      radio.openWritingPipe(slaveAddress[1]);//address not working correctly
      msg[0] = 101;                 // LED A1=on
      radio.write(msg, 1);          // transmit button two is pressed

    }
    if (off_btn3.justPressed()) {    // unit 2
      radio.openWritingPipe(slaveAddress[1]);//address not working correctly
      msg[0] = 100;                 // LED A1=off
      radio.write(msg, 1);          // transmit button two is pressed
    }

  }

  if (currentPage == '3') {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      Data();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      OnOff();
      currentPage == '2';
    }
  }

} //END PressButton()


void HomePage() //page==0
{
  currentPage = '0';
  tft.fillScreen(BLACK);
  tft.setCursor(60, 20);
  tft.setTextSize(2);
  tft.print("C");

  //on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  //on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  on_btn12.initButton(&tft, 120, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);
  update_button_list(buttons);
}

void Data()   //page==1
{
  currentPage = '1';
  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  //on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  //on_btn11.drawButton(false);
  on_btn12.initButton(&tft, 120, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);
  update_button_list(buttons);
  sendA();
}



[code]
void OnOff()  //page==2...............p8
{
  currentPage = '2';//graphics for OnOff
  tft.fillScreen(BLACK);

  on_btn.initButton(&tft,  230, 15, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn.initButton(&tft, 285, 15, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn.drawButton(false);
  off_btn.drawButton(false);
  on_btn1.initButton(&tft,  230, 50, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn1.initButton(&tft, 285, 50, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn1.drawButton(false);
  off_btn1.drawButton(false);
  on_btn2.initButton(&tft,  230, 85, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn2.initButton(&tft, 285, 85, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn2.drawButton(false);
  off_btn2.drawButton(false);
  on_btn3.initButton(&tft,  230, 120, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn3.initButton(&tft, 285, 120, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn3.drawButton(false);
  off_btn3.drawButton(false);
  on_btn4.initButton(&tft,  230, 155, 50, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn4.initButton(&tft, 285, 155, 50, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn4.drawButton(false);
  off_btn4.drawButton(false);

  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  //on_btn12.initButton(&tft, 120, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  // on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);
  update_button_list(buttons);
}

void Info()   //page==3
{
  currentPage = '3';//print Information ie model no/ unit address/etc screen graphics
  tft.fillScreen(BLACK);
  tft.setCursor(20, 120);
  tft.print("Info screen");

  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  on_btn12.initButton(&tft, 120, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);
  //on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  //on_btn13.drawButton(false);
  update_button_list(buttons);
}

void sendA() {

  tft.fillRect (0, 0, 320, 170, BLACK);
  tft.setCursor(1, 5);
  tft.setTextColor(WHITE);
  tft.setTextSize(2);
  sendB();
}

void sendB() {
  // call each Unit in turn
  for (byte n = 0; n < numSlaves; n++) {
    radio.openWritingPipe(slaveAddress[n]);// works correctly
    // include the Unit number in the message
    dataToSend[5] = n + '1';       //start 'unit no' at 1
    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );

    if (rslt) {
      if ( radio.isAckPayloadAvailable() ) {
        radio.read(&ackData, sizeof(ackData));
        newData = true;
      }
    }

    if (newData == true) {
      tft.print(dataToSend);   //println no
      tft.print(" "); //ln no
      tft.print(ackData[0]);  // the value ONLY
      tft.print(","); //ln no
      tft.println(ackData[1]);  // the value ONLY
      tft.println();
      newData = false;
    }
   
  }
  prevMillis = millis();
}// end sendB

I fixed a couple of issues I found in the DUE's programming but the section I use for on/off switching is still not working.
The Data is read - no problem there.

When I call this:

radio.stopListening();
update_button_list(buttons); //======change button & unit number..UNIT E
radio.openWritingPipe(addressE);

I get no response from Unit E. (on/off) It should switch a led on/off.

/*Rx_OnOff_multi
  Rx UNO
  working corectly 4 Jan 2019
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//   ....UNO ...........CHECK
#define CE_PIN 6  //confirm pin connections for nrf
#define CSN_PIN 7


int msg[1];
RF24 radio(CE_PIN, CSN_PIN);

const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'E'};
int LED0 = 2;     // led pin
int LED1 = 3;

void setup(void) {

  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, slaveAddress);
  radio.startListening();
  pinMode(LED0, OUTPUT);
  pinMode(LED1, OUTPUT);
}

void loop(void) {
  if (radio.available()) {

    radio.read(msg, 1);
    Serial.println(msg[0]);
    if (msg[0] == 01) {
      delay(10); digitalWrite(LED0, HIGH);
    }
    if (msg[0] == 00) {
      delay(10); digitalWrite(LED0, LOW);
    }
    if (msg[0] == 11) {
      delay(10); digitalWrite(LED1, HIGH);
    }
    if (msg[0] == 10) {
      delay(10); digitalWrite(LED1, LOW);
    }
  }

  else {
    Serial.println("No radio available");
  }
}
/*   Due_SubMenu
   
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <MCUFRIEND_kbv.h>
//#include <Adafruit_GFX.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 //shared pins
#define LCD_CD A2 //shared pins
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

//Touchscreen X+ X- Y+ Y- pins
#define YP A5
#define XM A4
#define YM 10
#define XP 11
//tested as correct for new ADAFRUIT screen
#define TS_MINX 150
#define TS_MINY 90
#define TS_MAXX 900
#define TS_MAXY 800

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define BLACK       0x0000
#define BLUE        0x001F
#define CYAN        0x07FF
#define DARKGREEN   0x03E0
#define DARKCYAN    0x03EF
#define DARKGREY    0x7BEF
#define GREEN       0x07E0
#define GREENYELLOW 0xB7E0
#define LIGHTGREY   0xC618
#define MAGENTA     0xF81F
#define MAROON      0x7800
#define NAVY        0x000F
#define OLIVE       0x7BE0
#define ORANGE      0xFDA0
#define PINK        0xFC9F
#define PURPLE      0x780F
#define RED         0xF800
#define WHITE       0xFFFF
#define YELLOW      0xFFE0

#define MINPRESSURE 10
#define MAXPRESSURE 1000

#define CE_PIN  50  //nrf24
#define CSN_PIN 51  //nrf24
RF24 radio(CE_PIN, CSN_PIN);

// to hold the Unit no,Data
float Data[3] = { 1, 111.11, 11.11};
unsigned long currentMillis;      
unsigned long prevMillis = -1000;
unsigned long  txIntervalMillis = 1000;

const byte addressA[5] = {'R', 'x', 'A', 'A', 'A'}; 
//const byte addressB[5] = {'R', 'x', 'A', 'A', 'B'}; 
const byte addressE[5] = {'R', 'x', 'A', 'A', 'E'};
const byte addressF[5] = {'R', 'x', 'A', 'A', 'F'}; 

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 365);
Adafruit_GFX_Button on_btn, off_btn, on_btn1, off_btn1, on_btn2, off_btn2, on_btn3, off_btn3,
                    on_btn4, off_btn4, on_btn10, off_btn10, on_btn11, off_btn11 ,
                    on_btn12, off_btn12, on_btn13, off_btn13;

char currentPage;
int msg[1];
int pixel_x, pixel_y;
int Unit;
bool Touch_getXY(void)
{
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
    //Serial.println( pixel_x);
    // Serial.println( pixel_y);
  }
  return pressed;
}

void setup() {

  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  tft.setTextColor(WHITE);
  HomePage();
  currentPage = '0';

}

// Array of button addresses to behave like a list
Adafruit_GFX_Button *buttons[] = {&on_btn, &off_btn, &on_btn1, &off_btn1, &on_btn2, &off_btn2,
                                  &on_btn3, &off_btn3, &on_btn4, &off_btn4,
                                  &on_btn10, &off_btn10, &on_btn11, &off_btn11 , &on_btn12, &off_btn12,
                                  &on_btn13, &off_btn13, NULL
                                 };


bool update_button(Adafruit_GFX_Button * b, bool down)
{
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  return down;
}


bool update_button_list(Adafruit_GFX_Button **pb)
{
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop() {

  update_button_list(buttons);
  if (currentPage == '0') { //home screen
    if (on_btn11.justPressed()) {
      ReadData();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      //tft.fillScreen(BLACK);//3
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }

  }  //END currentPage==0
  //.........................end of currentPage==0

  if (currentPage == '1')  {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn12.justPressed()) {
      //tft.fillScreen(BLACK);//3
      OnOff();
      currentPage == '2';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {

      ReadData(); 
    }
  }//.........END currentPage==1

  
  if (currentPage == '2') {
    
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      ReadData();
      currentPage == '1';
    }
    if (on_btn13.justPressed()) {
      Info();
      currentPage == '3';
    }
    radio.stopListening();
    update_button_list(buttons);    
    radio.openWritingPipe(addressE);
    
    if (on_btn.justPressed()) {      
      
      msg[0] = 01;                      // LED0=on
      radio.write(msg, 1);
      Serial.println(" LED1 on");
      Serial.println(*msg);
      Serial.println("  ");
    }

    if (off_btn.justPressed()) {   
      
      msg[0] = 00;                     // LED0=off
      radio.write(msg, 1);
    }

    if (on_btn1.justPressed()) {        // tft button row 2
      
      msg[0] = 11;                     // LED1=on
      radio.write(msg, 1);
      Serial.println(" LED2 on");
      Serial.println(*msg);
      Serial.println("  ");
    }

    if (off_btn1.justPressed()) {
      
      msg[0] = 10;                    // LED1=off
      radio.write(msg, 1);
    }
    
    radio.openWritingPipe(addressF);
    
    if (on_btn2.justPressed()) {           // tft button row 1
      
      msg[0] = 01;                        // LED0=on
      radio.write(msg, 1);
    }

    if (off_btn2.justPressed()) {          // read button is pressed
      
      msg[0] = 00;                        // LED0=off
      radio.write(msg, 1);
    }

    if (on_btn3.justPressed()) {            // tft button row 2
      
      msg[0] = 11;                 // LED1=on
      radio.write(msg, 1);
    }

    if (off_btn3.justPressed()) {
     
      msg[0] = 10;                        // LED1=off
      radio.write(msg, 1);
    }


 if (currentPage == '3') {
    if (on_btn10.justPressed()) {
      HomePage();
      currentPage == '0';
    }
    if (on_btn11.justPressed()) {
      ReadData();
      currentPage == '1';
    }
    if (on_btn12.justPressed()) {
      //tft.fillScreen(BLACK);//3
      OnOff();
      currentPage == '2';
    }

  }//............................END currentPage == 3

} //END loop()
//continue
void HomePage() //page==0
{
  currentPage = '0';
  tft.fillScreen(BLACK);
  tft.setCursor(60, 20);
  tft.setTextSize(2);
  tft.print("C");
  update_button_list(buttons);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  on_btn12.initButton(&tft, 122, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);

}

void ReadData()   //page==1
{
  currentPage = '1';
  update_button_list(buttons);
  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn12.initButton(&tft, 122, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);

  sendA();
}
void sendA() {

  tft.fillRect (0, 0, 320, 170, BLACK);//clear prev data from sendB()
  tft.setCursor(5, 5);
  tft.setTextColor(WHITE);
  tft.setTextSize(2);
  sendB();
}

void sendB() {
  {
    radio.openReadingPipe(1, addressA);

    radio.startListening();
    radio.read(&Data, sizeof(Data));
    tft.print(Data[0] );   //Unit no
    tft.print(" "); //
    tft.print(Data[1]);  // Data
    tft.print(",");
    tft.println(Data[2]);  // Data
    tft.println();

  }
  prevMillis = millis();

}// end sendB

void OnOff() {              //page==2..
   Serial.println("graphics on/off");
  currentPage = '2';           //graphics for OnOff
  tft.fillScreen(BLACK);

  update_button_list(buttons);

  on_btn.initButton(&tft,  80, 15, 130, 30, CYAN, GREEN, BLACK, "on", 2);
  off_btn.initButton(&tft, 225, 15, 130, 30, CYAN, RED, BLACK, "off", 2);
  on_btn.drawButton(false);
  off_btn.drawButton(false);
  on_btn1.initButton(&tft,  80, 50, 130, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn1.initButton(&tft, 225, 50, 130, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn1.drawButton(false);
  off_btn1.drawButton(false);
  on_btn2.initButton(&tft,  80, 85, 130, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn2.initButton(&tft, 225, 85, 130, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn2.drawButton(false);
  off_btn2.drawButton(false);
  on_btn3.initButton(&tft,  80, 120, 130, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn3.initButton(&tft, 225, 120, 130, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn3.drawButton(false);
  off_btn3.drawButton(false);
  on_btn4.initButton(&tft,  80, 155, 130, 30, CYAN, GREEN, BLACK, "ON", 1);
  off_btn4.initButton(&tft, 225, 155, 130, 30, CYAN, RED, BLACK, "OFF", 1);
  on_btn4.drawButton(false);
  off_btn4.drawButton(false);

  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  on_btn13.initButton(&tft, 210, 200, 60, 40, CYAN, GREEN, BLACK, "Info", 2);
  on_btn13.drawButton(false);

}// end OnOff()


void Info()   //page==3
{
  currentPage = '3';
  tft.fillScreen(BLACK);
  tft.setCursor(20, 120);
  tft.print("Info screen");
  update_button_list(buttons);
  on_btn10.initButton(&tft, 280, 200, 60, 40, CYAN, GREEN, BLACK, "Home", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 40, 200, 60, 40, CYAN, GREEN, BLACK, "Data", 2);
  on_btn11.drawButton(false);
  on_btn12.initButton(&tft, 122, 200, 90, 40, CYAN, GREEN, BLACK, "on/off", 2);
  on_btn12.drawButton(false);

}
[code]

Do NOT expect people to sew your code back together to recreate what you have. Post your code as an attachment, if necessary.

It is not at al clear what your problem is now.

fnb111:
attached is the complete program

I'll be back to read that code when I know what the problem is.

The section that is used on the main program for on/off switching is still not working. The Data is read - no problem there (in other words - the nRF works correctly. )

When I call this in the main program:

radio.stopListening();
update_button_list(buttons); //======change button & unit number..UNIT E
radio.openWritingPipe(addressE);

I get no response from Unit F. It should switch a led on or off when a button is pressed on the screen.