Getting started with nRF24L01

sample.png (122872Bytes)
receiver_code.PNG (12971Bytes)
transmitter_code.PNG (11631Bytes)
(Bytes)
nrf-ardino-en.png (84568Bytes)
Duemilanove-nrf_1.jpg (178082Bytes)
Duemilanove-nrf_2.jpg (191376Bytes)
DUE-nrf_1.jpg (171709Bytes)
DUE-nrf_2.jpg (163708Bytes)
output.png (122003Bytes)

Hello guys I'm trying to send message from arduino due to arduino duemilanove atmega328 using nRF24L01 

arduino due is the transmitter and the code is

 

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

RF24 radio(7, 8);

const byte rxAddr[6] = “00001”;

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  const char text[] = “Hello World”;
  radio.write(&text, sizeof(text));
  
  delay(1000);
}

arduino duemilanove atmega328 is receiver 

  •  MOSI is connected to the digital pin 11
  •     MISO is connected to the digital pin 12
  •     SCK is connected to the digital pin 13

 

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

RF24 radio(7, 8);

const byte rxAddr[6] = “00001”;

void setup()
{
  while (!Serial);
  Serial.begin(9600);
  
  radio.begin();
  radio.openReadingPipe(0, rxAddr);
  
  radio.startListening();
}

void loop()
{
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    
    Serial.println(text);
  }
}

when i run these code and open the serial monitor it is receiving  some blank characters as the serial monitor is constantly scrolling. 

I’ve also attached the screen shot of a test code

The NRF24l01 module is working fine with arduino duemilanove atmega328, the problem is with arduino DUE.

thanks you guys for reading

Please include a schematic and a detailed picture of both boards
You can include multiple images in your top post and you can edit this post to do it.

In order to see what you’re doing, we need to see which pins on the Arduino’s are connected to which pins of the radios.

It would be best is you could include a schematic and one image apiece (high resolution) so that we can see the actual wiring.

It would also have been much easier for you to debug if you had used two of the same type of arduinos.

One question: why are you including the SPI library, and telling us which pins are connected to the SPI bus? And I think that you’re using the wrong pins for SPI for the Due, but since I don’t have one, I can’t tell.

Exactly which library are you using for the RF?

Looking at SPI documentation
I’ve spentthe last hour and a half looking at this.

Since you haven’t provided pictures or schematics, I can only guess.

My suspicion is that you’ve wired the SPI bus incorrectly. On the DUE, the SPI bus has a specific 6 pin header where the ICSP is on the other boards. Please read the SPI library documentation to determine which pins are used.

The address for openPipe functions should be a uint64_t
You should only use one address shared by both sketches. Also the address to be used should be a uint64_t rather than an array of characters.

I would define it as

const uint64_t rfAddr = 0x9090909001;

And open the pipes as

radio.openReadingPipe(1, rfAddr);

And

radio.openWritingPipe(rfAddr);

The two addresses need to be the same. They are really only 40 bits long and only the low 8 bits should b different? Why? I don’t know! (Both) Third base!

If I actually had these modules I would test them, but only you can (well, technically anybody with two modules and one Arduino). And as I’ve inested about three hours in this now, be glad you’re getting it for free rather than at my consulting rate, which would be $300 and the imaginary meter is still running.

All I’ve done is to read simple open source docs available starting at Arduino.cc. You can do the same. And you get no more help until you’ve at least tried the suggestions and respond. If I’m not getting paid in coin of the realm, the words “thank you” are at least appreciated.

I hope this helps.

ok your suspicion is right

ok your suspicion is right the problem is with wiring of the SPI bus.there are two headers on DUE, ICSP and SPI. I’ve tried connecting to both still it doesn’t work.

this is a code test

#include <SPI.h>
#include <RF24.h>
#include “printf.h”
#define RF_CS 9
#define RF_CSN 7
RF24 radio(RF_CS, RF_CSN);
void setup() {
Serial.begin(9600);
printf_begin();
radio.begin();
radio.printDetails();
}
void loop() {

 the output of this code should be: But I’m not getting this output which means the connection of SPI bus is wrong
STATUS     = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xc2c2c2c2c2 0xe7e7e7e7e7
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xc2c2c2c2c2
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH

Thank you very much for

Thank you very much for helping me. I’ve also attached a pic of schematic. I’ll try out these suggestion but the first major problem is in wiring once i work that out then only i’ll be able to proceed further. Thanks once again.

Would you either post a link

Would you either post a link to the transceiver module you are using, or define what the IO Pins on the module are. I have no way of knowing if anything is hooked up correctly if I don’t know what the pins are supposed to be.

The other thing: does the module take 5v only or 5v and 3v3?

One suggestion: you can use two modules on a single Arduino. I would suggest hooking both modules up to the same Arduino and trying the following sketch.

http://maniacbug.github.io/RF24/GettingStarted_8pde-example.html

Ok i have uploaded one more

Ok i have uploaded one more schematic, in the schematic it is shown arduino uno but I’m using DUE. the module takes  3.3v at vcc

I tried that getting started

I tried that getting started sketch and it is working(though I’m not sure if it is working correctly). I connected the miso, mosi and sck pins to the icsp header of arduino due. 

The original code is not working(sending “hello world” from one arduino to other). i made the changes you suggested

const uint64_t rfAddr = 0x9090909001;

And open the pipes as

radio.openReadingPipe(1, rfAddr);

And

radio.openWritingPipe(rfAddr);

But it is still not working,

When I interchange roles of arduinos i.e., the arduino duemilanove as transmitter and arduino due as receiver this time instead of blank spaces the output in serial monitor is “ÿÿÿÿÿÿÿÿÿÿÿ”


First, I’m very certain that
First, I’m very certain that you need to connect to the SPI header.

When using the sample sketch I suggested, you need to use two Arduinos, with only one change to the sketch. There is a line in the sketch that defines the role.

The receiver has a line saying:

role_e role = role_pong_back;

and the transmitter has a line saying:

role_e role = role_pong_out;

Otherwise the two sketches are identical.

In order to help you any more, I eee a clear high resolution image taken from above your circuit clearly showing what is actually connected to what.

I will also need a link to where the page where the radio module was bought from. These tend to be slightly different.

I will check in on this to see if you have put up the images and link.

Have a good day.

One mistake I made is that
One mistake I made is that apparently to make it a 64 bit integer you need to put LL directly after the last hex character. Otherwise it will be a 16 bit integer.

I’ve uploaded the images of

I’ve uploaded the images of ciruit hope they are clear enough.

this is the link from where i bought the radios:

http://www.ebay.in/itm/2-PCS-NRF24L01-2-4GHz-Wireless-RF-Transceiver-Module-Free-C-Code-for-Arduino-/151618935166?pt=LH_DefaultDomain_203&hash=item234d31597e

I made the change in the transmitter code and ran it, I’m attaching the image of the output of the code

thanks

 

 

From the look of the
From the look of the output.png, it seems to be working. There are timeouts, but that is to be expected.

new code and its output

this is the new code for transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8);
char text= ‘B’;

const uint64_t rxAddr = 0xF0F0F0F0E1LL;
void setup()

{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  
  radio.write(&text, sizeof(text));
  
  delay(1000);
}

this is the new code for receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8);

const uint64_t rxAddr = 0xF0F0F0F0E1LL;
char text;

void setup()
{
  while (!Serial);
  Serial.begin(9600);
  
  radio.begin();
  radio.openReadingPipe(0, rxAddr);
  
  radio.startListening();
}

void loop()
{
  if (radio.available())
  {
   
    radio.read(&text, sizeof(text));
     Serial.println("=");
    Serial.println(text);
  }
}
The output of this code is:

=
ÿ
I tried this same code with Uno instead of Due, still it is not working

I think this is it, i’ll

I think this is it, i’ll switch to bluetooth as I’m on a very tight deadline. I can’t thank you enough for your help. If I find a solution in future will post it here. Thanks once again

The UNO is a 5v board. Did
The UNO is a 5v board. Did you do anything to protect your radio?

**Library **

Can you give me your printf.h library