Two NRF24L01 Transmitters sending data to one NRF24L01 Receiver

Hello

I have two transmitter one with tilt sensor and another transmitter with piezo sensor. i want to send data from two transmitter to one receiver.

if tilt sensor is activated it should send data to receiver, some for piezo.

How this can be done.

does any one code for transmitter and receiver.

pin connections will be same for both transmitter.

My idea was to write two types of address in receiver side like const byte address[6] = "00001"; and const byte address[6] = "00002"; and to write one address in one sender const byte address[6] = "00001"; and another address in another sender const byte address[6] = "00002"; will this concept works? please correct me if i am wrong.

How this can be done.

Quite easily. What is the problem?

does any one code for transmitter and receiver.

Several libraries for those radios, each with examples.

will this concept works?

Yes. Although that is not necessarily the simplest way. If you, as the receiver, receive "T:25" or "P:18", could you reasonably guess which device sent which message?

Hello

I went through many examples but i didn't understand the code for multi transmitter data to one receiver if you have code example or video links can you please share with me.

Question is do i need to upload same code for both transmitter? if there are any changes what changes and where i should make.

Question is do i need to upload same code for both transmitter?

If one is reading a piezo sensor, and one is reading a tilt sensor, it seems highly unlikely that you would run the same code on each one.

i didn't understand the code for multi transmitter data to one receiver

Post the code, and tell us what you don't understand.

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

It includes an example for a master and 2 slaves that should be able to do what you want.

...R

Here is sender code for one device

#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
//RF24 library link GitHub - maniacbug/RF24: Arduino driver for nRF24L01
//Pin Assingmenet http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin for the arduino you’re using. this pin number is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;
int buttonPin1 = 7;

int buttonState1 = 0;

void setup(void)
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
pinMode(buttonPin1, INPUT);

}

void loop(void)
{
buttonState1 = digitalRead(buttonPin1);

if (buttonState1 == HIGH)
{
msg[0] = 111;
radio.write(msg, 1);

}
}

receiver code

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

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin number for the arduino you’re using. this pin is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;
int led1 = 7;

void setup(void)
{
pinMode(7, OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
pinMode(led1, OUTPUT);

}

void loop(void)
{
if(radio.available()){
bool done = false;
while (!done) {
“done = radio.read(msg, 1)”;
Serial.println(msg[0]);
if (msg[0] == 111) {
//delay(10);
digitalWrite(led1, HIGH);

}else {
digitalWrite(led1, LOW);

}
}
}
}

now this code is for one transmitter and one receiver. can you please tell me what changes i should make if i want to send same data with another transmitter.

what changes i should make in receiver side and another sender side.
can you please explain me in detail.
Thank you

That code is pretty useless.

     "done = radio.read(msg, 1)";

The WTF light exploded.

please tell me what corrections i should make.

Does that code work? The code in Robin2's tutorial does. It would be worth your time to read his tutorial.

It would also be worth your time to read the how to use this forum sticky to see how to post code properly among other useful hints on how to get the most from the forum.

groundFungus: Does that code work? The code in Robin2's tutorial does. It would be worth your time to read his tutorial.

No code is not working, that is why i am asking someone to help

Which Arduino board are you using?

The problem could be your code or your wiring or your hardware. If you try Robin2's code we eliminate that part because we know that his code works. If you upload the SimpleRX and SimpleTX code and you do not get communication we can examine the other avenues.

After you upload the code, power the Arduino boards down (unplug the USB or whatever power source) wait a few seconds and power them back up to reset the radios. Just resetting the Arduinos will not reset the radios.

I am using arduino Uno

in the receiver code i am getting error

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

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin number for the arduino you're using. this pin is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;
int led1 = 7;



void setup(void)
{
 pinMode(7, OUTPUT);
 Serial.begin(9600);
 radio.begin();
 radio.openReadingPipe(1, pipe);
 radio.startListening();
 pinMode(led1, OUTPUT);

}

void loop(void)
{
 if(radio.available()){
   bool done = false;
   while (!done) {
     done = radio.read(msg, 1);
     Serial.println(msg[0]);
     if (msg[0] == 111) {
     //delay(10);
     digitalWrite(led1, HIGH);
     
     }else {   
     digitalWrite(led1, LOW);
     
     }
   }
 }
}

ERROR MESSAGE

sketch_dec03a:32:11: error: void value not ignored as it ought to be

done = radio.read(msg, 1);

^

exit status 1
void value not ignored as it ought to be

You are not using Robin2's code, as advised. Why is that?

There are several versions of the library for those radios. Some versions have read() return a boolean value. Others do not. Use the example code for your version of the library, not from some other version.

@Pauls

Thank you.

This code is working fine now.

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

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin number for the arduino you're using. this pin is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;
int led1 = 7;



void setup(void)
{
 pinMode(7, OUTPUT);
 Serial.begin(9600);
 radio.begin();
 radio.openReadingPipe(1, pipe);
 radio.startListening();
 pinMode(led1, OUTPUT);

}

void loop(void)
{
 if(radio.available()){
   bool done = false;
   while (!done) {
     done = radio.read(msg, 1);
     Serial.println(msg[0]);
     if (msg[0] == 111) {
     //delay(10);
     digitalWrite(led1, HIGH);
     
     }else {   
     digitalWrite(led1, LOW);
     
     }
   }
 }
}

now the question is if i want to do the same using another transmitter what changes i should make on receiver side and another transmitter side?

what changes i should make on receiver side

First, you change the sender(s). You could make the other one send 222, instead of 111.

Of course, sending 111 or 222 is a silly waste of time. Make them send something USEFUL.

bmg1234: No code is not working, that is why i am asking someone to help

I gave you a lot of help in Reply #4, but, of course, you are perfectly entitled to ignore it.

...R

PaulS:
First, you change the sender(s). You could make the other one send 222, instead of 111.

For both the sender do i need to send 222? receiver side any changes in the address?

if i write same address will both sender sends data to same receiver?

For both the sender do i need to send 222?

Hi, I'm Darryl, and this is my brother Darryl.

If you change both devices to send 222, how the (expletive deleted) do you intend to know which device sent the value?

if i write same address will both sender sends data to same receiver?

Try it, and see for yourself, since you are not following any advice you've gotten so far.