nRF24L01 radio.write

Hi there, i do apologise for my english, but i got the same issue, using the Network Library by Tmrh20. Basically, it uses the original sketches fotr tx and rx, but i have included a "switch button" to send message alternatly to one or the other receiver.

Even if each receiver seems to receive the message - print packets on the monitor - one is returning a failed while the other gets an OK. Original post is in french but you will have sketches here :

https://forum.arduino.cc/index.php?topic=615495.0

on the first post, i use 3 arduino linked to 3 computers to have the serial monitoring for each one, receivers sketches are the sames , modulo the address...

the 2nd post deals with a test including 4 receivers and a random sending, that lights on a led on the "choosen" receiver. Only one of the forth (the first one) send back an "ok" to the emetter, while the others are returning a failed even if the led lights on. 2 receiver and the emetter are powered by a USB port, while the 2 others receiver are powered by a 9v battery. Each Nrf Module is using a breakout adapter. there is two kind of Nrf modules (included antenna on the pcb and NRF24L01+Pa+LNA Modules).

Thx in advance

As Robin2 suggested, here is some details on the project.

The main idea is to create a kind of a "capture the flag" system based on a central remote and flag nodes displayed on a playing area.

Each node can be activated randomly, one at a time, until a player "capture it" or because the "activation time" has runned off.

when a flag has to be deactivated (captured or exhausted time) it sends a signal to the remote to allow it to activated another node (and score points in case of capture).

But, to secure the system, i had to use the "autoresponse" to validate the selected node, or to jump to another if not the case on the remote side, and that capture and scores have been aknowledged by the remote when sended by a node.

here is the code for the remote :

/*
  Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  version 2 as published by the Free Software Foundation.

  Update 2014 - TMRh20
*/

/**
   Simplest possible example of using RF24Network

   TRANSMITTER NODE
   Every 2 seconds, send a payload to the receiver node.
*/

#include <RF24Network.h>
#include <RF24Network_config.h>
#include <Sync.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio(9, 10);                   // nRF24L01(+) radio attached using Getting Started board

RF24Network network(radio);          // Network uses that radio

const uint16_t this_node = 00;        // Address of our node in Octal format
const uint16_t other_node1 = 01;
const uint16_t other_node3 = 03;      // Address of the other node in Octal format
const uint16_t other_node2 = 02;
const uint16_t other_node4 = 04;
boolean active = 0;
boolean ok=0;
int node = 0;

const unsigned long interval = 2000; //ms  // How often to send 'hello world to the other unit

unsigned long last_sent;             // When did we last send?
unsigned long packets_sent;          // How many have we sent already


struct payload_t {                  // Structure of our payload
  unsigned long ms;
  unsigned long counter;
};

void setup(void)
{
  Serial.begin(115200);
  Serial.println("RF24Network/examples/helloworld_tx/");

  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  randomSeed(analogRead(A0));

}

void loop() {

  network.update();                          // Check the network regularly


  unsigned long now = millis();              // If it's time to send a message, send it!
  if ( now - last_sent >= interval  )
  {
    last_sent = now;
    node = random(1, 5);
    Serial.println(node);
   
     if (node==1) {
        Serial.print("Sending to node 01...");
        active = 1;
        RF24NetworkHeader header1(/*to node*/ other_node1);
        ok = network.write(header1, &active, sizeof(active));
        if (ok) {
          Serial.println("ok node 1.");
          active = 0;
          ok=0;
        }
        else {
          Serial.println("failed.");}
     }
     else if (node==2) {
        Serial.print("Sending to node 02...");
        active = 1;
        RF24NetworkHeader header2(/*to node*/ other_node2);
        ok = network.write(header2, &active, sizeof(active));
        if (ok) {
          Serial.println("ok node 2.");
          active = 0;
          ok=0;
        }
        else {
          Serial.println("failed."); }
     }
     else if (node== 3) {
        Serial.print("Sending to node 03...");
        active = 1;
        RF24NetworkHeader header3(/*to node*/ other_node3);
        ok = network.write(header3, &active, sizeof(active));
        if (ok) {
          Serial.println("ok node 3.");
          active = 0;
          ok=0;
        }
        else {
          Serial.println("failed."); }
     }
      else if (node==4) {
        Serial.print("Sending to node 04...");
        active = 1;
        RF24NetworkHeader header4(/*to node*/ other_node4);
        ok = network.write(header4, &active, sizeof(active));
        if (ok) {
          Serial.println("ok node 4.");
          active = 0;
          ok=0;
        }
        else {
          Serial.println("failed."); }
      }
  }
}

and the code for a node :

/*
 Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 
 Update 2014 - TMRh20
 */

/**
 * Simplest possible example of using RF24Network,
 *
 * RECEIVER NODE
 * Listens for messages from the transmitter and prints them out.
 */

#include <RF24Network.h>
#include <RF24Network_config.h>
#include <Sync.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>


RF24 radio(9,10);                // nRF24L01(+) radio attached using Getting Started board 

RF24Network network(radio);      // Network uses that radio
const uint16_t this_node = 01;    // Address of our node in Octal format ( 04,031, etc) - others are 02,03,04
const uint16_t other_node = 00;   // Address of the other node in Octal format

boolean active = 0;
int ledB = 2;
struct payload_t {                 // Structure of our payload
  unsigned long ms;
  unsigned long counter;
};


void setup(void)
{
  Serial.begin(115200);
  Serial.println("RF24Network/examples/helloworld_rx/");
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  pinMode (ledB, LOW);
}

void loop(void){
  
  network.update();                  // Check the network regularly

  
  while ( network.available() ) {     // Is there anything ready for us?
    
    RF24NetworkHeader header1;        // If so, grab it and print it out
    //payload_t payload1;
    network.read(header1,&active,sizeof(active));
    if (active) {
    digitalWrite (ledB, HIGH);
    delay (1500);
    digitalWrite (ledB, LOW);
    }
//    Serial.print("Received packet #");
 //   Serial.print(payload1.counter);
//    Serial.print(" at ");
 //   Serial.println(payload1.ms);
  }
}

To reduce the confusion for other readers my advice was here - I just suggested an explanation in English

...R

Are you using the Network system because there is a long distance between nodes?

If all the nodes are within communication distance of a single Master then I reckon it would be simpler not to use the Network library and just get the Master to poll each node in turn, or else to listen for a message from any node.

Be aware that if two or more nodes transmit at the same time their output will be garbled. Polling avoids that.

...R
Simple nRF24L01+ Tutorial

Sorry for the late answer !

Well, by now, the system is supposed to deal with large areas (as paintball of airsoft fields can be....) that the first point, and the second point is that it may have to manage more than 5 nodes. That's why i choose the network library.

But due to my poor skills, i will think about my ambition...

goodgrief:
(as paintball of airsoft fields can be....)

I don't provide assistance with projects that involve real or toy weapons. There is far too much violence in this world.

...R

I respect that and i won't try to argue... thanks for the time you already give to me.