Nrf2401 RC transmitter and receiver

HI, I'm trying to build a transmitter and receiver using the nrf2401for a flying wing(4-8 channels). I tried a lot of projects on the internet but cant get them to communicate. I got a base with a cap.

Can any one pleas assist me with a project?

they connect but do not communicate.

What helped me get started was following the tutorials by @Robin2 here of this forum:

The ones I got has an antenna

How do you know that they connect if they will not communicate?

Here is my collection of tips gathered while getting my radios to work reliably and helping others to do so, too.

If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. The code in the examples has been proven to work many many times. If it does not work for you, there is likely a hardware problem.

Run the CheckConnection.ino (look in reply #30 in the tutorial) to verify the physical wiring between the radio module and its processor (Arduino).

Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.

If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings.

Reset the radios by cycling power to them after uploading new code. I have found that to help. They do not reset with the Arduino.

Switch to 1MB data rate to catch the not so cloned clones.
radio.setDataRate( RF24_1MBPS );

Also for some clones, change TMRh20's RF24.cpp line 44
_SPI.setClockDivider(SPI_CLOCK_DIV2);
Into
_SPI.setClockDivider(SPI_CLOCK_DIV4);

Have a look at the common problems page.

where is the code in the tutorial?

You probably have the higher power modules (the LNA+PA variants). The electrical connections are the same. Follow the advice of @groundFungus and the tutorial(s) in the link I gave you.

It's all there in the discussion. Start with the code in reply #30 to make sure that your 2 modules are wired up correctly, then jump back to the start and build up your knowledge by following the tutorials.

I am setting it up.

So where are your drawings and code...????

You might want to look here also..... old project but most still applies....goes through a full list of videos.

https://www.youtube.com/watch?v=YPtxHw3DWrg&list=PLzidsatoEzeieT03YQ6-LpO0bR1yfEZpx

Dose any one know a bout a working 4-6 channel transmitter and receiver project?

Can you explain your project and what you are trying to achieve?

You didn,t see the above link.....?????

Ah, got it! You can combine all your "channels" into one message. If you package up your channel data (= servo position in R/C speak?) into a single struct or array, then you can send all the positions in 1 message.

Here is tested example code for sending and receiving a struct that contains the X and Y values for 2 joysitcks.

Sender:


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


const byte CE_PIN = 9;
const byte CSN_PIN = 10;

const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

struct JoyValues
{
  int joy1x;
  int joy1y;
  int joy2x;
  int joy2y;
}joyValues;

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

const byte joy1xPin = A0;
const byte joy1yPin = A1;
const byte joy2xPin = A2;
const byte joy2yPin = A3;

void setup()
{

   Serial.begin(115200);
   Serial.println("SimpleTx Starting");
      
   radio.begin();
   radio.setChannel(76);  //76 library default
   //RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
   radio.setPALevel(RF24_PA_HIGH);
   radio.setDataRate( RF24_250KBPS );
   radio.setRetries(3, 5); // delay, count
   radio.openWritingPipe(slaveAddress);
}

void loop()
{
   currentMillis = millis();
   if (currentMillis - prevMillis >= txIntervalMillis)
   {
      send();
      Serial.print("JOY 1 X = ");
      Serial.print( joyValues.joy1x);
      Serial.print("  JOY 1 Y = ");
      Serial.print( joyValues.joy1y);
      Serial.print("  JOY 2 X = ");
      Serial.print( joyValues.joy2x);
      Serial.print("  JOY 2 Y = ");
      Serial.println( joyValues.joy2y);
      prevMillis = millis();
   }
}

//====================

void send()
{
   joyValues.joy1x = analogRead(joy1xPin);
   joyValues.joy1y = analogRead(joy1yPin);
   joyValues.joy2x = analogRead(joy2xPin);
   joyValues.joy2y = analogRead(joy2yPin);
   radio.write( &joyValues, sizeof(joyValues) );
}

Receiver:



// SimpleRx - the slave or the receiver

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

const byte CE_PIN = 9;
const byte CSN_PIN = 10;

const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};

RF24 radio(CE_PIN, CSN_PIN);

struct JoyValues
{
  int joy1x;
  int joy1y;
  int joy2x;
  int joy2y;
}joyValues;

bool newData = false;

//===========

void setup()
{

   Serial.begin(115200);

   Serial.println("SimpleRx Starting");

   radio.begin();
   radio.setChannel(76);  //76 library default
   //RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
   radio.setPALevel(RF24_PA_HIGH);
   radio.setDataRate( RF24_250KBPS );
   radio.openReadingPipe(1, thisSlaveAddress);
   radio.startListening();
}

//=============

void loop()
{
   getData();
   showData();
}

//==============

void getData()
{
   if ( radio.available() )
   {
      radio.read( &joyValues, sizeof(joyValues) );
      newData = true;
   }
}

void showData()
{
   if (newData == true)
   {
      Serial.print("Data received >> ");
       Serial.print("JOY 1 X = ");
      Serial.print( joyValues.joy1x);
      Serial.print("  JOY 1 Y = ");
      Serial.print( joyValues.joy1y);
      Serial.print("  JOY 2 X = ");
      Serial.print( joyValues.joy2x);
      Serial.print("  JOY 2 Y = ");
      Serial.println( joyValues.joy2y);
      newData = false;
   }
}

Code is adapted from the examples in Robin2's tutorial that I linked in post #5.

1 Like

@markd833 I'm just trying to get them them to connect and send a word from the one to the other. Then I want to make a transmitter that takes the values of two joy sticks and turn them into a servo position then send it to the receiver in my flying wing.

@markd833 That is a grate Idea but first I need to get them them to connect.

@groundFungus How do I get a serial monitor on the slave because I only have one pc?

You can open an instance of the IDE for each board. In each IDE instance, choose the board and port for each board. Then you should be able to open a serial monitor for each board.

It is important that you have a separate instance of the IDE for each board. Do not use File, New to open an IDE.

Get the modules to communicate:

I want them 6meaters out of each other.