Go Down

Topic: Send 3 variables with Nrf24L01 transceiver module? (Read 238 times) previous topic - next topic

00ramsey00

Hi, I have two arduino boards and two Nrf24L01 transceiver module connecting to each other. I am able to get them to send information back and forth to each other but only one piece of information at a time.

For example, I want to send variables X, Y, and Z from one arduino to another.
It works fine when I am only using one variable and sending one piece of information such as X.

But when i add more than one variable and one more than one radio.write function, the recieving end collects the data all weird

Am I supposed to open more reading pipes or something? Can someone please explain in detail.

Thank You


groundFungus

#1
Jan 14, 2018, 04:05 am Last Edit: Jan 14, 2018, 04:16 am by groundFungus
You can send a packet of 32 bytes with each write.  Put your 3 Variables into one packet.  If your variables are int data type it is pretty easy to build a comma delimited string packet using sprintf.  If they are floats, you can use dtostrf to make each float into a string and then use sprintf to build the packet.  Then send the packet.  At the other end use strtok to separate the variable back out and atoi or atof to covert the strings back to int or float.  See example #5 of this thread for an example of using strtok.

Go Up