NRF24L01 Not working with Arduino nano

I have made one project that is two BO dc Motor (300rpm) and one servo controlled by remote (nrf24l01) with joy stick and buttons

I have used two push button this controlled motor 2 rotation i.e, clock and anticlockwise.
I have used joy stick ,X axis controlled Motor 1 rotation i.e, clock and anticlockwise.Y axis controlled servo
I have used L298N Motor driver for two motor.

I used the NRF24L01 with 3.5volt adaptor.

Two number External dc power supply (230AC-24VDC-5A) with Buck converter (3A) used for TX and RX circuit seperately.

Now coming to my problem.

If i have controlled the Motor2 by push button and servo controlled by joy stick (Yaxis), system working satisfactory.
But when i controlled the BO motor by the joy stick(Xaxis) ,the connection between the TX and RX is disconnected shortly after the operation.Than RX i has to be again to start work again.

My TX code is here

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

#define CE_PIN 9
#define CSN_PIN 10
#define yAxis A0     // A0 for Arduino UNO
#define xAxis A1    // A1 for Arduino UNO

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

/*-----( Declare Variables )-----*/
int joystick[6];  // 10 element array holding Joystick reading and 4 buttons
int HstUp    = 2;
int HstDwn = 3;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  pinMode(xAxis,INPUT);
  pinMode(yAxis,INPUT); 
  pinMode(HstUp,INPUT_PULLUP);
  pinMode(HstDwn,INPUT_PULLUP);
 delay(1000);
}

void loop() {
  radio.stopListening();
  radio.write( joystick, sizeof(joystick) );
  joystick[0] = analogRead(xAxis);
  joystick[1] = analogRead(yAxis);
  joystick[2] = digitalRead(HstUp);
  joystick[3] = digitalRead(HstDwn);
      Serial.print("X = ");
      Serial.print(analogRead(xAxis));
      Serial.print(" Y = ");  
      Serial.print(analogRead(yAxis));
      Serial.print(" Up = "); 
      Serial.print(digitalRead(HstUp));
      Serial.print(" Down = "); 
      Serial.print(digitalRead(HstDwn));
  }

My RX code is here

#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <Servo.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

int servoVal; // variable to read the value from the analog pin
Servo myservo1; // create servo1
const int servo1 = 6;
RF24 radio(CE_PIN, CSN_PIN);

int joystick[6];  // 8 element array holding Joystick readings Xangle and 7 button state
int joystickX;
int joystickY;
int Mtr1A = 2; // digital out put
int Mtr1B = 3; // digital out put
int Mtr2A = 4; // digital out put
int Mtr2B = 5; // digital out put

void setup() {
  myservo1.attach(servo1);
  Serial.begin(9600);
  pinMode(Mtr1A, OUTPUT);
  pinMode(Mtr1B, OUTPUT);
  pinMode(Mtr2A, OUTPUT);
  pinMode(Mtr2B, OUTPUT);// put your setup code here, to run once:
  pinMode(joystickX, OUTPUT);
  pinMode(joystickY, OUTPUT);
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();;
} //--(end setup )-

void loop() {
  // put your main code here, to run repeatedly:
  radio.startListening();
  if ( radio.available() )
  {

    radio.read( &joystick, sizeof(joystick));
    joystickX = map(joystick[0], 0, 1023, 179, 0);; // turn value of 0-1023
    joystickY = map(joystick[1], 0, 1023, 179, 0);
    int HstUp = joystick[2];
    int HstDwn = joystick[3];
    ////////////////Button oprtn////////////
    if (HstUp == HIGH) {
      digitalWrite(Mtr2A, LOW);
      digitalWrite(Mtr2B, HIGH);
      Serial.println ("UP");
    }
    else {
      digitalWrite(Mtr2A, HIGH);

    }
    if (HstDwn == HIGH) {
      digitalWrite(Mtr2A, HIGH);
      digitalWrite(Mtr2B, LOW);
      Serial.print ("DWN");
    }
    else {
      digitalWrite(Mtr2B, HIGH);
    }
    /////////////Joy Stick/////////////
    if (joystickX < 50)
    {
      //Serial.println (joystickX);
      digitalWrite(Mtr1A, LOW);
      digitalWrite(Mtr1B, HIGH);
      //digitalWrite(led3, HIGH);
      delay(50);
    }
    if (joystickX > 130)
    {

      digitalWrite(Mtr1A, HIGH);
      digitalWrite(Mtr1B, LOW);
      delay(50);
    }
    if (joystickX > 55 && joystickX < 125 )
    {
      digitalWrite(Mtr1A, HIGH);
      digitalWrite(Mtr1B, HIGH);

    }
    // Serial.println (joystickX);
    Serial.println (joystickY);
    servoVal = joystickY; // scale it to use it with the servo (result between 0 and 180)

    myservo1.write(servoVal);

  }
}

I don't know whether the problem in my code .Expecting valuable advice from the arduino Forum members.
Thank you

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

...R

Robin2:
Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

...R

sir
I have checked Simple TX starting Code its and i confirmed that my NRF24L01 communication is good

My serial monitor TX

SimpleTx Starting
Data Sent Message 0  Acknowledge received
Data Sent Message 1  Acknowledge received
Data Sent Message 2  Acknowledge received
Data Sent Message 3  Acknowledge received
Data Sent Message 4  Acknowledge received
Data Sent Message 5  Acknowledge received
Data Sent Message 6  Acknowledge received
Data Sent Message 7  Acknowledge received
Data Sent Message 8  Acknowledge received
Data Sent Message 9  Acknowledge received

My RX serial monitor shows

SimpleRx Starting
Data received Message 0
Data received Message 1
Data received Message 2
Data received Message 3
Data received Message 4
Data received Message 5
Data received Message 6
Data received Message 7
Data received Message 8
Data received Message 9
Data received Message 0
Data received Message 1
Data received Message 2

i confirmed I/P Volt 3.3 on NRF24L01 terminal

sreekanthmp:
I have checked Simple TX starting Code its and i confirmed that my NRF24L01 communication is good

Then you can be confident that whatever problem exists in your program it is not a wireless problem.

And in that case, if it was my project, I would create a version of the RX program without any wireless functions but with the values that would have come from the wireless hard coded and make sure it works properly. When it does I would add back the wireless functions.

...R

Robin2:
Then you can be confident that whatever problem exists in your program it is not a wireless problem.

And in that case, if it was my project, I would create a version of the RX program without any wireless functions but with the values that would have come from the wireless hard coded and make sure it works properly. When it does I would add back the wireless functions.

...R

I have made one program without wireless and its working satisfactory.
Here is my code

#include <Servo.h>
int servoVal; // variable to read the value from the analog pin
Servo myservo1; // create servo1
const int servo1 = 6;
#define yAxis A0    
#define xAxis A1
#define ENA_m1 8

int HstUp  = 10;
int HstDwn = 7;
int joystickX;
int joystickY;
int Mtr1A = 2; // digital out put
int Mtr1B = 3; // digital out put
int Mtr2A = 4; // digital out put
int Mtr2B = 5; // digital out put

void setup() {
  myservo1.attach(servo1);
  Serial.begin(9600);
  pinMode(Mtr1A, OUTPUT);
  pinMode(Mtr1B, OUTPUT);
  pinMode(Mtr2A, OUTPUT);
  pinMode(Mtr2B, OUTPUT);// put your setup code here, to run once:
  pinMode(joystickX, OUTPUT);
  pinMode(joystickY, OUTPUT);
  pinMode(ENA_m1, OUTPUT);
  pinMode(xAxis, INPUT);
  pinMode(yAxis, INPUT);
  pinMode(HstUp, INPUT_PULLUP);
  pinMode(HstDwn, INPUT_PULLUP);
} //--(end setup )-

void loop() {
  // put your main code here, to run repeatedly:



  joystickX = analogRead (xAxis) ;//, 0, 1023, 0, 179); // turn value of 0-1023
  joystickY = analogRead (yAxis);
  servoVal = map(yAxis, 0, 1023, 179, 0);
  myservo1.write(joystickY);

  if (digitalRead (HstUp) == HIGH) 
  {
    digitalWrite(Mtr2A, LOW);
    digitalWrite(Mtr2B, HIGH);
    Serial.println ("UP");
  }
  else 
  {
    digitalWrite(Mtr2A, HIGH);

  }
  if (digitalRead (HstDwn) == HIGH)
  {
    digitalWrite(Mtr2A, HIGH);
    digitalWrite(Mtr2B, LOW);
    Serial.print ("DWN");
  }
  else 
  {
    digitalWrite(Mtr2B, HIGH);
  }
  
  /////////////Joy Stick/////////////

  if ((joystickX) < 470)//&&flag==true)
  {
    //Serial.println (joystickX);
    digitalWrite(Mtr1A, LOW);
    digitalWrite(Mtr1B, HIGH);
    //digitalWrite(led3, HIGH);
    Serial.print ("fwd");
    Serial.println (joystickX);
  }
  else if ((joystickX) > 600)
  {

    digitalWrite(Mtr1A, HIGH);
    digitalWrite(Mtr1B, LOW);
    Serial.print ("rvs");
    Serial.println (joystickX);
  }

  else
  {
    digitalWrite(Mtr1A, HIGH);
    digitalWrite(Mtr1B, HIGH);
    Serial.print ("stop");
    Serial.println (joystickX);

  }

}

i can't understand, why its not working with NRF24L01

sreekanthmp:
i can't understand, why its not working with NRF24L01

Have you got a separate working pair of wireless programs that simply send (and receive) the data that the motor program needs?

Because the wireless part of a project is the most difficult to debug I always start with the wireless part and then add the other code in small steps checking that it still works after every addition.

...R

Robin2:
Have you got a separate working pair of wireless programs that simply send (and receive) the data that the motor program needs?

Because the wireless part of a project is the most difficult to debug I always start with the wireless part and then add the other code in small steps checking that it still works after every addition.

...R

How wonder this.!!!!!! :fearful: :fearful:
Now i have used Arduino UNO as a RX in place of Nano.I added the code one by one,I have to say it was a miracle , now all wireless operation functioning successfully .. :smiley: .