0

It's about the RF24 library you can find here. http://maniacbug.github.io/RF24/index.html

I transmit data from one Arduino to another using NRF24L01 radios. When I use the write-function on the transmitter arduino (joystick is an array) and after that I put in a delay higher then 10, the available function returns false.

Transmitter

radio.write( joystick, sizeof(joystick) );
delay(20);

Receiver

if(!available())
  print('No data'); // delay > 10 --> No data will be printed

Why is it working with a delay of 10 but not above? Has it something to do with timeouts which is mentioned in the docs of the library?: http://maniacbug.github.io/RF24/classRF24.html#a4cd4c198a47704db20b6b5cf0731cd58

Thank you for your answers.

  • Don't you check repeatedly to see if data becomes available later? Unless you use an interrupt from the radio to the processor, you will need to. – Chris Stratton Jan 21 '15 at 1:20
  • I check repeatedly in the sense of the standard loop. What I think is, that Arduino prints a huge amount of "No data" because of the delay. When delay is over, one single line is different, then again a huge amount of "No data" lines. I was scrolling the Serial Monitor, but this was not the case. Or maybe I scrolled not long enough? Would be interesting how many milliseconds a small loop needs to complete...But I think it's just better when I use: while(!radio.available()) {} so that only something happens when there is a payload. I will try this today. – mathnow Jan 21 '15 at 3:11
  • Yes, it's not usually useful to repeatedly log that data is not available, thiugh if you are really curious you could count the number of loops until data is obtained and print that with the data. – Chris Stratton Jan 21 '15 at 3:38
  • Nice, that's a great idea. Yes, I'm very curious about this. I will share the result after I tried. – mathnow Jan 21 '15 at 3:53
  • 2
    This is a snippet, isn't it? print('No data'); would not print "No data" because you are using the wrong quotes. It is difficult to answer such questions without the actual code being posted. – Nick Gammon Jul 8 '15 at 6:03
2

In my situation the issue was with the Transmitter not continuing to transmit after a delay. I was able to resolve the issue using the powerDown (http://maniacbug.github.io/RF24/classRF24.html#aa0a51923a09ba4f3478aba9be0f8a6a1) and powerUp (http://maniacbug.github.io/RF24/classRF24.html#a5cdaf47aa0edd6dca1b9a8bb7972a1a3) functions. Here is a snipet of my code. "radioTx" is the name assigned to my transmitter.

//standard code setup for arduino uno board examples
radioTx.begin();
radioTx.setChannel(108);
radioTx.openWritingPipe(pipe);

}

void loop() {

  int dist_cm = sonar.ping_cm();


  Serial.println(dist_cm);
  radioTx.write(&dist_cm,sizeof(dist_cm));
  radioTx.powerDown();
  delay(5000);
  radioTx.powerUp();

  }
0

Please read this: Arduino NRF24L01+ arduino to netmf transmit issue
Although you are not using NETMF, @PhilVallone uses the library and chip together successfully, points out the samples are not asynchronous, and addresses time-out. The OP for that question is using delay(1000) and no answer has been accepted.

  • I don't believe there is any use of interrupts or threading involved, making this mostly irrelevant. Do you have evidence otherwise? – Chris Stratton Feb 7 '15 at 19:48
  • Answers should have some relevance to the problem - random unrelated suggestions do not. – Chris Stratton Feb 7 '15 at 20:25
  • And what bootloader bugs do you think might be relevant? Do you realize how self contained the code in question is? This is not helpful, it's an uninformed grasping at straws. – Chris Stratton Feb 7 '15 at 21:21
  • Please take some time to actually read the code associated with the question... – Chris Stratton Feb 7 '15 at 21:35
  • With your feedback, I have backtracked and await the OP's reply. – Jon Feb 7 '15 at 22:07
0

Try updating your library to the new TMRh20 fork. That improves the old maniacbug's version a lot (possibly also fixing the bug). tmrh20.github.io/RF24

It's also worth noting that after you've read the message, it will print out "no data" until you receive new message.

-1

I had the same problem. My solution is:

First make .stopListening()

then .write(&data, sizeof(data))

and behind the write command an .startListening().

Now you can delay for longer times.

  • 1
    Welcome to Arduino SE! I'm having trouble understanding what you mean. The stopListening() command seems helpful, although can you explain how the .write(&data, sizeof(data)) would help? Thanks! – Anonymous Penguin Sep 29 '15 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.