User avatar
kehribar
Posts: 3
Joined: Sat Aug 18, 2012 10:39 am
Location: istanbul
Contact: Website

Re: NRF24L01 RF Transceiver

Thu May 16, 2013 8:37 am

Hi all,

I've also writen a C based library for these tranceivers. Github link is this: https://github.com/kehribar/nrf24L01_plus

Library is very portable and platform indipendent. In order to use this in Raspberry Pi, you only need to define couple of GPIO functions in your code. Example of a platform spesific definition can be found here: https://github.com/kehribar/nrf24L01_pl ... unctions.c

Let me know if you find it usefull. Issue reports and comments are welcome!

Best,
ihsan.

Aizenko
Posts: 18
Joined: Thu Aug 02, 2012 10:18 am
Contact: Website

Re: NRF24L01 RF Transceiver

Thu May 30, 2013 11:10 am

Hi,
I reconnect to times the nRF24L01 to the raspberry. But each times i got this result as i run spi-hub
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN
The spi is loaded (i used it for an DAC before)... don't understand why it's not working....

the pinout of the RF24 is this one ? :
Image

EDIT:
Seems it is, i wired it to a Arduino and the output is good!

EDIT 2 :

Its working!

On http://arduino-for-beginners.blogspot.f ... es-to.html
The pins connections are
RPi GPIO9 (Pin 21) to RF Module Pin 7 ( MISO )
RPi GPIO10 (Pin 19) to RF Module Pin 6 ( MOSI )
RPi GPIO 11 (Pin 23) to RF Module Pin 5 ( SCK )
RPi GPIO8 (Pin 24) to RF Module Pin 3 ( CE )
RPi GPIO 25 (Pin 22) to RF Module Pin 4 ( CSN )
RPI 3.3V (Pin 17) to RF Module Pin 2 ( VCC/3.3V )
RPi Gnd (Pin 25) to RF Module Pin 1 (GND)
I put the RF pin 4 on RPi 24 (GPIO8) and the RF Pin 3 on RPi 22 (GPIO25) and got a result
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 = 0x7365727631 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xe2 0xe3 0xe4 0xe5
TX_ADDR = 0x7365727631
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x3f
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

Aizenko
Posts: 18
Joined: Thu Aug 02, 2012 10:18 am
Contact: Website

Re: NRF24L01 RF Transceiver

Fri May 31, 2013 9:57 am

I got a question.

In the example of the RF24 lib for RPi all the loop are active. Is there an way to wait for an interrupt when communications are entering?

Regards,

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

Re: NRF24L01 RF Transceiver

Mon Jun 03, 2013 1:41 am

I found this for the interest for everyone here... uses python & GPIO to control the nRF

Raspberry pi: nRF24L01 and TCP
http://gizmosnack.blogspot.se/2013/05/r ... d-tcp.html
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Tue Jun 25, 2013 9:32 am

bertux wrote:I fix the error 0X000 now it's ok, but no response.
Hi dude

I am a Noob starting to learn about RF communications. Would you please tell me how you got that error fixed.
I am trying to establish wireless communication between my arduino and raspberry.

Initially, when I connected my nrf+ module to arduino, I got an error 0x000 error (same as you). Figured out that my connections were loose. Now it works perfectly fine.
The nrf+ module attached to Raspberry has been a problem. Raspberry detects it to be nrf24L01 and not nrf24L01+. This wrong detection happens only when connections are wrong. I checked all of them. Connections are as mentioned in this blog. Still, my output remains:
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1 = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5 = 0xff 0xff 0xff 0xff
TX_ADDR = 0xffffffffff
RX_PW_P0-6 = 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA = 0xff
EN_RXADDR = 0xff
RF_CH = 0xff
RF_SETUP = 0xff
CONFIG = 0xff
DYNPD/FEATURE = 0xff 0xff
Data Rate = 1MBPS
Model = nRF24L01 (Model is detected wrongly)
CRC Length = 16 bits
PA Power = PA_MAX

Please help me in case I can fix it. :!:

SKH
Posts: 1
Joined: Fri Jun 28, 2013 7:08 am

Re: NRF24L01 RF Transceiver

Fri Jun 28, 2013 7:11 am

Hi everyone.
I am a noob and am trying to access gpio pins from a C++ program. I am working on communication between nrf modules and have done it successfully. But i receive errors when i include both <wiringPi.h> and <RF24.h> together in a program. Please help.
The error is as follows:

/usr/local/include/wiringPi.h:132:13: error: declaration of âstatic void GPIO::open(int, int)â outside of class is not definition [-fpermissive]
/usr/local/include/wiringPi.h:135:13: error: declaration of âstatic void GPIO::write(int, int)â outside of class is not definition [-fpermissive]
/usr/local/include/wiringPi.h:177:21: error: declaration of C function âvoid __msleep(unsigned int)â conflicts with
/home/pi/Desktop/lolism/RF24/librf24-rpi/librf24/compatibility.h:26:6: error: previous declaration âvoid __msleep(int)â here
/usr/local/include/wiringPi.h:178:21: error: declaration of C function âvoid __usleep(unsigned int)â conflicts with
/home/pi/Desktop/lolism/RF24/librf24-rpi/librf24/compatibility.h:27:6: error: previous declaration âvoid __usleep(int)â here


Thanks in advance

gnulnulf
Posts: 32
Joined: Sat Oct 06, 2012 12:04 pm

Re: NRF24L01 RF Transceiver

Sat Jun 29, 2013 11:46 am

I noticed it to. I ran into a bug with the spi implementation.
If I have some spare time I will try to make the library with Wiring or Wiring aware.

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Sat Jun 29, 2013 1:20 pm

Thank you so much gnulf.
The main problem is that the "digitalRead" command is not supported by nrf and RF24 and spi libraries (though they support digitalWrite and pinMode() [strange enough].. for which I used wiringPi and .......

gnulnulf
Posts: 32
Joined: Sat Oct 06, 2012 12:04 pm

Re: NRF24L01 RF Transceiver

Sat Jun 29, 2013 1:57 pm

The nrf has two control lines. the spi chipselect and another chip select.
The first can be controlled by the hardware SPI, the second needs to be controlled using GPIO.
Because it's an output, only digitalwrite is needed. Pinmode is used to set is as an output pin.

Why do you need digititalread? For another part of your project?

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Sat Jun 29, 2013 4:06 pm

Thanks for replying......
actually, I am working on wireless transmission project between one nrf receiver and 6 transmitters. The receiver signals everyone to get activated when lights are on. So I need to check for the photoresistor input in order to see whether lights are on (from a gpio pin) for which I need digitalread(). I tried gpio commands for reading but the output says that digitalRead()/gpioR....() is not defined :(

Any suggestions about any other way I can take GPIO Inputs?? I usually write codes in C and C++. Thanks in advance

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Tue Jul 02, 2013 8:50 am

Dear gnulf,

Need your help in figuring out errors as mentioned in my previous post. Appreciate your help. Please spare some time. Thanks in advance. :oops:

gnulnulf
Posts: 32
Joined: Sat Oct 06, 2012 12:04 pm

Re: NRF24L01 RF Transceiver

Tue Jul 02, 2013 5:21 pm

@noob001: I see the problem, both compatibility and wiringPi claim functions like millis and pinMode.
I don't know why an io lib would need to define millis, others would question millis in compatibility 8-)

When wiringPi is nearly always installed we could try to use that as a standard IO lib.

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Tue Jul 02, 2013 6:16 pm

gnulnulf wrote:@noob001: I see the problem, both compatibility and wiringPi claim functions like millis and pinMode.
I don't know why an io lib would need to define millis, others would question millis in compatibility 8-)

When wiringPi is nearly always installed we could try to use that as a standard IO lib.
Thanks for replying. Could you please also tell me about the way I make the nrf24L01 modules work without using nrf24L01.h and RF24.h?? Wiringpi is awesome by itself (for input-output)
Can we modify the header files to our needs?? because some critical radio functions (related to nrf modules) are unique to nnrf24L01.h and RF24.h? thanks in advance for sparing your time.

liam_leee
Posts: 18
Joined: Mon May 27, 2013 9:45 am

Re: NRF24L01 RF Transceiver

Fri Jul 12, 2013 9:06 am

Hi guys,

I want to use the wireless module for Raspberry commucation with Arduino. My application is indoors, so i wonder if the NRF24L01 is not power enough if there is a wall between the Raspberry with Arduino :?

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Fri Jul 12, 2013 1:14 pm

liam_leee wrote:Hi guys,

I want to use the wireless module for Raspberry commucation with Arduino. My application is indoors, so i wonder if the NRF24L01 is not power enough if there is a wall between the Raspberry with Arduino :?
Dude, it more than enough for indoor applications upto 30 meters or so. (I have tested myself for distances up to 15 meters. So am pretty sure it supports upto 15 meters with in-built antenna)

liam_leee
Posts: 18
Joined: Mon May 27, 2013 9:45 am

Re: NRF24L01 RF Transceiver

Tue Jul 16, 2013 2:42 am

Hi Noob001, thanks. 30 meters is enough. So have you ever tested if there is some barrier between the two NRF24L01 commucation modules?

antpman
Posts: 1
Joined: Tue Jul 30, 2013 1:05 am

Re: NRF24L01 RF Transceiver

Tue Jul 30, 2013 1:17 am

Hi Liam,

I just found this topic and got RPi. While I haven't tried this yet with the RPi, I have used two NRF modules with Arduino to communicate. I live in a two story 2,000 sq ft house. I am able to communicate from the first story in a room on one corner of the house to the 2nd story opposite corner no problems. I have even put the receiving device in my garage (goes through two walls line of site) and have had no issues communicating. These were just tests though not solid day to day communication. I can't wait to try this with the RPi. Though I am a total beginner (very little Arch Linux experience). Thanks everyone in advance for the information contributed here.

Noob001
Posts: 7
Joined: Tue Jun 25, 2013 9:11 am

Re: NRF24L01 RF Transceiver

Tue Jul 30, 2013 6:56 am

If your nRF modules have an external antenna, then great. But even with an internal antenna, they are GREAT for smaller distances even with barriers present in between. (With each barrier the signal strength drops by around (4 dBm per concrete wall [to be verified again])).

pico
Posts: 16
Joined: Sun Sep 16, 2012 2:49 pm

Re: NRF24L01 RF Transceiver

Fri Aug 16, 2013 10:44 am

If you are interested in connecting Arduinos to a LAN or the Internet using nRF24L01+ and a Raspberry Pi, you might want to check out this site: http://embeddedcoolness.com

User avatar
vazquezjm
Posts: 11
Joined: Thu Aug 22, 2013 10:43 pm

Re: NRF24L01 RF Transceiver

Sun Sep 08, 2013 1:02 pm

Hi!

I have a simple question: can the same NRF24 module act as sender AND receiver when connected to an Arduino? I'm trying to figure that out, but most examples are based on an one-way configuration (sender -> receiver). I need to implement a bi-directional communication between an Arduino and Raspi.

Thank you!

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

Re: NRF24L01 RF Transceiver

Mon Sep 09, 2013 7:06 am

it can only do one at a time unfortunately. So this means, one has to be a listener, one a sender. But however the sender can listen after it has sent and the listener can then switch to send.

I have tried bi-directional and it is not 100% as messages will be lost when trying to initiate randomly from both sides.

gnulnulf
Posts: 32
Joined: Sat Oct 06, 2012 12:04 pm

Re: NRF24L01 RF Transceiver

Mon Sep 09, 2013 11:53 am

have your tried multiple connections? you can have multiple channels. If I recall correct only one sending..
You should always use a protocol with acknowlegdement if you want to be sure it was received. Just design with lost packages.

User avatar
vazquezjm
Posts: 11
Joined: Thu Aug 22, 2013 10:43 pm

Re: NRF24L01 RF Transceiver

Mon Sep 09, 2013 12:22 pm

Can you do that programatically? I mean, within a loop, can you switch from send to receive mode?

My idea (pseudocode):

Code: Select all

Loop
{
  setRxMode();
  receiveMsg();
  doSmthWithMsg();
  pause (1000ms?);
  setTxMode();
  prepareToSendMsg();
  sendMsg();
}

mstang1988
Posts: 3
Joined: Mon May 06, 2013 8:30 pm

Re: NRF24L01 RF Transceiver

Fri Sep 13, 2013 5:08 am

Having issues and need your help to debug as I'm at the limits of my skill.

I'm trying to communicate between a Raspberry Pi Rev 2.0 model B and an Arduino Uno 3.0. I'm using the standard software RF24 lib and not the bcm lib. I've gotten it to configure but can't seem to get the two to ping. The serial data is below.

I used the tutorial below for the pinouts. The exception is swaping the CE and CSN pins on the pi (per the updated code) and using 9 and 10 on the arduino, not the substituted 7 and 8. I am using the up to date versions of the code per the latest git repo's yesterday.
http://arduino-for-beginners.blogspot.c ... es-to.html

Any thoughts on how to debug this? I have another arduino on the way, I'm hoping to use that to see if I can get just the arduino's pinging.

Code: Select all



RF24/examples/pingpair/

ROLE: Pong back

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0xf0f0f0f0d2
RX_PW_P0-6	 = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
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

Code: Select all

[email protected]:~/RF24/librf24-rpi/librf24/examples# ./pingtest

RF24/examples/pingpair/
ROLE: Ping out
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 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
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_MAX
Now sending 363208402...failed.
Failed, response timed out.
Now sending 363209695...failed.
Failed, response timed out

Antivirusvivente
Posts: 130
Joined: Fri Dec 07, 2012 4:01 pm
Location: Bari
Contact: Website

Re: NRF24L01 RF Transceiver

Wed Sep 18, 2013 9:30 pm

Hello guys, i'm having some troubles using this code:
http://arduino-for-beginners.blogspot.i ... es-to.html
adapted with this one:
http://conoroneill.net/arduino-and-rasp ... 1-modules/

And using this one into the Pi:

Code: Select all

/* 
 *
 *  Filename : rpi-hub.cpp
 *
 *  This program makes the RPi as a hub listening to all six pipes from the remote 
 *  sensor nodes ( usually Arduino  or RPi ) and will return the packet back to the 
 *  sensor on pipe0 so that the sender can calculate the round trip delays
 *  when the payload matches.
 *  
 *  Refer to RF24/examples/rpi_hub_arduino/ for the corresponding Arduino sketches 
 * to work with this code.
 *  
 *  CE is connected to GPIO25
 *  CSN is connected to GPIO8 
 *
 *  Refer to RPi docs for GPIO numbers
 *
 *  Author : Stanley Seow
 *  e-mail : [email protected]
 *  date   : 4th Apr 2013
 *
 */

#include <cstdlib>
#include <iostream>
#include "../RF24.h"

using namespace std;

// Radio pipe addresses for the 2 nodes to communicate.
// First pipe is for writing, 2nd, 3rd, 4th, 5th & 6th is for reading...
// Pipe0 in bytes is "serv1" for mirf compatibility
const uint64_t pipes[6] = { 0x7365727631LL, 0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0E4, 0xF0F0F0F0E5 };

// CE and CSN pins On header using GPIO numbering (not pin numbers)
RF24 radio("/dev/spidev0.0",8000000,25);  // Setup for GPIO 25 CSN


void setup(void)
{
	//
	// Refer to RF24.h or nRF24L01 DS for settings
	radio.begin();
	radio.enableDynamicPayloads();
	radio.setAutoAck(1);
	radio.setRetries(15,15);
	radio.setDataRate(RF24_1MBPS);
	radio.setPALevel(RF24_PA_MAX);
	radio.setChannel(76);
	radio.setCRCLength(RF24_CRC_16);

	// Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading )
	radio.openWritingPipe(pipes[0]);
	radio.openReadingPipe(1,pipes[1]);
	radio.openReadingPipe(2,pipes[2]);
	radio.openReadingPipe(3,pipes[3]);
	radio.openReadingPipe(4,pipes[4]);
	radio.openReadingPipe(5,pipes[5]);

	//
	// Dump the configuration of the rf unit for debugging
	//

	// Start Listening
	radio.startListening();

	radio.printDetails();
	printf("\n\rOutput below : \n\r");
	usleep(1000);
}

void loop(void)
{
	char receivePayload[32];
	uint8_t pipe = 0;


	 while ( radio.available( &pipe ) ) {

		uint8_t len = radio.getDynamicPayloadSize();
		radio.read( receivePayload, len );

		// Display it on screen
		printf("Recv: size=%i payload=%s pipe=%i",len,receivePayload,pipe);

		// Send back payload to sender
		radio.stopListening();


		// if pipe is 7, do not send it back
		if ( pipe != 7 ) {
			// Send back using the same pipe
			// radio.openWritingPipe(pipes[pipe]);
			radio.write(receivePayload,len);

			receivePayload[len]=0;
			printf("\t Send: size=%i payload=%s pipe:%i\n\r",len,receivePayload,pipe);
  		} else {
			printf("\n\r");
                }

		// Enable start listening again
		radio.startListening();

	// Increase the pipe outside the while loop
	pipe++;
	// reset pipe to 0
	if ( pipe > 5 ) pipe = 0;
	}

	usleep(20);
}


int main(int argc, char** argv) 
{
	setup();
	while(1)
		loop();

	return 0;
}
but i cannot retrieve correct data, here's a picture:
https://www.dropbox.com/s/7o6gpp3bh5qniqh/err.jpg
DomoHome is coming! - RaspberryPi ~ Raspbian ~ Android
https://www.facebook.com/pages/Domohome/155791057916884

Return to “Add-ons”

Who is online

Users browsing this forum: No registered users and 6 guests