Can't get a connection between nrf24l01 modules

Hi, I am very new to forum so excuse me if I don't give enough information and / or give it on the wrong way. I am working on a hobby project which is trying to make a remote control car using the nrf24l01 modules.

When I first attempted to start this project I was experimenting with the modules and couldn't get them to work for a while. Finally I discovered a faulty wire and got them to work, which led me to progress with the creation of the car its self.

I have worked on the car significantly and during testing the connection between the car and remote suddenly stopped working. For an hour or so I could get them to work by fiddling around with the wires but I have now hit a point where I can't get them to work ever.

I have been looking through the countless forms about this module and applying the solutions what worked for other people, but I can't seam to get it to work again.

One thing that I noticed that may are may not have an effect is that the 3.3v power supply pin on the Arduino uno (which is what I am using for the car and controller) is putting out close to 4 volts. I am not sure whether or not that would have an effect on the overall connection.

Below is the code for the remote (transmitting end):

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

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1;

int joystickX;
int joystickY;

const int rSWpin = 2;
const int rXpin = 0;
const int rYpin = 1;

const int lSWpin = 4;
const int lXpin = 2;
const int lYpin = 3;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setAutoAck(true);
  radio.setRetries(0, 15);
  radio.openWritingPipe(address);
  radio.stopListening();

  pinMode(rSWpin, INPUT);
  digitalWrite(rSWpin, HIGH);

  pinMode(lSWpin, INPUT);
  digitalWrite(lSWpin, HIGH);
}

void loop() {
  joystickX = analogRead(rXpin);
  joystickY = analogRead(lYpin);

  currentMillis = millis();
  if(currentMillis - prevMillis >= txIntervalMillis)
  {
    send();
    prevMillis = millis;
  }

  if(!radio.write(&joystickX,sizeof(joystickX)))
  {
    Serial.println(F("communication failed."));
  }
}

void send()
{
  radio.write(&joystickX, sizeof(joystickX));
  radio.write(&joystickY, sizeof(joystickY));

  Serial.print("Joystick X: ");
  Serial.println(joystickX);

  Serial.print("Joystick Y: ");
  Serial.println(joystickY);
}

And here is the code for the car (receiving end):

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

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

int joystickX = 0;
int joystickY = 0;

const int forwardPin = 2;
const int backwardPin = 4;

const int lSpeedOut = 5;
const int rSpeedOut = 3;

int lSpeed;
int lSpeedF;
int rSpeed;
int rSpeedF;

float lrOffset;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openReadingPipe(1, address);
  radio.startListening();

  pinMode(forwardPin, OUTPUT);
  pinMode(lSpeedOut, OUTPUT);
  pinMode(rSpeedOut, OUTPUT);
  pinMode(backwardPin, OUTPUT);
}

void loop()
{
  if (radio.available())
  {
    radio.read(&joystickX, sizeof(joystickX));
    radio.read(&joystickY, sizeof(joystickY));

    /*Serial.print("Joystick X: ");
  Serial.println(joystickX);

  Serial.print("Joystick Y: ");
  Serial.println(joystickY);*/

  if(joystickY < 511)
  {
    MoveBackward();
  }
  else if(joystickY == 511)
  {
    DontMove();
  }
  else if(joystickY > 511)
  {
    MoveForward();
  }

  if(joystickX < 511)
  {
    lrOffset = joystickX / 511.5;
    
    lSpeedF = lSpeed * lrOffset;
    rSpeedF = rSpeed;
  }
  else if(joystickX == 511)
  {
    lrOffset = 1;
    
    lSpeedF = lSpeed;
    rSpeedF = rSpeed;
  }
  else if(joystickX > 511)
  {
    lrOffset = 1 - (joystickX / 511.5) + 1;
    
    lSpeedF = lSpeed;
    rSpeedF = rSpeed * lrOffset;
  }

  Serial.print("LR Offest: ");
  Serial.println(lrOffset);

  lSpeed = map(joystickY, 0, 1023, -255, 255);
  rSpeed = map(joystickY, 0, 1023, -255, 255);
  }
}

void MoveForward()
{
  if(radio.available())
  {
    digitalWrite(forwardPin, HIGH);
    digitalWrite(backwardPin, LOW);
  
    analogWrite(lSpeedOut, lSpeedF);
    analogWrite(rSpeedOut, rSpeedF);
  }
}

void MoveBackward()
{
  if(radio.available())
  {
    digitalWrite(forwardPin, LOW);
    digitalWrite(backwardPin, HIGH);
  
    analogWrite(lSpeedOut, -lSpeedF);
    analogWrite(rSpeedOut, -rSpeedF);
  }
}

void DontMove()
{
  if(radio.available())
  {
    digitalWrite(forwardPin, HIGH);
    digitalWrite(backwardPin, HIGH);
  }
}

Any help would be greatly appreciated as I am trying to get this project done before I start school again.

Thankyou for helping.

Sorry but it sounds like you may have fried your Arduino. Remove all the hardware and start with some simple sketches to check it out. Here are some simple rules that you appear to have violated.
Gil's Crispy Critter Rules, they also apply to Raspberry Pie hardware:
Rule #1. A Power Supply the Arduino is NOT!
Rule #2. Never Connect Anything Inductive to an Arduino!
Rule #3 when first starting out, add a 220R resistor in series with both Input and Output pins. (LarryD)
Rule #4 buy a DMM to measure voltages, currents and resistance. (LarryD)
Violating these rules tends to make crispy critters out of Arduinos.

If you need more help post an annotated schematic showing exactly how you have wired it, be sure to include all power sources, grounds etc. Links to technical information on your hardware makes it a lot easier to fogure out what the problem(s) is.

Thanks for the advice. I have 2 other nrf24l01 modules as well as another Arduino which I have been switching out to try to get it to work. There is a change that they are fried but I am not sure whether I have fried them all.

I think I will take a day to pull it all apart and just use the Arduino and the module to try to get a simple connection.

Thanks for the advice,
Can I ask again on this post if I run into another road block on the same topic or is it better to make another post.

Thanks

Hello pakenplayz

Welcome to the world's best Arduino forum ever.

I have been following the topic of using this type of wireless module and the associated software functions for some time now.

For wireless projects, I recommend using the HC12 module.

What are the advantages:

  1. no external functions from a library are needed.
  2. the development of a communication protocol is in your hands
  3. the necessary development steps can be programmed and tested without using the wireless module
  4. the radio module can be easily configured for the project requirements
  5. both transmitter and receiver are contained in one radio module.

hth

Have a nice day and enjoy coding in C++.

Cool thankyou very much,

I will try pulling my project apart and putting it back together again, but if worse comes to worse I will most likely give this module a go.

Thankyou very much

1 Like

We would be disappointed if you did not post. We are here to help. Have fun!

Awesome thankyou so much

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.