Problem with NRF24

Hi!

I am trying to conrol 4 motors with a joystick remote. I have one NRF connected to a Arduino Uno with a joystick that should send the analog input to the reciver witch is a Arduino Nano with a NRF24 as reciver. The problem is that the reciver doesnt recive the value.
Here is my wiring on my transmitter:
NRF24 - Arduino Uno
CSN - D8
CE - D9
MOSI - D11
MISO - D12
SCK - D13

My reciver:
CSN - D8
CE - D9
MOSI - D11
MISO - D12
SCK - D13

My code for the transmitter:

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

// Create Radio and define pins
RF24 radio(8, 9);

// Create Radio channels
byte addresses[][6] = {"00001", "00002"};

void setup() {
  Serial.begin(9600);

  // Start radio communication
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_MIN);
}

void loop() {
  delay(100);
  radio.stopListening();
  int potValue = analogRead(A0);
  int angleValue = map(potValue, 0, 1023, 0, 180);
  radio.write(&angleValue, sizeof(angleValue));
  
  Serial.println(angleValue);
}

My code for the reciver:

#include <Servo.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

// Booleans
bool gpsMode = false;

// Create GPS
TinyGPSPlus gps;

// Create Radio and define pins
RF24 radio(8, 9);

// Create Radio channels
byte addresses[][6] = {"00001", "00002"};

// Create SoftwareSerial to read TX pin. RX pin is unnecessary
SoftwareSerial ss(4, -1);

// Create Motors
Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;

void setup() {
  // Declare motor pins and min/max throttle
  motor1.attach(5, 1000, 2000);
  motor2.attach(6, 1000, 2000);
  motor3.attach(7, 1000, 2000);
  motor4.attach(8, 1000, 2000);

  // Calibrate motors
  motor1.writeMicroseconds(1000);
  motor2.writeMicroseconds(1000);
  motor3.writeMicroseconds(1000);
  motor4.writeMicroseconds(1000);

  // Start logging
  Serial.begin(9600);
  ss.begin(9600);

  // Start radio communication
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_MIN);
}

void loop() {
  delay(100);

  // Start radio
  radio.startListening();
  if (radio.available()) {
    while (radio.available()) {
      // Throttle Controll
      int angleV = 0;
      radio.read(&angleV, sizeof(angleV));
      
      Serial.println(angleV);
      
      motor1.writeMicroseconds(angleV);
      motor2.writeMicroseconds(angleV);
      motor3.writeMicroseconds(angleV);
      motor4.writeMicroseconds(angleV);

      // GPS Mode
      if (gpsMode) {
        while (ss.available() > 0) {
          if (gps.encode(ss.read())) {
            if (gps.location.isUpdated()) {
              Serial.print(gps.location.lat(), 6);
              Serial.print(", ");
              Serial.println(gps.location.lng(), 6);
            }
          }

        }
      }
      delay(100);
    }
  }
  delay(100);
  /*
  radio.stopListening();
  char postValue[32] = "Return Values";
  radio.write(&postValue, sizeof(postValue));
  */
}

Thanks beforehand!!!
Best regards Max

How are the radios powered. One of the biggest problems with using the rf24 radios is trying to power them from the weak 3.3V regulator on Arduino boards. They just can’t supply the required current. A 10uF (or larger) across the rf24 power input (as close to the rf24 as possible) will sometimes help. I use a separate LM1117 3.3 regulator for my radios. There are adapters available that have the regulator and other components on board to power the radios.

I used Robin2’s simple rf24 tutorial
to get my radios to work. There is also information on powering the radios in the tutorial.

I am powering it from the arduinos 3.3v. Ill try with a 3.3v regulator instead.

I have a couple of Unos with rf24 radios attached. I loaded your transmitter and receiver codes onto them. The receiver, in my setup, gets the data from the transmitter just fine. So your code seems OK. So it could be a power problem which you can fix by using a regulator that can supply the required current. If that doesn’t work, look for a wiring problem or bad jumper wires.

I tested with the 3.3v regulator and now I belive that I have a wiring error. I will have to take a look at it tomorrow, thanks for the help!

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