nrfl24l01 chip missing packets of data (FIXED)

I am using two nrf24I01 chips to connect a brush motor driver setup (using a L293D integrated circuit to power two motors). To test them, I am having one send “Hello World” messages to the motor one to test connectivity, and, frustratingly, it is only printing “Hello World” to the serial monitor every so often. Every ten seconds, maybe, with the other arduino sending messages at 1Hz. I suspect it is because my code is long enough to make it “miss” the packet because it was busy telling the motors how fast to go and such with analogWrite() and other housekeeping type stuff. But how are you supposed to make Arduinos do interesting things if they can’t handle multiple tasks in series? Shouldn’t there be a small queue in the nrf chip itself, which is what it queries when I call if(radio.available())? Anyhow, the code is below. Is there a better way to do this?

EDIT2: Fixed it. It changed out the maniacbug library with the TMRh20 one using the library manager in the IDE. Before I installed it I had to delete the library using this guide:

The first two answers are good, I looked at the second.

Receiver/motor driver:

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

RF24 radio(9, 10);//housekeeping

const byte rxAddr[6] = "00001";//housekeeping

// rear motor variables
int enablePin = 11;
int in1Pin = 8;
int in2Pin = 7;
boolean forward = true;

//front motor variables
int enablePin2 = 2;
int in3Pin = 32;
int in4Pin = 34;

//test variables
boolean go = true;

void setup() {
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);

  pinMode(in3Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(enablePin2, OUTPUT);
  while (!Serial);
  Serial.println("Serial on");
  radio.openReadingPipe(0, rxAddr);
  Serial.println("Radio on");
  Serial.println("Radio Listening");

void loop() {
  char text[32] = {0};, sizeof(text));
    setSpeed2(200);//like setSpeed for second motor
    setDirection2(forward);//like setDirection for second motor
    forward = !forward;//change the direction!

    forward = !forward;

void setSpeed(int speed) {
  if(speed >= 0 && speed < 256){
    analogWrite(enablePin, speed);

void setDirection(boolean clockwise){
  digitalWrite(in1Pin, ! clockwise);
  digitalWrite(in2Pin, clockwise); 

transmitter code:

 * Author: Dan Pollak
 * MEGA2560 because it is more portable. Probably.

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

RF24 radio(7, 8);

const byte rxAddr[6] = "00001";

void setup()
  radio.setRetries(15, 15);
  radio.stopListening();//because it is a transmitter, not a receiver
//FOR MEGA2560
void loop()
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));


Please do not cross-post. Other thread removed.

You need also to post the code for the transmitter - the problem may be there.

I suggest you use the TMRh20 version of the RF24 library - it solves some problems from the ManiacBug version


Yeah you bet- it’s up. When I go into my library manager there is an option for an nrf24 library (not sure which is maniacbug and which is TMRh20) and its imports are different, they look like:

#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

And are the imports I have right now:

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

Which is for which? Also, any idea if the code will work as-is for TMRh20’s library?

Unfortunately TMRh20 used the same name for his version of the library as did ManiacBug. I reckon you have two options. Delete whatever you have and download and install the TMRh20 library anew. OR, download the TMRh20 library and install it with a different name - but that is a bit more complex.

The API for the TMRh20 library is nearly identical to the ManiacBug version. The only difference I have noticed is that the read() function does not return a value.