3 nRF24L01s ?

I have a project idea that involves 3 nRF24L01 modules. I would need to use one as a receiver and have the other two send data to it simultaneously. I have the RF24-master library, but I don't know how to have the three modules communicate in that way. Any help is appreciated.

Thanks!

Check Multiple Nodes nRF24L01+ Wireless Temperature DS18B20 with Arduino UNO (2 Transmitter , 1 Receiver) | Elec-Cafe.Com

I would organize things so that one of the nRF4s acts as master and the others act as slaves. Then the master can poll each slave in turn. It is not exactly simultaneous but probably as near as makes no difference. If two nRF24s do actually transmit at the exact same time both messages will be garbage.

I got my nRF24s working with this Tutorial

I recommend using the TMRh20 version of the RF24 library - it solves some problems from the ManiacBug version

The pair of programs in this link may be useful and the master can easily be adapted to connect to several slaves.

...R

Thanks guys!

I'll check out the links you gave me

Hey J-M-L, what is I were to use different variables with one of the tx modules and the rx module? Like if I used this for one of the tx modules:

radio.write(&temperature, sizeof(temperature));

and tried to read it with the rx module like this:

radio.read(&temp1, sizeof(temp1));

I guess my question is do the variables that are sent have to be the same as the ones received, like sending data in a variable called “temperature” and receiving it in a variable called “temp1” between two different modules?

There is no need for the names of the variable to be the same. But the size and type of the variables must be the same. For example if you send an array of 2 ints you must store the received data into an array of 2 ints. But the arrays can have different names.

…R

Ok, thanks!

So is there a way for me to know which radio is sending the information. in my case, as a test I have the two transmitters with buttons on them. How to I get the receiver to tell me which button is being pressed and which button is not?

The receiver doesn't readily know. The transmitters have to provide their identity, or the pushbuttons will have to be named differently.

If each transmitter was on a different channel, and then the receiver listened first to one channel, and then to the other channel, then the receiver could differentiate by knowing which channel it was using to receive.

How can I specify to the receiver which channel I want it to read?

The RF24 library has a setChannel function that allows you to choose one of 128 channels.

One transmitter can transmit on one channel, the other transmitter can transmit on another channel. The receiver listens on one channel for a while, then the other channel for a while. When the receiver receives something, it knows what channel it was listening to and thus what transmitter sent it.

It is up to you to design the protocol and choose what "for a while" means so that this works.

The transmitters may have to repeat messages and the receiver may have to deal with partial and with repeated messages.

Thanks for the info

If it is possible, would it be better to have each transmitter send a 1 or a 2 in front of the data it sends and then have the receiver convert that data into a string and read the first character, and based on if it is a 1 or 2, it would convert the rest of the string back into an int or whatever it started out as and use the 1 or 2 to know which radio the data came from?

I'm asking this because, correct me if I'm wrong, the method you told me of sounds unreliable.

Are you sure you want to change the

nick13579:
How can I specify to the receiver which channel I want it to read?

Because this follows earlier questions about how to know which button was pressed I wonder if you really mean to change the channel. The channel specifies the exact frequency the wireless operates at and both sender and receivier MUST use the same channel.

In your case I would use the same channel for all the nRF24s - it makes life much easier.

Each nRF24 must be be given a different address so that messages can arrive at the correct place.

If I wanted to know which slave sent some data I would get one slave to include an 'A' in the message and the other slave to include a 'B'

However if you use the system in the programs I linked to in Reply #2 then there can be no amiguity because the master knows which slave it is talking to. The master sends a short message to the slave and the slave responds directly. Using the ackPayload facility the switch between sending and receiving (or receiving and sending) is completely automatic and invisible to your program.

...R

I followed Robin's advice when I set my radios up. The system works perfectly.

Hey Robin and TKall. Thanks for the replies. What exactly does ackPayload do and how did you use it?
I'm looking at the code now, but it is hard for me to follow what ackPayload does because I am not familiar with it.
Also, in your example, why did you not use a "&" in front of dataToSend in "rslt = radio.write( dataToSend, sizeof(dataToSend) );" In all of the other example I saw they used a "&"

I don't know if that is significant or not, but I'm just curious.

Thanks!

You load ackPayload with some data. Then when the device receives a message it automatically sends that data as part of the acknowledgment process.

Does that help?

I didn't need '&' because the data is in an array. When it is in a simple variable you need the '&'

...R

Ok thanks

Sorry for the late reply

That does help a lot, thanks!

I'll post again if I get it working or have any questions

I have a question on the code in the link you sent. For the slave code, what does opening a reading pipe on slave's own device ID do?
Maybe I have this wrong, but the code I'm looking at is:

const uint64_t deviceID = 0xE8E8F0F0E1LL; // Define the ID for this slave

and:

radio.openReadingPipe(1,deviceID);

I was just confused on this because I thought that if you wanted to read something from another radio, you open a reading pipe on THAT radio.

I may not understand your question. Let me know if the answer does not make sense.

An nRF24 hs to be told what its own address is so it can know what what messages are intended for it. If the master was sending messages to several slaves (each with a different address) all the slaves would get all the messages but they would ignore those with the wrong address.

The master and the slave must use the same address - just like your phone needs to know its phone number and the person calling you also needs to know the number. Of course changing the number for a phone is not a simple process - but it can be done.

By the way it is much easier to understand you if you give names to the devices rather than refer to them as this and that. Even names such as A and B are a big help

...R

Ok sorry if I worded that weird. I was just wondering why a slave radio used it's own device ID in a reading pipe. I thought a radio was supposed to use another radio's device ID to read.

For example, Radio A's device ID is 0xE8E8F0F0E1LL (A_ID) and radio B's device ID is 0xE8E8F0F0E2LL (B_ID). If radio A wants to read data from radio B, it needs to use radio.openReadingPipe(1, B_ID) and radio B would have to use radio.openWritingPipe(A_ID). Is that correct?