NRF24L01 multiple chat users

Hello is there a way i can add more users to the 2way chat Using the nrf24l01 up to as many to chat together if can get up to 6 users or more would be nice i have a sketch below but i honestly don’t know how to add more users can someone please help me out?

#include<SPI.h>
#include"nRf24L01.h"
#include"RF24.h"
#include"printf.h"
RF24 radio(9, 10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
bool go_to_tx_mode = false;
//bool go_to_rx_mode = false;
//bool go_to_serial_mode = true;
char input[32] = "";
void setup() {
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.enableDynamicPayloads();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1, pipes[0]);
  radio.startListening();
  radio.printDetails();
  // put your setup code here, to run once:
 
}
 
void loop() {
  if (go_to_tx_mode)
  {
    radio.stopListening();
    bool ok = radio.write(input, 32);
    if (ok)
    {
      //printf("written successfully !!!\n");
      printf("ME : %s\n", input);
      go_to_tx_mode = false;
      radio.startListening();
    }
    else
      printf("could not write....\n");
  }
  if (radio.available())
  {
    char payload[32] = "";
    bool done = false;
    while (!done)
    {
      done = radio.read( payload , 32 );
      printf("HIM : %s\n", payload);
 
      //delay(20);//see you did this when you checked the getting started example but it is NOT AT ALL required.why?because after being in rx mode it will go in serial mode and wait for our input so the other unit has sufficient time to go in tx mode !!
    }
 
  }
 
  //if(go_to_serial_mode)//having this makes the program extremely stable, just having an if block starting with serial.available is unstable.it will not take untimed serial inputs.
  //{
  if (Serial.available())
  { //try with local "input" variable too by passing a pointer to tx function.
    int len = Serial.readBytesUntil('\n', input, 31);
    input[len] = '\0';
    go_to_tx_mode = true;
    //go_to_serial_mode = false;
  }
  //}
 
}

Included in maniacbug's library is a sketch called starping. While waiting for a few more tranceivers to come in I've been trying to understand the code. Will that sketch work for you? Perhaps you may be able to use snippets of it. - Scotty

Hello right now the sketch i posted worked between 2 users trying to get at least maybe 5 or 6 users from what I’m understanding the nrf24l06 modules can only support up to 6 transceivers talking between each others.

Hello i still can't figure out how to add another user to it still stuck on 2 users can someone please help me out?

This is the exact same problem you reported for the LEDs sketch: you either use a transmitter identifier in the payload or you use a different address for each chatting station.

Whatever is going to be your choice all you need to do is to identify the message sender.

hello this is the led prject I finished project that works but this one i can talk to one on one back and forth but i try to add a new user by adding a new pipeline address and also adding

if (radio.available()) { char payload[32] = ""; bool done = false; while (!done) { done = radio.read( payload , 32 ); printf("HIM : %s\n", payload);

//delay(20);//see you did this when you checked the getting started example but it is NOT AT ALL required.why?because after being in rx mode it will go in serial mode and wait for our input so the other unit has sufficient time to go in tx mode !! } and change it from payload to payload2 and put her instead of him in it i get nothing comes up

I'm not sure I get you: please post your entire source code for all your sketches.... ALWAYS. If you prefer (I do) use Gist as it provides syntax highlighting. In both cases please add comments to explain what you are trying to achieve with different instruction blocks.

Anyway, when you put your radio into listen mode it is capable of receiving packets on all the registered pipes at the same time. Please note also that unless you are using one of the forks of maniacbug's library, by default the library puts the radio into power down after a write operation.... this means you have to power up the radio before each write.

Also it's not clear how do you populate payload2 and distinguish between the two senders.

The whole code is the only thing that I believe can answer to these questions without introducing more confusion.

hello i didn’t make the nrf24l01 chat sketch it’s from http://shantamraj.wordpress.com/2014/07/20/a-better-chat-program/ what I’m trying to do is add another user to the chat this is the old sketch below

#include<SPI.h>
#include"nRf24L01.h"
#include"RF24.h"
#include"printf.h"
RF24 radio(9, 10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
bool go_to_tx_mode = false;
char input[32] = "";
void setup() {
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1, pipes[0]);
  radio.startListening();
  radio.printDetails();
  // put your setup code here, to run once:
 
}
 
void loop() {
  if (go_to_tx_mode)
  {
    radio.stopListening();
    bool ok = radio.write(input, 32);
    if (ok)
    {
      printf("ME : %s\n", input);
      go_to_tx_mode = false;
      radio.startListening();
    }
    else
      printf("could not write....\n");
  }
  if (radio.available())
  {
    char payload[32] = "";
    bool done = false;
    while (!done)
    {
      done = radio.read( payload , 32 );
      printf("HIM : %s\n", payload);
    }
 
  }
  if (Serial.available())
  {
    int len = Serial.readBytesUntil('\n', input, 31);
    input[len] = '\0';
    go_to_tx_mode = true;
  }
 
}

new sketch i did was below

#include<SPI.h>
#include"nRf24L01.h"
#include"RF24.h"
#include"printf.h"
RF24 radio(9, 10);
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL , 0xF0F0F0F0D3LL };
bool go_to_tx_mode = false;
char input[32] = "";
void setup() {
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(2, pipes[0]);
  radio.startListening();
  radio.printDetails();
  // put your setup code here, to run once:
 
}
 
void loop() {
  if (go_to_tx_mode)
  {
    radio.stopListening();
    bool ok = radio.write(input, 32);
    if (ok)
    {
      printf("ME : %s\n", input);
      go_to_tx_mode = false;
      radio.startListening();
    }
    else
      printf("could not write....\n");
  }
  if (radio.available())
  {
    char payload[32] = "";
    bool done = false;
    while (!done)
    {
      done = radio.read( payload , 32 );
      printf("HIM : %s\n", payload);
    }
 
  }
  
    if (radio.available())
  {
    char payload2[32] = "";
    bool done = false;
    while (!done)
    {
      done = radio.read( payload2 , 32 );
      printf("Her : %s\n", payload2);
    }
 
  }
  
  if (Serial.available())
  {
    int len = Serial.readBytesUntil('\n', input, 31);
    input[len] = '\0';
    go_to_tx_mode = true;
  }
 
}

i check the compile it passed so i uploaded it and tried it and nothing first 2 users still work but that’s all.

not sure what I’m missing.

Ok, let's start:

  • you added a pipe in the array but you didn't add it to the listening addresses: to do so you need to 'open another reading pipe'
  • each time you call 'available' on your radio you are checking if there's a packet available on each and every reading pipe: calling it twice in a loop is not going to help
  • when within the 'available' if-statement you perform the while-statement loop, that is meant to discard all the messages but the last one you received and that is not your case anymore because you don't want to discard any message any more
  • you haven't provided any mean to distinguish between messages sent from HIM and those sent from HER: the arduino doesn't have any magic wand so it cannot know who is who and who sent the message

The sketch you posted might compile, but it's not adding a second receiver in no way.

Another hint to get you in the right direction: there is another 'available' function on the nRF24 library which takes an argument....

Enjoy!

How can i add a second reading pipe I'm not sure how to add it?

can someone please help me to add a new user to this chat?

Are you looking for directions in order to get out of a coding stall or are you looking for somebody who writes the code for you?

To add a second reading pipe you do what you did with the first one:

// YOU HAD THESE
radio.openWritingPipe(pipes[1]); // this opens a writing pipe on address pipe[1] AND the first reading pipe on the same address
radio.openReadingPipe(1, pipes[0]); // this opens the second reading pipe on address pipe[0]
// ADD THIS
radio.openReadingPipe(2, pipes[2]); // this opens the third reading pipe on address pipe[2]

This is how you open a reading pipe.... was it complex?

Now refer to my other hint there is another 'available' function on the nRF24 library which takes an argument....

If you don't try you'll never learn... If you want to learn you have to read and try.... If you are not willing to learn than you might want to hire somebody to code for you.

I'm trying thank you I'm learning i don't give up but coding is not one of the strong part I'm good at hardware making things :)

Ok, good, but now have a look at the library and try to understand what I meant with my suggestion and my other comments.

I know it's not easy, but I can assure you it's not difficult either, you just have to get used to "computer thinking", also known as "programming"

I'm looking at it using my notepad ++ editor.

rlogiacco i looked to see the library and what not but i can not get it to work i don' t know what I'm doing wrong or missing to add another user to the nrf24 module.

Which advancement/modification have you made to your code? Your reply doesn’t tell much…

Have you noticed there are 2 versions of the available function?
What do you believe is the use case for the one accepting an int as argument?
Can you describe each statement in your sketch code using a comment?

Please post your code along with answers to the previous…

Hello there are 2 sketches there because first one is the Original one second one was me trying to mod it and a tempting to add a third user not knowing what I'm doing.

josephchrzempiec: Hello there are 2 sketches there because first one is the Original one second one was me trying to mod it and a tempting to add a third user not knowing what I'm doing.

What "there" stands for? You need to share them, either with Gist or by posting here. Please add comments to each statement about what you believe it does.

just meaning that i have posted 2 sketches on the first page under Reply #7 the original and the one i try to add the the third user but couldn't. because i do not know enough about coding or the nrf24 modules to add a third user or so on.