Nordic RF24L01 module with Arduino Mega

Hello,

On the Sparkfun website I've seen the following module:

http://www.sparkfun.com/commerce/product_info.php?products_id=691

But could not find any code for this specific module.

I've found some ready to use code on the Seeedstudio website for the following module:

http://www.seeedstudio.com/depot/24g-rf-module-nrf24l01-p-214.html

Code: http://www.seeedstudio.com/depot/images/product/code/nRF24l01.rar

I've notices the same chip is used but can I use this code for the sparkfun module? Or does it need modification?

Since I have less programming skills, maybe some user with more programming experience can estimate is this is possible?

Thanks in advance,

OpenSource

According to the Nordic website the nRF24L01+ is backwards compatible with the nRF24L01 sold by Seeedstudio so the code should work. I've never used these modules myself so can't give you a cast-iron guarantee.

http://www.nordicsemi.com/index.cfm?obj=product&act=display&pro=94

HTH

Ver

Ok thanks for the information :)

But is there normally also some module specific code included in a library? I am not a coder so I don't know what's included in a library.

Best regards.

There I can't help you as I've never used those modules or the code.

Sorry.

Ver

I've ported this nRF24L01 avr-gcc library (not mine) to an Arduino library. It has been tested it on duemilanove with the sparkfun nRF24L01+ modules.

Download it here it depends on the Spi library.

Looking at the hardware page for the Mega it looks like the SPI pins are different. You might have to change the pin definitions in the Spi library.

Hope that helps :)

Hi there,

Thanks for your reply :)

For what specific purpose are u using the nrf24l01 ( I know it's some kind of wireless transfer ;))? It is possible to send files (1 mb) from Arduino A to Arduino B using this library. I know I have to chop up the file into little packets prior to transfer.

Are all the benefits of the "+" version also included in this library?

Do you maybe have got a example sketch how to send a file?

I've also seen this library:

http://forum.sparkfun.com/viewtopic.php?t=6855 This is not for the nrf24l01+ (it is off course backwards compatible but the extra features will not work)

Cheers.

The project I'm working on is a temperature data logger with wireless download.

My aim is to have a solar powered Arduino logging the data constantly then a script on my computer (not near suitable window) to download on boot.

The most you can send in one packet is 32 bytes, set with Mirf.payload. The Mirf.send function in the library only sends one packet. So to send anything larger you'll need to split the data up and call send for each bit.

1 mb is more than the ram in the mega so you'll need some extra storage, other than that there's no reason why you can't transfer it.

I don't really know about the extra benefits of the + version I don't think there is any extra configuration require to take advantage.

The library I've ported is much simpler than that library. It depends if you need the extra data pipes etc.

Is there a specific feature you're particularly interested in?

Basically I want to do the following things:

  1. I want to send a picture (chopped in packets) from Arduino A to Arduino B.

  2. At the same time I want to send commands from Arduino B to Arduino A to control the movements of a vehicle.

Is this possible using your ported library?

I don't know if this uses extra pipelines?

The + version has a better sensitivity and bigger range ( I don't think you need a special library to achieve this)?

Thanks in advance :)

May be it would eb better for you ti use the other Sparcfun transceivers nRF2401A ? There is a good library in the Playground http://www.arduino.cc/playground/InterfacingWithHardware/Nrf2401.

You can use 2 parallel channels, one for your image and one for the control.

The chipantenna is not so good try the other ones.

And you do not need SPI.

If you know some german have a look in this topic: Arduino und der Sparkfun Transceiver nRF2401A ???

The nRF24L01 definitely can't do both sending and receiving at the same time so you would need two at each end. If the nRF2401A can do that it would be a much better choice for your application.

Hello,

On the playground of the nrf2401A I've read:

"The Nrf2401 is a half-duplex transceiver, so while it has the ability to send and receive data, it cannot do both simultaneously."

So this means this is not possible?

Yes I am sorry but it is NOT possible to send and receive at the same time, there is no transceiver (I know) that can do this. The two channels can be used in one direction at a time only.

But there are some indipendent sender and receiver modules from Sparkfun (which I have but thes do not really work) and from Seeedstudio (which I ordered but I did not get them right now) - maybe these are better for your purpose?

Maybe I need to use a RF link transmitter and receiver module (http://www.sparkfun.com/commerce/product_info.php?products_id=8950 to send commands to send commands from Arduino A to Arduino B. This connection is used to send control commands for a vehicle.

And use the nrf24L01 to send pictures from Arduino B to Arduino A. (relatively large files).

I still have some questions:

  1. Do I need the 315 or 434 MHz version to send control commands? And the 2400 or 4800 bps version?

  2. Can I use the RF (315 or 434 MHz) and nrf24L01 modules "next" to each other without interference?

Cheers :)

Well... I tried both modules to get some wireless control and I suggest you to go with the nrf2401. These 315mhz and 434mhz modules are very good for remote control, but not data transfer and you won't get not even close to 4800bps with them. I couldn't get 1/4 of that.

The nrf2401 is definitely the way to go if you have these options and want to transfer image data. You really don't need full duplex once you implement some protocol to do the bidirectional communication. You can do something like having both constantly in receive mode, attach interrupts to data receiving and use an ACK based protocol. As long as the receiver is in rx mode waiting for at least an ACK all the time, you can establish bidirectional communication very well. I have it set this way to control a robot and it works very well.

One thing... 2.4ghz is a very used frequency, so search for a cleaner channel when setting up. I have it with some code to restart on a new channel sometimes. And keep packet size small. It goes up to 25 or 36 bytes, I'm not sure, but the transceiver has a builtin CRC so if you get a single bit corrupted, the whole packet is lost. I got it working fine, transmitting at 250kbps, 4bytes per packet, up to 180 meters with less than 5% lost packets.

Ok, so for sending pictures (data files) the nrf2401 is perfect :). Why do u use the nrf2401 and not the nrf24L01? I will probably use the nrf24L01+, this because of the improved range ect...

Do you think the 434 MHz transmit/receive modules are not good enough for sending control commands to my vehicle (control two small motors and two servo's)? The advantage of there modules is the range (150 meters, 500 feet).

Cheers

Some confusion here… nrf2401 and variations is just the chip by Nordic. You’ll have to go for some module implementation, and Sparkfun created some confusion by using the chip names on their modules. You can find modules from various manufacturers, not only Sparkfun.

I’m using the TRW-24G module by Laipac built around the nrf2401a chip, I used the Sparkfun nrf2401a using the same chip (not recommended), and the Sparkfun nRF2401L+ module. They have some minor differences, and when I recommended using the nrf2401 I referred to the family… anything within it would be better suited for your data transmission problem than the 434 and 315mHz modules.

If you’re concerned about range, I’d recommend using the Laipac, not the Sparkfun modules. Don’t ask me why, but even the module with te same chip don’t have the same range. Maybe the shielding or the different antenna makes a difference. The only advantage for the Sparkfun module with the nRF24L01+ is the built-in ACK and retransmit features, but it’s not such a big deal. The higher max data rate is not so useful if you’re concerned about range and will have to keep it low to 250kbps anyway.

Despite what the manufacturer says, which sounds like sales argument from marketing people, I wasn’t able to get the 434 and 315mHz modules working with UART at more than 500bps, and even that wasn’t very reliable. They can’t keep transmitting for a long time, so it will drop signal a few seconds after the first pulse. Not only that, but those frequencies are very crowded too, and you’ll get a lot of corrupted data. If you’re building a robot that will run outdoors like mine did, every time someone around turn the car alarm on or off, expect to get interferences. The 2.4gHz frequency is very crowded, but the nrf2401 modules have the shockburst mode to transmit the whole buffer in a single short burst, so the chances of getting interference are much lower.

The 434/315mHz modules are perfect for making small remote controls, like those used by cars and home security systems. I get them working easily by coupling with a pair of HT12E/HT12D encoders, decoders and currently have one working like that for my home automation system. If you can control your vehicle motor and servos with 4 bits per frame, then you can use it, but I think it’s worth mentioning I was doing the exact same thing with them (controlling a robot motors and servos) when I got tired of struggling with it and decided to try with the nrf2401 family modules.

About the range advantage you presume those modules have, don’t go for it. With the TRW-24G module with the nRF2401A chip, I got a greater range than these modules, and than the Sparkfun modules too, including the one with the same chip. With the much higher data rate is easier to also implement a better protocol to deal with lost packets and force the range to the limits. Maybe the only real advantage is that 434 and 315mHz signals need a much bigger obstacle to be blocked, but it’s not such a big deal.

OpenSource,

Any luck with sending the picture? I am very interested if you have some tips for me on how to do this.

Hi,

I have not managed it yet. The picture sending is just a small part of the project I am working on. But I use this library:

http://www.mrroot.net/2009/11/more-software-this-time-some-fixes-to-the-mirf-library/

What do you exactly want to do? Send a picture wireless? How big is the picture? was it taken using the C328 camera?

Cheers :)

Good luck on your project! I need to transmit a picture from a computer to an FPGA, so it can be displayed on a PSP screen. I use the Arduino merely to send data from the computer to the RF24L01. It is working right now, but when I send a lot of data in a row, it always causes problems.

I want to transmit a packet with 4 bytes in the payload. When I slowly send the data, this is working correctly. However, when I use the Serial Monitor to send multiple characters (by typing a sentence for example) the data gets mixed up. For example:

When I type “5000500050005000” in the Serial Monitor, the output from the receiver should be the same. If a packet is lost, the output could be “500050005000”, but it should always be a 5 followed by three zero’s because the payload is 4, so the data in the payload can’t get messed up. This works properly if I send the characters piece by piece, but when I send this string at once the output is something like this:

“500000050050”

This is my code. I can’t use ack’s due to the nature of the project, so I think the problem might be the function “isSending”, which waits for an interrupt. I don’t know when this interrupt is thrown, since I don’t use ack’s. All comments are very much appreciated!

#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

  byte data[4]; 
  int i;
  
void setup(){
  Serial.begin(57600);
   Mirf.csnPin = 7;
   Mirf.cePin = 8;
   Mirf.init();
  
   Mirf.setRADDR((byte *)"clie1");
  
   
   Mirf.payload = 4;
  
  
  Mirf.configRegister(EN_AA,0x00);  //Disable auto ack
  Mirf.config();

  
}

void loop(){
  
  if (Serial.available() > 3) {
    
    // read the incoming bytes:
    
  data[0] = Serial.read(); 
  data[1] = Serial.read();
  data[2] = Serial.read();
  data[3] = Serial.read();
  
 
  
  Mirf.setTADDR((byte *)"serv1");
  
  Mirf.send((byte *)&data);
  
  while(Mirf.isSending()){
    
    }
  
  }
  
}

Never mind, it's working now.