Connecting 5+ NRF24 to multiple Arduino's

akatchi:
Yes this is exactly what I mean! It will be reading an address, so my question is how do I get it reading all the slaves? Can it read all the slaves at the same time? Or only 1 slave by 1 slave?

If it can read multiple at the same time, how do I code that in my setup?

And else if it read 1 slave by 1 slave, do I have to call 'openReadingPipe' each time on every slave?

When you say "do I have to call 'openReadingPipe' each time on every slave" are you asking if the code in the slave will need to open a reading pipe?

However I suspect you are referring to the code in the master? If so, you still seem to have the whole concept back to front.

Please do like I suggested in Reply #18 and "write down as a series of steps (one on each line) the sequence of messages that you want to happen". Then we will (hopefully) have a common understanding which will make it easier to explain how to go about it.

...R

Robin2:
Please do like I suggested in Reply #18 and "write down as a series of steps (one on each line) the sequence of messages that you want to happen". Then we will (hopefully) have a common understanding which will make it easier to explain how to go about it.

Ok sorry,

  • The master has to receive the messages from the slaves
  • How do I code the master so it reads out all the messages from all the slaves?
  • Using the openReadingPipe (in the setup)?

From what I know now:

  • In order to WRITE to all the slaves, I just have to call the function 'openWritingPipe(slaveAdress[y])' each time.

  • So the writing will be 1 by 1, which is good, because the message is supposed for only 1 slave.

  • But how do I code it so the master reads all the slaves? I know how to code it for 1 slave, just 'openReadingPipe(1, Adress[y])'. But how do I do it for multiple?

Is this better?

What I want you to write out is something like this

slave 1 sends "abc" to master
master sends "abc" to slave 3
master sends "abc" to slave 4
slave 2 sends "qwe" to master
master send "qwe" to ....

etc etc

until you have a described a complete sequence.

For the moment never mind how the Arduino might implement it. Just describe the requirement.

...R

Robin2:
What I want you to write out is something like this

slave 1 sends "abc" to master

master sends "abc" to slave 3
master sends "abc" to slave 4
slave 2 sends "qwe" to master
master send "qwe" to ....

etc etc




until you have a described a complete sequence.

For the moment never mind how the Arduino might implement it. Just describe the requirement.

Oh that way oh okey.

master is listening on all 5 slaves
slave 1 sends '1to3' to master
master goes into write mode
master sends '1unlocked' to slave 3
master goes into listening mode and waits for new messages

Look at my 3rd example. Now change the names of the roles so what I call the slave becomes the master and what I call the master becomes the slave. Then you have the system you need. To avoid confusion change references in both programs from slave to master and vice versa.

The only extra thing you need is to add a list of writing addresses so you have one for each "slave". In my slave code the relevant address is the masterAddress but you will be changing that to slaveAddress and, as I say, you will need one for each slave.

Then when a message arrives (for example "1to3" you can check the first character to figure out which slave sent the message and check the last character to figure out where to send it.

Get the system working with a single slave to start with and post the pair of programs - with all the slave and master references swapped.

By the way, I still reckon my ackPayload system will make YOUR life much easier because my 3rd example makes no attempt to deal with data collisions.

...R

I see here very interesting interchanging messages, and Robin2 has a lot of patience to explain in different ways for everybody to understand, that great and nice community, we can do lot of things in this way. Could you please also help me to understand and to make my little project to work?

After long time of tries and reading I want to find the solution for my master to read 2 or more slaves at the same time.
From Robin2 explanation I wonder is it possible the master to send message to the slave1 and the slave1 to wait prepared with my variable and to response to the master from the first message through acknowledge with my variable?

Another question, if it is so hard for this extraordinary nrf24, which can use 125 channels and 6 pipes per channel, to receive 2 messages at the same time, for what was intended? Another question here, why not using one slave per one channel and the master change the channel to get message from each slave?

So what is the best way to receive 2 messages from 2 slaves periodically in 2 different structs? Not just the way, but the code little bit explained. This subject is very important for everybody, but nowhere I can find a good example.

thank you,

antonio1:
After long time of tries and reading I want to find the solution for my master to read 2 or more slaves at the same time.
From Robin2 explanation I wonder is it possible the master to send message to the slave1 and the slave1 to wait prepared with my variable and to response to the master from the first message through acknowledge with my variable?

Another question, if it is so hard for this extraordinary nrf24, which can use 125 channels and 6 pipes per channel, to receive 2 messages at the same time, for what was intended? Another question here, why not using one slave per one channel and the master change the channel to get message from each slave?

So what is the best way to receive 2 messages from 2 slaves periodically in 2 different structs? Not just the way, but the code little bit explained. This subject is very important for everybody, but nowhere I can find a good example.

thank you,

I find this confusing. I have highlighted a few parts in different colours that seem to contradict each other or represent different streams of thought.

An nRF24 module has a single wireless transceiver so it can only send or receive one message at any one time. However most messages only take a few millisecs so many messages can be sent (or received) within one second.

One way to receive messages from 2 slaves periodically is for the master to send a message to each slave in turn and the slave will send the data back to the master in the acknowledgement - that is the basis for my second example. For this to work the slave must put the data into the acknowledge buffer before the master makes contact.

If that is not suitable you will need to give full details of the project you want to implement.

...R

Robin2:
An nRF24 module has a single wireless transceiver so it can only send or receive one message at any one time. However most messages only take a few millisecs so many messages can be sent (or received) within one second.

It is true that I put many questions, many thought and maybe I was not so clear, this is because I work for more than one month to make these devices to communicate each others and internet it's full of discussion about theory or with the simple example one communication in one way.
Let's clarify, my question here was for what is intended so many channels if the solution in communication is not to use a channel for each slave and master to interchange? Why I have 6 pipes per channel if at a time just one can receive a message?

Robin2:
One way to receive messages from 2 slaves periodically is for the master to send a message to each slave in turn and the slave will send the data back to the master in the acknowledgement - that is the basis for my second example. For this to work the slave must put the data into the acknowledge buffer before the master makes contact.

If that is not suitable you will need to give full details of the project you want to implement.

...R

I will reflect and test your example 2 and I'll come back with results. But for this you didn't answer to me, coming back to your example with postman. I remind you that master in my case collect data from 2 or more slaves. Is it possible master to ask acknowledge from slave one time and the acknowledge to be prepared with my variable to response at the first sign? Or should I have to ask twice as you mentioned for having the variable received in master?
Let's be fear, receiving messages through acknowledge is tips and tricks but not normal use of this tranceiver, I would like to use send/receive instead of acknowledge.

thank you,

antonio1:
Let's clarify, my question here was for what is intended so many channels if the solution in communication is not to use a channel for each slave and master to interchange? Why I have 6 pipes per channel if at a time just one can receive a message?

The channel denotes the frequency in the 2.4GHz band that the wireless works on. Both the transmitter and receiver must use the same channel. Many things use the 2.4GHz band (such as Bluetooth, WiFi and microwave ovens) and if you find that interference is causing problems you can change to a different channel.

The pipes are for sorting messages after they have been received. Think of pipes as 6 shelves onto which the mail for different residents in an apartment block can be placed. All the letters come through the same mail slot (the radio receiver listening on Channel N) and when they fall on the floor someone picks them up, looks at the name of the recipient (the address the message was sent to) and puts them on the correct shelf (the pipe that has been assigned the same address as the message) or shreds them if they are for a recipient who lives in another block (i.e. if they are for an address that is not assigned to any of the pipes on this nRF24)

To be honest I have never found a use for multiple pipes. I include an identifier within my messages so that the receiver can tell where the message came from.

Is it possible master to ask acknowledge from slave one time and the acknowledge to be prepared with my variable to response at the first sign? Or should I have to ask twice as you mentioned for having the variable received in master?

I find that confusing.

Rather than trying to figure out how the nRF24 works, please tell us in non-technical terms what you would like to happen. Start by telling us what you are trying to create - I presume it is not a big secret?

If I know what you want to happen it will be much easier to give suitable advice.

...R

Big secret it's not of course, but I try to understand very well before implementing to have this wifi nRF24 communication optimized.

I have a master, which get data temp and humidity from 2-3 slaves. There is another slave more which get the order from the master after computing, but this last slave also have to send back to master the status of the unit which should be controlled.

I choose the master to communicate fast with no delay in loop, but slaves should send data from time to time with intervals about 3 minutes.

It is not a big deal but using nRF24 became a big deal. I have lot of limits here and I always optimize resources, here I want to optimize even radio tries and so on.
Why I can't do this without acknowledge message which is not intended for tips and trick. How we can solve this with send/receive?

@antonio1, it's obvious you don't have any idea how to implement this system the way you THINK it should work. At this point, any rational person would take @Robin2's advice and try the Poll / Auto-ACK technique that he suggested at the beginning. It will probably work for your application if you implement it correctly. IMO, you're expending far too much effort solving a problem you probably don't even have.

gfvalvo:
@antonio1, it's obvious you don't have any idea how to implement this system the way you THINK it should work. At this point, any rational person would take @Robin2's advice and try the Poll / Auto-ACK technique that he suggested at the beginning. It will probably work for your application if you implement it correctly. IMO, you're expending far too much effort solving a problem you probably don't even have.

I really know what I want to do, and my request is a normal request, acknowledge function was not implemented for this use. For me the things does not just work, it is important how they work.
I said I'll try Robin example today, but even if it works I have to implement the method with send receive playing with time moment, then I decide which is the best.

By the way, could you please tell me where at which reply the Robin example2 works? Could you please Robin give me the link for RX/TX code to try which works by using acknowledge? I'm ready to test before adapting to my software.

By the way, after test it seems that the master TX never get true for sending:
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
this could be the cause of acknowledge alteration, the aim for what was intended, fails. Maybe I'm wrong, let see first your example working, please tell me why I have fail for sending expression even if at the receiver side I have the message received?

Thank you anyway for any advice or help.

antonio1:
By the way, could you please tell me where at which reply the Robin example2 works? Could you please Robin give me the link for RX/TX code to try which works by using acknowledge? I'm ready to test before adapting to my software.

That is the second example in this Simple nRF24L01+ Tutorial

I have been assuming all along that you have been studying that tutorial since you have been using my name prolifically.

From Reply #14 ...

I choose the master to communicate fast with no delay in loop,

That is a silly approach. It just clogs up the system for no benefit whatever and abuses the airwaves to the detriment of anyone else that may wish to use a 2.4GHz device near you.

If the slaves just need to report their data once every 3 minutes then just call the slaves once every 3 minutes - put the master in charge of timing.

There is another slave more which get the order from the master after computing, but this last slave also have to send back to master the status of the unit which should be controlled.

I can't figure how to respond to that. Can you explain more clearly what you want to happen and how often it must happen.

...R

Robin, about my project, I can't put the master in charge of timing as soon as more than 2 slaves send messages to the master without being synchronized. This is why the master work in loop with no delay, as fast as possible to collect messages from those slaves. I could do here all slaves to work in fast loop and the master to call at every 3 minutes, but for this more than one devices communicate through radio and the optimisation is not the one desired.

But please before going deeply discuss about my project let's make your example2 to work, because it is not working, for this please response to my previous mail. I will change anything you consider it must and let's see the example2 working.

At your example #2 there is "ackPayload example". The TX and RX codes from there are not working. Response from TX as I already said is always "Tx failed" even if the message is sent. So I have no acknowledge message as response. Did you test it?

thank you,

antonio1:
But please before going deeply discuss about my project let's make your example2 to work, because it is not working, for this please response to my previous mail. I will change anything you consider it must and let's see the example2 working.

Have you got my first (simplest) example to work? If not, start with that.

If my first example works then please post the code for my second example that YOU have uploaded to your two Arduinos - being sure to tell us what type of Arduino has each program.

My examples do work, and they have been tried by several other Forum members.

...R

Robin2:
Have you got my first (simplest) example to work? If not, start with that.

If my first example works then please post the code for my second example that YOU have uploaded to your two Arduinos - being sure to tell us what type of Arduino has each program.

My examples do work, and they have been tried by several other Forum members.

...R

Ok, very well, I loaded the first example. I have two arduino uno with two nRF24. After running I see that the transmitter send the message "Message 0" but with TX failed, which means no acknowledge received. The receiver receive the message and display the message.
I also observe that no line in TX code enable the acknowledge payload, this is what it's intended to see? No acknowledge received in TX?

I think that compiler generate problems, sometimes has strange results. I stopped the PC and after a while I started again, and checking again to see what's wrong with the software devices. Right now without doing anything i have the Message in TX "Data sent Message x Acknowledge received" where x is incrementing and in RX I have "Data received Message x" where x is incrementing.

so it seems that it works this time, compiler generate error info sometimes I have no idea why. I'm using now 1.8.9 version.

The normal behaviour of the nRF24 is to acknowledge every message but that does not include an ackPayload.

Have you tried the connection test program in my Tutorial to make sure the Arduinos can talk to the nRF24 they are attached to?

If that shows that the connection is good the next most likely cause of a problem is an inadequate 3.3v power supply. If in doubt power the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

DO NOT make any changes to the programs until you can see the communication working properly.

EDIT, to add, following Reply #36 ...

Good to see it's working. Another thing to be aware of is that the nRF24 does not reset when the Arduino resets. The only way to reset the nRF24 is to disconnect and reconnect the power.

Now try the second example in my Tutorial.

...R

Robin2:
Have you tried the connection test program in my Tutorial to make sure the Arduinos can talk to the nRF24 they are attached to?

No I didn't do it yet, but I read about it, I'll do if it's necessary.

EDIT, to add, following Reply #NN ...

what do you mean with this?

Good to see it's working. Another thing to be aware of is that the nRF24 does not reset when the Arduino resets. The only way to reset the nRF24 is to disconnect and reconnect the power.

Now try the second example in my Tutorial.

...R

I use as power supply USB from desktop I don't think the problem is power supply, sometimes the compiler give me error at loading and after restart compiler, the loading works well without any modification.

Sorry edit again, it is working, I see acknowledge received. At this point let me to adapt to my project and I'll contact you if necessary.

One question, is it possible to power off nRF24 and wakeup at every 3 minutes to send the message?

Thank you,

antonio1:
.what do you mean with this?

The #NN should have been #36. I have corrected it now. When you are modifying a message you can't see the Reply numbers.

One question, is it possible to power off nRF24 and wakeup at every 3 minutes to send the message?

The nRF24 has a very low power mode. I have never needed it myself. Read about it in the Nordic nRF24L01+ datasheet and study the TMRh20 library documentation.

...R