NRF24L01 do not work with servos

Hello, I’m currently planning to make a RC plane. For this I use two Arduino nano with the NRF24L01 transmission modules (the version with the antenna).

I have as transmitter a home-made remote control with two joysticks, 4 buttons, 2 switches and 2 potentiometers (I only use the joysticks for the plane).

For reception on my plane I have a 2280Kv brushless motor, and 4 servos. The transmission works very well, I get the information on the receiver.

My problem is that as soon as I plug a servo on the receiver, I receive the information and writes on the servo but as soon as I touch the joystick transmitter to vary the angle of the servo, the arduino read the information and apply it and 2 seconds later he can not read the information he receives from the NRF ... I lost the connection.

Then 3-4 seconds after he can read it for 1 second and then he re-loses the reading data from the NRF and so on until I no longer touch the joystick and he gets to resume reading and write the data to the servo ...

Sometimes he completely loses the reading of the data and I have to reset the arduino.

I tried with my brushless motor, so I plugged into my ESC, it works fine without any interruption... After several hours of reflection and research, I can’t figure out where the problem is. You should know that servos work very well without the NRF24L01.

This is the transmitter code :

/*     Transmitter code     */

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

#define jB1 2  // Joystick button 1
#define jB2 3  // Joystick button 2
#define t1 4   // Toggle switch 1
#define t2 5   // Toggle switch 1
#define b1 6   // Button 1
#define b2 7   // Button 2

RF24 radio(9, 10);
const byte address[6] = "RC";

struct Data_Package {
  byte j1PotX;
  byte j1PotY;
  byte j1Button;
  byte j2PotX;
  byte j2PotY;
  byte j2Button;
  byte pot1;
  byte pot2;
  byte tSwitch1;
  byte tSwitch2;
  byte button1;
  byte button2;
};

Data_Package data;

void setup() {
  Serial.begin(9600);
  
  radio.begin();
  radio.openWritingPipe(address);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_LOW);
  
  pinMode(jB1, INPUT_PULLUP);
  pinMode(jB2, INPUT_PULLUP);
  pinMode(t1, INPUT_PULLUP);
  pinMode(t2, INPUT_PULLUP);
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  
  data.j1PotX = 90;
  data.j1PotY = 90;
  data.j2PotX = 90;
  data.j2PotY = 90;
  data.j1Button = 1;
  data.j2Button = 1;
  data.pot1 = 90;
  data.pot2 = 90;
  data.tSwitch1 = 1;
  data.tSwitch2 = 1;
  data.button1 = 1;
  data.button2 = 1;
}

void loop() {
  data.j1PotX = map(analogRead(A0), 0, 1023, 0, 180);
  data.j1PotY = map(analogRead(A1), 0, 1023, 0, 180);
  data.j2PotX = map(analogRead(A2), 0, 1023, 0, 180);
  data.j2PotY = map(analogRead(A3), 0, 1023, 0, 180);
  data.pot1 = map(analogRead(A4), 0, 1023, 0, 180);
  data.pot2 = map(analogRead(A5), 0, 1023, 0, 180);
  
  data.j1Button = digitalRead(jB1);
  data.j2Button = digitalRead(jB2);
  data.tSwitch2 = digitalRead(t2);
  data.button1 = digitalRead(b1);
  data.button2 = digitalRead(b2);

  Serial.print("j1PotX: ");
  Serial.print(data.j1PotX);
  Serial.print(";   j1PotY: ");
  Serial.print(data.j1PotY);
  Serial.print(";   j1Button: ");
  Serial.print(data.j1Button);
  Serial.print("    j2PotX: ");
  Serial.print(data.j2PotX);
  Serial.print(";   j2PotY: ");
  Serial.print(data.j2PotY);
  Serial.print(";   j2Button: ");
  Serial.print(data.j2Button);
  Serial.print(";   pot1: ");
  Serial.print(data.pot1);
  Serial.print(";   pot2: ");
  Serial.print(data.pot2);
  Serial.print(";   tSwitch1: ");
  Serial.print(data.tSwitch1);
  Serial.print(";   tSwitch2: ");
  Serial.print(data.tSwitch2);
  Serial.print(";   button1: ");
  Serial.print(data.button1);
  Serial.print(";   button2: ");
  Serial.println(data.button2);
  
  radio.write(&data, sizeof(Data_Package));
}

And the receiver code :

/*     Receiver code     */
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

RF24 radio(9, 10);
const byte address[6] = "RC";
Servo Moteur;
Servo Servo_ailes;
Servo Servo_gouvernail;
Servo Servo_ailes_arriere;

unsigned long lastReceiveTime = 0;
unsigned long currentTime = 0;

struct Data_Package {
  byte j1PotX;
  byte j1PotY;
  byte j1Button;
  byte j2PotX;
  byte j2PotY;
  byte j2Button;
  byte pot1;
  byte pot2;
  byte tSwitch1;
  byte tSwitch2;
  byte button1;
  byte button2;
};

Data_Package data;

void setup() {
  Serial.begin(9600);
  
  Moteur.attach(2);
  Servo_ailes.attach(3);
  Servo_gouvernail.attach(4);
  Servo_ailes_arriere.attach(5);
  
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_LOW);
  radio.startListening();
  resetData();
}

void loop() {
  if (radio.available()) {
    radio.read(&data, sizeof(Data_Package));
    lastReceiveTime = millis();
  }
  
  currentTime = millis();
  if ( currentTime - lastReceiveTime > 1000 ) {
    resetData();
  }
  
  Serial.print("j1PotX: ");
  Serial.print(data.j1PotX);
  Serial.print(";   j1PotY: ");
  Serial.print(data.j1PotY);
  Serial.print(";   j1Button: ");
  Serial.print(data.j1Button);
  Serial.print("    j2PotX: ");
  Serial.print(data.j2PotX);
  Serial.print(";   j2PotY: ");
  Serial.print(data.j2PotY);
  Serial.print(";   j2Button: ");
  Serial.print(data.j2Button);
  Serial.print(";   pot1: ");
  Serial.print(data.pot1);
  Serial.print(";   pot2: ");
  Serial.print(data.pot2);
  Serial.print(";   tSwitch1: ");
  Serial.print(data.tSwitch1);
  Serial.print(";   tSwitch2: ");
  Serial.print(data.tSwitch2);
  Serial.print(";   button1: ");
  Serial.print(data.button1);
  Serial.print(";   button2: ");
  Serial.println(data.button2);
  
  Moteur.write(data.j1PotY);
  Servo_ailes.write(data.j2PotX);
  Servo_gouvernail.write(data.j1PotX);
  Servo_ailes_arriere.write(data.j2PotY);
}

void resetData() {
  data.j1PotX = 90;
  data.j1PotY = 90;
  data.j2PotX = 90;
  data.j2PotY = 90;
  data.j1Button = 1;
  data.j2Button = 1;
  data.pot1 = 90;
  data.pot2 = 90;
  data.tSwitch1 = 1;
  data.tSwitch2 = 1;
  data.button1 = 1;
  data.button2 = 1;
}

Here some photos of my circuit:

Image 1

Image 2

I look to you to hopefully find the answer to my problem, thank you.

Huguizz:
My problem is that as soon as I plug a servo on the receiver, I receive the information and writes on the servo but as soon as I touch the joystick transmitter to vary the angle of the servo, the arduino read the information and apply it and 2 seconds later he can not read the information he receives from the NRF ... I lost the connection.

That sounds to me like a power supply problem - not enough power for the servos, the nano and the nRF24.

I don't have a nano myself but from other Threads it seems that a nano's 3.3v pin cannot supply enough 3.3v current for an nRF24

Make a simple pencil drawing showing how everything is connected and post a photo of the drawing. Also, please make your other images visible here. See this Simple Image Guide

...R
Simple nRF24L01+ Tutorial

Hi Robin, thanks for the help I really appreciate.

I think I found the solution, it’s just that I bought poor quality servos on a Chinese website.

During the construction of my plane, I broke 2 servos and not wanting to wait 3 weeks of delivery I went to buy the "same" at my local dealer. And as if by chance I tried on the servos I bought recently and they work...

Thank you for your help and I’m sorry for this rather useless post.