SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: NRF24L01 RF Transceiver

Thu Sep 19, 2013 10:32 am

I have a bizarre problem. I have a couple of modules which don't work unless they are set to 2MB/s speeds.
They claim to be nRF24L01+, and are identified as such, and to eliminate any weirdness, I am using 2x arduino, one set as a hub, the other as a sendtohub node.

I have correctly wired them both (I checked each one SEVERAL times), and as I say, they only work if set to RF24_2MBPS.

I have also tried different channels to see if that helped, but no, it doesn't.

To me it sounds like these cheap clones are not entirely as advertised.
Anyone any ideas?

Steve
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: NRF24L01 RF Transceiver

Thu Sep 19, 2013 12:33 pm

If they only work on lower mbs then could be interference - could do the scanner test to see whats going on

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: NRF24L01 RF Transceiver

Thu Sep 19, 2013 1:20 pm

That's the weird thing, they only work on the higher transmission speed.
I have them sat here now, running quite happily at 2MB/s, for the last 2 hours, with only the odd drop-out/.

Of course, there's no reason NOT to use them at 2MB/s instead of 1MB/s, but I did wonder why they don't work at the lower rate.
(I have 5 of them, and they all do the same). They are the ones with integral antenna on the board, and apart from not working at the lower rate, are fine - I have them talking to each other from one side of the house to another with no problems.

Steve
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

jabelch
Posts: 1
Joined: Wed Oct 30, 2013 11:43 pm

Re: NRF24L01 RF Transceiver

Wed Oct 30, 2013 11:49 pm

My first guess about the failed message on the arduino is that the protocol may be expecting a confirmation from the recipient. I'm just getting involved with this particular implementation with these radios, so I may be wrong. The same radio is used in ResponseCard RF "clickers" and that protocol specifies that the master device send a confirmation, otherwise the clicker just continues to broadcast.

Some hacked versions of the clicker using an arduino can sniff the wireless traffic of other radios but don't bother with sending a confirmation.

If I find anything specific I'll post another response.

ecrampton
Posts: 2
Joined: Sun Dec 15, 2013 5:23 pm

Re: NRF24L01 RF Transceiver

Sun Dec 15, 2013 6:14 pm

I am having a bit of trouble getting the NRF24l01+ to work consistently. I am currently trying to interface the RPI to an MSP430 using the smp library here: https://github.com/spirilis/msprf24 . Now I have tested two MSP430's talking and they work great together. My problem is getting the rpi to work with the MSP430. My first problem was I was dropping a lot of packets and decided to use the GPIO interrupt to catch when the RPI would get a message. This seemed to improve the connection where the RPI wasn't dropping but very few packets from the MSP430.

The way I achieved this was I set the MSP430 to send out a 32 byte packet and the RPI to receive a 32 Byte packet. However when trying to enable a dynamic packet length the RPI NRF24l01 doesn't seem to receive anything as my GPIO interrupt never fires. One thing to note is after doing some testing I seem to have to completely restart the RPI because it will just stop receiving any packets when I go back to the static 32 Bytes from dynamic payload.

Here is the code I am using on the RPI as a reference to enable dynamic I just comment out the radio.setPayloadSize(32); and uncomment the radio.enableDynamicPayloads();

Code: Select all

/*
#include <wiringPi.h>
#include <cstdlib>
#include <iostream>
#include "../RF24.h"
#include <ctime>
#include <iostream>
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio("/dev/spidev0.0",8000000 , 25);  //spi device, speed and CSN,only CSN is NEEDED in RPI

char receive_payload[32+1];
uint8_t intResult;

void gotData(void)
{
	
  bool rx, blnTXOK, blnTXFail;

  radio.whatHappened(blnTXOK,blnTXFail,rx);
	puts("gpio\r\n");
if(blnTXFail){
intResult = 2;
}else if(blnTXOK){
intResult = 1;
}else if ( rx )
  {
intResult = 3;
//uint8_t len = radio.getPayloadSize();

      bool done = false;
      while (!done)
      {
		  uint8_t len = radio.getDynamicPayloadSize();
        // Fetch the payload, and see if this was the last one.
      done = radio.read( receive_payload, len );

      // Put a zero at the end for easy printing
      receive_payload[len] = 0;

        // Spew it
        std::time_t result = std::time(NULL);
		std::cout << std::asctime(std::localtime(&result));
		printf("Got data size=%i value=%s\n\r",len,receive_payload);

      }

     fflush (stdout) ;
   }

}

void setup(void)
{

  printf("\n\rRF24/examples/pingpair/\n\r");
  radio.begin();
  radio.setPayloadSize(32);
  //radio.enableDynamicPayloads();
	radio.setAutoAck(true);
	radio.setRetries(10,15);
	radio.setDataRate(RF24_1MBPS);
	radio.setPALevel(RF24_PA_MAX);
	radio.setChannel(120);
	radio.setCRCLength(RF24_CRC_16);
    radio.openReadingPipe(0,0xDEADBEEF00LL);

   system ("gpio unexport 4");

   system ("gpio export 4 in");
   system ("gpio edge 4 falling"); 
  wiringPiSetupSys () ;

    if (wiringPiISR (4, INT_EDGE_FALLING, &gotData) <0 )   // Got it
    {
		printf ("error setting interrupt: \n") ;
    }

  radio.startListening();
  radio.printDetails();

}


int main(int argc, char** argv)
{
 char chrSend[] = "hello arduino";
int intLoop;
        setup();
  for (;;)
  {

   intResult = 0;
	intLoop = 0;
     
   printf("Main thread\r\n");

     fflush (stdout) ;

   sleep (10) ;
   radio.stopListening();
   radio.startListening();
  }

        return 0;
}
Here is the MSP430 code:

Code: Select all

#include <msp430.h>
#include "msprf24.h"
#include "nrf_userconfig.h"
#include "stdint.h"

volatile unsigned int user;

void main()
{
	char addr[5];
	char buf[32];

	WDTCTL = WDTHOLD | WDTPW;
	DCOCTL = CALDCO_16MHZ;
	BCSCTL1 = CALBC1_16MHZ;
	BCSCTL2 = DIVS_1;  // SMCLK = DCOCLK/2
	// SPI (USCI) uses SMCLK, prefer SMCLK < 10MHz (SPI speed limit for nRF24 = 10MHz)

	// Red, Green LED used for status
	P1DIR |= 0x41;
	P1OUT &= ~0x41;

	user = 0xFE;

	/* Initial values for nRF24L01+ library config variables */
	rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit
	rf_addr_width      = 5;
	rf_speed_power     = RF24_SPEED_1MBPS | RF24_POWER_0DBM;
	rf_channel         = 120;

	msprf24_init();  // All RX pipes closed by default
	msprf24_set_pipe_packetsize(0, 32);
	msprf24_open_pipe(0, 1);  // Open pipe#0 with Enhanced ShockBurst enabled for receiving Auto-ACKs

	// Transmit to 'rad01' (0x72 0x61 0x64 0x30 0x31)
	msprf24_standby();
	user = msprf24_current_state();
	addr[0] = 0xDE;	addr[1] = 0xAD;	addr[2] = 0xBE;	addr[3] = 0xEF;	addr[4] = 0x00;
	w_tx_addr(addr);
   addr[4] = 0x00;
	w_rx_addr(0, addr);  // Pipe 0 receives auto-ack's, autoacks are sent back to the TX addr so the PTX node
			             // needs to listen to the TX addr on pipe#0 to receive them.

	while(1){
		__delay_cycles(800000);
		if(buf[0]=='0'){buf[0] = '1';buf[1] = '0';}
		else {buf[0] = '0';buf[1] = '1';}
		w_tx_payload(32, buf);
		msprf24_activate_tx();
		LPM4;

		if (rf_irq & RF24_IRQ_FLAGGED) {
			rf_irq &= ~RF24_IRQ_FLAGGED;

			msprf24_get_irq_reason();
			if (rf_irq & RF24_IRQ_TX){
				P1OUT &= ~BIT0; // Red LED off
				P1OUT |= 0x40;  // Green LED on
			}
			if (rf_irq & RF24_IRQ_TXFAILED){
				P1OUT &= ~BIT6; // Green LED off
				P1OUT |= BIT0;  // Red LED on
			}

			msprf24_irq_clear(rf_irq);
			user = msprf24_get_last_retransmits();
		}
	}
}

ecrampton
Posts: 2
Joined: Sun Dec 15, 2013 5:23 pm

Re: NRF24L01 RF Transceiver

Sun Dec 15, 2013 10:58 pm

Following up on my previous post I tried running the ping_out example. And I am only seeing:
Failed, response timed out.
Now sending 4168711038...failed.
I did some googling and found alot of people had power issues (seemed to be arduino mega only) and suggested placing a cap across the power and gnd. I did this with a 22uf cap and it did not seem to help. I even changed the RF module thinking maybe something went bad with that one and I get the same result.

Thanks for any help you can provide.

Edit: I fixed the bug in the MSP430 that was causing it not to auto ack thus making it say failed. The TX side of the RPI is working; however the RX dynamic is still not working properly.

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: NRF24L01 RF Transceiver

Mon Dec 16, 2013 8:07 am

If you are not receiving anything then might need to verify pin wiring. If it is intermittent, then you could try using an interrupt to raise event on receive

sureshmali
Posts: 1
Joined: Mon Feb 03, 2014 10:42 pm

Re: NRF24L01 RF Transceiver

Mon Feb 03, 2014 10:47 pm

Hi,

I have tried using the RF24 library modified for Raspberry . Link: https://github.com/stanleyseow/RF24
If I use it with Arduino as tx and rx both can communicate. when I use it as Arduino tx and raspberry pi rx, no data is recieved. Anybody got it working using the above library. Please help.

redlegoman
Posts: 14
Joined: Sat Aug 11, 2012 11:16 am

Re: NRF24L01 RF Transceiver

Tue Feb 18, 2014 5:10 pm

Just thought I'd add my thanks for the hard work of the guys who have ported the Arduino stuff to the Pi. I now have my Arduino successfully transmitting sensor information to my Pi via the rf24. I struggled a bit though until I worked out that I had to add the radio.powerUp() command before every time I wanted to transmit from the Arduino, otherwise it only seemed to transmit the last value when the Arduino was reset.
For example:

Code: Select all

  radio.powerUp();
  sprintf(outBuffer,"%s,%s",tempe,hum);
  radio.write(outBuffer, strlen(outBuffer));
  radio.powerDown();
  delay(1000);
Just thought someone might find that useful. I put it down to the cheap RF24 clones I bought from FleaBay.

bubulindo
Posts: 5
Joined: Fri Mar 21, 2014 9:14 am

Re: NRF24L01 RF Transceiver

Fri Mar 21, 2014 9:23 am

Are you using Greg Copeland's library?
Or the original Maniac Bug's?

After looking into Maniac Bug's files (stupidly, as someone else found the same thing before) I found this:

Code: Select all

  // Yay, we are done.

  // Power down
  powerDown(); //commented this line. 

  // Flush buffers (Is this a relic of past experimentation, and not needed anymore??)
  flush_tx();

  return result;
}
This was what prevented my code to work properly.

After commenting the power down line, things started working better and I can now stream from one side of the house to the other... with Arduinos.
Next step is to communicate with the raspberry pi.

@redlegoman, Are you using the Rpi as a hub? Or just a point to point communication?

redlegoman
Posts: 14
Joined: Sat Aug 11, 2012 11:16 am

Re: NRF24L01 RF Transceiver

Fri Mar 21, 2014 3:46 pm

I am using the RPi as a receiver for several other RF enabled Arduinos, but not using the hub code that came with the library because I couldn't get on with it. I just wrote some C++ code to loop through the addresses of my Arduinos and write each value it finds to a file.

kamerman
Posts: 3
Joined: Wed Sep 26, 2012 3:12 pm

Re: NRF24L01 RF Transceiver

Sat Apr 19, 2014 3:30 pm

Hi,
I am trying to write a program for interfacing the nrf24l01+. I want to write it without library so I can really understand what is happening.
I downloaded the datasheet and started coding but could not get the modules to work. I tried using RF24 library and managed to successfully run the ping-pong example. I studied the code from library and copied setting to my program but i still can't get them working with my code. I can interface the module via spi just fine but nothing is send/received when i try to send data with module.
Would anyone be so kind to look at my code and tell me what am i doing wrong =).
My code: http://pastebin.com/e1ncwtmp

Thanks in advance

stanley
Posts: 33
Joined: Fri Feb 01, 2013 7:38 pm
Location: Kuala Lumpur, Malaysia
Contact: Website

Re: NRF24L01 RF Transceiver

Thu May 15, 2014 4:26 am

I am trying to write a program for interfacing the nrf24l01+. I want to write it without library so I can really understand what is happening.
I downloaded the datasheet and started coding but could not get the modules to work. I tried using RF24 library and managed to successfully run the ping-pong example. I studied the code from library and copied setting to my program but i still can't get them working with my code. I can interface the module via spi just fine but nothing is send/received when i try to send data with module.
Would anyone be so kind to look at my code and tell me what am i doing wrong =).
My code: http://pastebin.com/e1ncwtmp
Try looking at the Mirf library, they are easier to read but less functions ... based on this, I wrote the driver for Electric Imp...
Mirf :-
https://github.com/stanleyseow/arduino-nrf24l01

Electric Imp library in Squirrel lang ...
https://github.com/stanleyseow/electricimp-nRF24L01
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

xgodxqn
Posts: 1
Joined: Thu May 29, 2014 3:17 pm

Re: NRF24L01 RF Transceiver

Thu May 29, 2014 3:29 pm

I use file rpi-hub, then my nRF24L01+ is identified as nrfl24l01.
https://drive.google.com/file/d/0B8OGy7 ... sp=sharing
ah, Can I use address receive 1 bytes for Rpi?
Ex: const uint64_t pipes=0x3F;
People help me :|

tuynhkindnice
Posts: 2
Joined: Mon Mar 03, 2014 1:36 am

Re: NRF24L01 RF Transceiver

Wed Jun 04, 2014 3:08 am

Hi everyone.
I have a problem when I complied file.cpp. I use this link:" http://blog.the-jedi.co.uk/2013/10/07/n ... pberry-pi/ " to make a file.cpp use RF24 library. I put this file.cpp in folder RF24. When I complied it; there are some errors below:

pi@raspberrypi ~/RF24 $ g++ tuynh.cpp -o tuynh
tuynh.cpp:8:39: note: candidates are:
./RF24.h:238:3: note: RF24::RF24(uint8_t, uint8_t)
./RF24.h:238:3: note: candidate expects 2 arguments, 3 provided
./RF24.h:45:7: note: RF24::RF24(const RF24&)
./RF24.h:45:7: note: candidate expects 1 argument, 3 provided

I don't know why there are many errors? I think my library is full. Please give me a hand to solve this problem.

bcatalin
Posts: 23
Joined: Mon Jan 30, 2012 9:45 am

Re: NRF24L01 RF Transceiver

Wed Jun 04, 2014 7:39 am

Paste your cpp code. Did you linked the library ? Is your library installed ?

wickedraspberry
Posts: 6
Joined: Thu Jun 19, 2014 6:37 pm

Re: NRF24L01 RF Transceiver

Thu Jun 19, 2014 6:43 pm

Hello RPI users,

I have the RF24 modules working on arduino, but when trying to use them on RPI, I don't seem to get any signal.
Everything checks out fine, connections are ok, but when I run 'scanner' I get the following output:
RF24/examples/scanner/
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x0f
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
00000000000000001111111111111111222222222222222233333333333333334444444444444444555555555555555566666666666666667777777777777777
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
etc. etc.

So the device seems ok (it should, it works fine on arduino), but I get only zero's back from the scanner (on arduino I always see some signals). Where should I look to solve my problem?

Thanks in advance,
wickedraspberry

dertester
Posts: 6
Joined: Sun Nov 03, 2013 3:14 am

Re: NRF24L01 RF Transceiver

Sun Jun 22, 2014 10:13 pm

Hi,

im totally new to this. So pls forgive stupid questions

I have a arduino nrf network running using:
https://github.com/maniacbug/RF24
https://github.com/maniacbug/RF24Network

I found a port that could work with the pi:
https://github.com/farconada/RF24Network

Now after a little problem i cloned the lib, make all and make install and now im stuck.

As im actually coming from the arduino ide i have no clue how to get the examples running. I hope you can help me :)

wickedraspberry
Posts: 6
Joined: Thu Jun 19, 2014 6:37 pm

Re: NRF24L01 RF Transceiver

Mon Jun 23, 2014 5:42 am

Best start with this topic:
http://conoroneill.net/arduino-and-rasp ... 1-modules/
or this one:
http://hack.lenotta.com/arduino-raspber ... -nrf24l01/

I have it working, but am not getting any signals though (see my previous post).

dertester
Posts: 6
Joined: Sun Nov 03, 2013 3:14 am

Re: NRF24L01 RF Transceiver

Mon Jun 23, 2014 7:46 pm

@wickedraspberry

Have you tried a cap (1uF) directly on the NRF module?

I think its pretty sensible, on my selfmade boards i need them, while on arduino using 3.3V its pretty good.


I tried to compile a example from the rf24network but i get:
rx-example.cpp:(.text+0x84): undefined reference to `RF24::begin()'

not sure if i point to the right libs using g++ -L/usr/lib rx-example.cpp -I/usr/include -o main -lrrd

What are the -L and -I options actually?

wickedraspberry
Posts: 6
Joined: Thu Jun 19, 2014 6:37 pm

Re: NRF24L01 RF Transceiver

Tue Jun 24, 2014 6:31 am

I will try the capacitor. Noise might indeed be the problem, since everything else seems to be working fine.
Not an expert on gcc and library linking. It has been a while since I programmed for something without an IDE which takes care of these kind of things :D

But in the lenotta example they use:

g++ -Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -L../librf24/ -lrf24 remote.cpp -o remote

Or you can look in the makefile how the libraries are linked.

wickedraspberry
Posts: 6
Joined: Thu Jun 19, 2014 6:37 pm

Re: NRF24L01 RF Transceiver

Wed Jun 25, 2014 9:03 am

The capacitor didn't help, so I started from scratch with a clean raspbian image.
This time I installed everything from TMRh20's fork:
https://github.com/TMRh20/RF24/tree/master/RPi
Which has very good documentation on how to set things up. And it worked!

I also reinstalled this library on the old image, but still no go, so I guess something is wrong there, but haven't figured out what it is yet.

wickedraspberry
Posts: 6
Joined: Thu Jun 19, 2014 6:37 pm

Re: NRF24L01 RF Transceiver

Wed Jun 25, 2014 9:31 am

Figured it out: I had also installed servoblaster, which was using the same GPIO pins. Reconfigured servoblaster and everything is working fine now!

So when you're using both servoblaster and RF24 make sure you look at the GPIO configuration.

xavbabe
Posts: 5
Joined: Sat Aug 09, 2014 11:52 am

Re: NRF24L01 RF Transceiver

Thu Sep 18, 2014 11:14 am

If it helps anyone I have started a project that uses Pies and Arduinos to form a sensor network with these radios - all nodes can send and receive. Pi side is Python3. Code is here: http://github.com/xavbabe/heating you will want to look in the Arduino folder and at monitor.py
Hope you get it working!
Last edited by xavbabe on Mon Sep 29, 2014 5:49 pm, edited 1 time in total.

redlegoman
Posts: 14
Joined: Sat Aug 11, 2012 11:16 am

Re: NRF24L01 RF Transceiver

Thu Sep 18, 2014 12:29 pm

You probably mean https://github.com/xavbabe/heating. Hope there are fewer typos in the code! ;) :lol:

Return to “HATs and other add-ons”