nielsoe
Posts: 4
Joined: Mon Jan 28, 2013 3:36 pm

Nooob question

Wed Feb 27, 2013 5:00 pm

Hi All

As I realize im a noob in programming o Linux I have tried to sort things out, but ended out more confused.
I have quite some experience from programming Arduino. I have also had a few programs running in Python. I guess my problem lies in understanding how to setup Linux libraries, make-files etc. Hope someone can help me sort out the problems.

Have installed the RF24 librariaris via git, and tried to compile the examples (I suppose that is what make does). But i had a lot of warnings and a few errors. I guess a successfull compilations results in executable files- where would these be placed, how would I be able to tell if it succeeded? Then I guess it would be easy to execute...

As the files are .cpp i guess it is C++. How does it fit into Python? Will it be possible to control the nrf24.. from a Python program?

I guess that what im asking for is a short explanation of what is in the library, and what is needed to utilise it..

Kind regards
Niels

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

Re: Nooob question

Wed Feb 27, 2013 7:09 pm

nielsoe wrote: I have quite some experience from programming Arduino. I have also had a few programs running in Python. I guess my problem lies in understanding how to setup Linux libraries, make-files etc. Hope someone can help me sort out the problems.

As the files are .cpp i guess it is C++. How does it fit into Python? Will it be possible to control the nrf24.. from a Python program?
Niels
Look at the Makefile, it determine where the binary / executable files are compiled and linked into binary files for execution...

To use it with other programs ( python, perl, bash,etc) , you use like just like any other unix programs, you can display it to standard output and pipe "|" it to another program or write the receive sensor readings directly to a file for further processing... anything you can do with unix/linux...

Or have yr python to execute that binary to send/receive data to the RF modules...
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

nielsoe
Posts: 4
Joined: Mon Jan 28, 2013 3:36 pm

Re: NRF24L01 RF Transceiver

Wed Feb 27, 2013 8:37 pm

Im not sure what to do. I might be asking for some obvious things - so pardon me.

The makefile looks like this:

Code: Select all

all: librf24 examples

librf24:
	$(MAKE) -C librf24 all

examples:
	$(MAKE) -C examples


clean: 
	$(MAKE) -C librf24 clean
	$(MAKE) -C examples clean

install: 
	$(MAKE) -C librf24 install
	$(MAKE) -C examples install

.PHONY:  all install  librf24 examples
Im not sure where and how it is stated where the executables should be put?
When I run the makefile, I get this output (my OS language is set to Danish):

Code: Select all


[email protected] ~/RF24/librf24-rpi $ make all
make -C librf24 all
make[1]: GÃ¥r til katalog '/home/pi/RF24/librf24-rpi/librf24'
g++ -shared -Wl,-soname,librf24.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s  -o librf24.so.1.0 compatibility.o gpio.o spi.o RF24.o
make[1]: Forlader katalog '/home/pi/RF24/librf24-rpi/librf24'
make -C examples
make[1]: GÃ¥r til katalog '/home/pi/RF24/librf24-rpi/examples'
g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -L../librf24/  -lrf24 scanner.cpp -o scanner
../librf24/compatibility.h:18:23: warning: âstartâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:18:30: warning: âendâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:13: warning: âmtimeâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:20: warning: âsecondsâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:29: warning: âusecondsâ defined but not used [-Wunused-variable]
/usr/bin/ld: cannot find -lrf24
collect2: ld returned 1 exit status
make[1]: *** [scanner] Fejl 1
make[1]: Forlader katalog '/home/pi/RF24/librf24-rpi/examples'
make: *** [examples] Fejl 2
[email protected] ~/RF24/librf24-rpi $
Any idea what I can do? I feel im running out of ideas..

/Niels

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

Re: NRF24L01 RF Transceiver

Thu Feb 28, 2013 3:46 pm

I assume you are using this source :- https://github.com/gnulnulf/RF24

This code is using shared libraries...

cd librf24-rpi/librf24 <-- where all the libraries and headers are stored...
make
sudo make install <-- install the shared libraries into yr /usr/local/lib folder
cd ../examples
make

Yr binaries should be linked with the shared libraries installed above...

I'm still getting the compatibility warnings....

[edit] In the Makefile line 28, remove -Wall ( remove all warnings ) to get rid of the above warnings...

Code: Select all

[email protected] ~/RF24/librf24-rpi $ make all
make -C librf24 all
make[1]: GÃ¥r til katalog '/home/pi/RF24/librf24-rpi/librf24'
g++ -shared -Wl,-soname,librf24.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s  -o librf24.so.1.0 compatibility.o gpio.o spi.o RF24.o
make[1]: Forlader katalog '/home/pi/RF24/librf24-rpi/librf24'
make -C examples
make[1]: GÃ¥r til katalog '/home/pi/RF24/librf24-rpi/examples'
g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -L../librf24/  -lrf24 scanner.cpp -o scanner
../librf24/compatibility.h:18:23: warning: âstartâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:18:30: warning: âendâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:13: warning: âmtimeâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:20: warning: âsecondsâ defined but not used [-Wunused-variable]
../librf24/compatibility.h:19:29: warning: âusecondsâ defined but not used [-Wunused-variable]
/usr/bin/ld: cannot find -lrf24
collect2: ld returned 1 exit status
make[1]: *** [scanner] Fejl 1
make[1]: Forlader katalog '/home/pi/RF24/librf24-rpi/examples'
make: *** [examples] Fejl 2
[email protected] ~/RF24/librf24-rpi $
Last edited by stanley on Thu Feb 28, 2013 5:25 pm, edited 2 times in total.
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

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

Re: NRF24L01 RF Transceiver

Thu Feb 28, 2013 4:37 pm

The PA power , the display output was wrong spelling/error ...that all...

I found the error, in file RF24.cpp line 307 to 310

static const char rf24_pa_dbm_e_str_0[] PROGMEM = "PA_MIN";
static const char rf24_pa_dbm_e_str_1[] PROGMEM = "PA_LOW";
static const char rf24_pa_dbm_e_str_2[] PROGMEM = "LA_MED";
static const char rf24_pa_dbm_e_str_3[] PROGMEM = "PA_HIGH";

You can change them to below to fix it...

static const char rf24_pa_dbm_e_str_0[] PROGMEM = "PA_MIN";
static const char rf24_pa_dbm_e_str_1[] PROGMEM = "PA_LOW";
static const char rf24_pa_dbm_e_str_2[] PROGMEM = "PA_HIGH";
static const char rf24_pa_dbm_e_str_3[] PROGMEM = "PA_MAX";

dauhee wrote:I'm getting a hit rate of about 1 in 100 messages being received. Using the following after having changed a number of channels:

RF24/examples/pingpair/
ROLE: Pong back
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
PA Power = PA_HIGH

I even have the RPi and Arduino and its still unreliable - I can get a 1 in 2 response rate by holding both the chips close. Just wondering has anybody else had intermittent issue such as this? I might try 2 arduinos and see what the hit rate is there. I'm also reading PA_HIGH after specifying PA_MAX
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 10:12 am

Hello everybody,

I am trying to port a NRF24 Library to Pi, all code seems to be fine except that is not working, so I double checked my wiring and then found this thread. Thanks god !!

You said that the connection between Pi and NRF should be as follow

Code: Select all

nrf-vcc = rpi-3v3 (1)
nrf-gnd = rpi-gnd (6)
nrf-ce = rpi-ce0 (24)
nrf-csn = rpi-gpio25 (22)
nrf-sck = rpi-sckl (23)
nrf-mo = rpi-mosi (19)
nrf-mi = rpi-miso (21)
but the datasheet of NRF24L01 says nrf-csn is the SPI Chip Select, and for my understanding SPI Chip Select on Pi side is CE0 (or CE1 ) so my question is should the wiring be as follow ?

Code: Select all

nrf-vcc = rpi-3v3 (1)
nrf-gnd = rpi-gnd (6)
nrf-ce = rpi-gpio25 (22) 
nrf-csn = rpi-ce0 (24) SPI Chip Select
nrf-sck = rpi-sckl (23)
nrf-mo = rpi-mosi (19)
nrf-mi = rpi-miso (21)
Thanks to confirm me which wiring is correct ?

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

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 11:39 am

I am using :

Code: Select all

nrf-vcc = rpi-3v3 (1)
nrf-gnd = rpi-gnd (6)
nrf-ce = rpi-ce0 (24)
nrf-csn = rpi-gpio25 (22)
nrf-sck = rpi-sckl (23)
nrf-mo = rpi-mosi (19)
nrf-mi = rpi-miso (21)
on a first revision model B. In my setup I've connected GND to pin 25 on GPIO (a GND pin).

Verify with lsmod that you have spi_bcm2708 loaded.

Do you have any errors ? How do you config the NRF ? Are both on the same channel?

This is my configuration

Code: Select all

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         = 0x27
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 250KBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_MAX

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 12:40 pm

Ok thanks for your reply

My NRF is connected to SPI0.1 and gpio 22

gpio 22 Pi goes to CE
CE1 goes to CSN

then changed the code in scanner.cpp

Code: Select all

RF24 radio("/dev/spidev0.1",8000000 , 22);  //spi device, speed and CSN,only CSN is NEEDED in RPI
compiled, linked fine, when I launch, seems to have no values

Code: Select all

RF24/examples/scanner/
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
000000000000000011111111111111112222222222222222333333333333333344444444444444445555555555555555666666666666666677777777
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
tonight I will try to reverse CSN and CE pin to be like you, so strange

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

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 2:21 pm

My NRF is connected to SPI0.1 and gpio 22
gpio 22 Pi goes to CE
CE1 goes to CSN
then changed the code in scanner.cpp

Code: Select all

RF24 radio("/dev/spidev0.1",8000000 , 22);  //spi device, speed and CSN,only CSN is NEEDED in RPI
Make sure that :-
CSN is connected to the second number ( GPIO22 ) in yr case...
CE is connected to GPIO8 ( Pin 24 )

*** Both me and gnulnulf decide to use GPIO25 for the CSN for all codes in the examples folder...

The combined Arduino & RPi libs are at :-
https://github.com/stanleyseow/RF24

Setup instructions at : http://arduino-for-beginners.blogspot.c ... es-to.html
Last edited by stanley on Wed Mar 06, 2013 4:09 pm, edited 1 time in total.
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

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

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 3:11 pm

I am using

Code: Select all

RF24 radio("/dev/spidev0.0",8000000 , 25);
Charly86 wrote:Ok thanks for your reply

My NRF is connected to SPI0.1 and gpio 22

gpio 22 Pi goes to CE
CE1 goes to CSN

then changed the code in scanner.cpp

Code: Select all

RF24 radio("/dev/spidev0.1",8000000 , 22);  //spi device, speed and CSN,only CSN is NEEDED in RPI
compiled, linked fine, when I launch, seems to have no values

Code: Select all

RF24/examples/scanner/
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
000000000000000011111111111111112222222222222222333333333333333344444444444444445555555555555555666666666666666677777777
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
tonight I will try to reverse CSN and CE pin to be like you, so strange

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 3:45 pm

Thanks Stanley

Got it; I will try this.

So, as far as I understand, if you connect CSN to a GPIO pin, this means that you drive the CSN (so the GPIO) pin manually into the Library and not using the hardware Chip Select pin from the PI ?

Is that correct ?

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

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 4:13 pm

Here is my working pinout :-


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)

Pls refer to the pinout with functions below :-
Image
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Wed Mar 06, 2013 10:54 pm

Stanley

Amazing, I did this connection on the PI
then
git-clone https://github.com/stanleyseow/RF24.git
then build all from scratch and launched rpi-hub
here my results

Code: Select all

STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0x0e0e0e0e0e 0x0e0e0e0e0e
RX_ADDR_P2-5     = 0x0e 0x0e 0x0e 0x0e
TX_ADDR          = 0x0e0e0e0e0e
RX_PW_P0-6       = 0x0e 0x0e 0x0e 0x0e 0x0e 0x0e
EN_AA            = 0x0e
EN_RXADDR        = 0x0e
RF_CH            = 0x0e
RF_SETUP         = 0x0e
CONFIG           = 0x0e
DYNPD/FEATURE    = 0x0e 0x0e
Data Rate        = 2MBPS
Model            = nRF24L01
CRC Length       = 16 bits
PA Power         = PA_MAX

Output below :
tried with 2 modules, same things, it drives me nuts !!!

So if it is working for you, is it possible to provide me these 3 files just to be sure I have the correct files and configuration.
the library compiled for Pi (*.so.1)
the rpi_hub compiled for Pi
the arduino file rpi_hub_arduino.pde ?

Thank you for your help, if fact there is so much files, repos and different config that I am a little lost.

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

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 3:34 am

Charly86 wrote:Stanley
git-clone https://github.com/stanleyseow/RF24.git

tried with 2 modules, same things, it drives me nuts !!!

So if it is working for you, is it possible to provide me these 3 files just to be sure I have the correct files and configuration.
the library compiled for Pi (*.so.1)
the rpi_hub compiled for Pi
the arduino file rpi_hub_arduino.pde ?

Thank you for your help, if fact there is so much files, repos and different config that I am a little lost.
If you compile without errors, the binary should be identical since the source codes are identical..

I suggest the following steps :-

1. tail -f /var/log/messages ( make sure no errors are occurring )

2. make sure you supply enough power to the RPi ( most common issues with the Pis.... )

3. pull out all the jumpers wires and start over, pin by pin...

When I switched from older static codes to the github codes, I did not notice the CE pin was changed from GPIO23 to GPIO8 and spend a lot of time banging on the codes when the problem was a different pinout!!!!

Did the nRF24L01 works on the Arduino side... ?

If you installed the RF24 libs, it is located at
examples/RF24 folder
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 3:58 pm

Stanley

I just saw that gnulnulf has accepted your fork on github, so done from scratch

I done a git clone https://github.com/gnulnulf/RF24.git (Under a new folder)

then make, make install, triple checked pins connection and issue a rpi-hub just to see if the config displayed is correct. (the arduino side if off for now)
my device is a NRF24L01+
build from scratch without changing any code. Take a look at the output, the Data Rate should be 1MBPS and show me 2MBPS

Code: Select all

STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0x0e0e0e0e0e 0x0e0e0e0e0e
RX_ADDR_P2-5     = 0x0e 0x0e 0x0e 0x0e
TX_ADDR          = 0x0e0e0e0e0e
RX_PW_P0-6       = 0x0e 0x0e 0x0e 0x0e 0x0e 0x0e
EN_AA            = 0x0e
EN_RXADDR        = 0x0e
RF_CH            = 0x0e
RF_SETUP         = 0x0e
CONFIG           = 0x0e
DYNPD/FEATURE    = 0x0e 0x0e
Data Rate        = 2MBPS
Model            = nRF24L01
CRC Length       = 16 bits
PA Power         = PA_MAX

Output below :
Do you think you can show me what is your output code when you build from scratch from the same repo and just run rpi-hup to show config ?

Hey, you know what it is a Pi V2 I will check on a V1 just to verify !!

Thanks

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 4:36 pm

Stanley,

I decided to go in the code and something is strange for me and that I do not understand. Lot of time in the NRF24 Library code the ce pin is driven low or high by ce(LOW); or ce(High); right ?

But when invoking the NRF24 instance in rpi-hub like this

Code: Select all

RF24 radio("/dev/spidev0.0",8000000,25);
the ce_pin Library variable is not set up and initialized by 0
I confirmed this by putting a printf in begin

Code: Select all

void RF24::begin(void)
{
  // Initialize pins
  pinMode(ce_pin,OUTPUT);
  pinMode(csn_pin,OUTPUT);

  printf_P(PSTR("ce=%d   cs=%d\n"), ce_pin, csn_pin);

....
So the Library is driving a wrong I/O and connecting ce pin to another I/O can be uneffective because this IO can be in or out because uninitialized. So from my point of view, leaving CE un-connected could also have wrong side effect.

I will try to modifiy the lib and instantiate the RF24 with ce AND csn, what do you think ?

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

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 5:02 pm

Hmmm... good point.
when removing all the ce() it still works..

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 5:17 pm

Wahou, that's amazing !!!

datasheet says CE is used to enable Receive or Transmit mode so I do not understand how it is possible to change the mode (receive or transmit) of the NRF24L01 without changing from high to low and/or low to high this pin. :roll:

Did you tried both mode on Pi (Send and Receive) by trying with ./ping_server and ./ping_client ?

kinda some magic Inside ...

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

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 6:05 pm

send/receive refers to the spi send/receive, not the wireless part.
On the pi CE is controlled by the spidev0.N device.

[email protected]:/usr/src/rf24-gnulnulf/RF24# /opt/librf24-examples/bin/pongtest

RF24/examples/pingpair/
ROLE: Pong back
SPI device = /dev/spidev0.0
SPI speed = 8000000
CSN GPIO = 25
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 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
Got payload 3698...Sent response.
Got payload 4784...Sent response.

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

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 6:36 pm

Charly86 wrote:Stanley
Do you think you can show me what is your output code when you build from scratch from the same repo and just run rpi-hup to show config ?

Hey, you know what it is a Pi V2 I will check on a V1 just to verify !!
Yes , we merge the codes so both the repos are identical...

Here is link screenshot so others do not need to load the image...
http://4.bp.blogspot.com/-cLPkEh5aAdc/U ... enshot.png
Stanley
blog :- http://arduino-for-beginners.blogspot.com/
fb group :- https://www.facebook.com/groups/arduino.for.beginners/

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 8:02 pm

Ok this is more clear. On the pi ce0 and ce1 are driven by spi hardware. For what i understand For exemple ce0 is used as chip sélect for spi device. That is what i do for spi oled and it is working fine. Ce0 is connected to spi oled chip sélect. Is that make sense to you ?

So now what do i not understand is why ce0 or ce1 is not going to CSN of nrf ? This mean that ce of nrf is the réal chip sélect ?

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

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 9:10 pm

correct.
ce on the nrf goes to GPIO8(CE0) for /dev/spidev0.0 or GPIO7(CE1) for /dev/spidev0.1
CSN goes to a normal IO pin.

(I still don't know why one would use more then one control pin on an spi device.... except for an interrupt pin)

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Thu Mar 07, 2013 9:44 pm

Thanks, that was what i suspected.
So the hardware of the pi ce1 or ce0 drive ce pin of nrf (pulling it low when accessing the spi device) and in the NRF24 lib the code does the same with CSN before and after each spi transfert. Make me so perplex because that is not what is said in the datasheet. But i Will Check on my nrf breakout board that the pin connector labeled ce goes really to ce chip pin.

Charly86
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am

Re: NRF24L01 RF Transceiver

Tue Mar 12, 2013 2:14 pm

Ok guys,

I decided to start from scrach with 2 arduino.
I tried 2 libraries with no success, this one and the NRF24. But I will focus on this one.
In fact I just tried from one arduino and got I timeout on the sendpacket with sample sktech GettingStarted.pde
At startup I got the NRF information correctly displayed such as Type, Speed, the RX address, .. (by the printDetails ()) so SPI Dialog with NRF seems good, but when I launch the pde, when I toggle mode to be sender I got I timeout delay (tried to put 1s instead of 500ms timeout also) when the write method is called and check if the packet was correctly sent, I have no response from device that it was sent and the write method always return false.
I tried with different modules and 2 arduino boards, same problem.
Does someone has already encounter this problem ? it drive me crazy !!!! I triple checked connection and seems good because the informations are correct when the printDetails is displayed

Any help would be appreciated.

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

Re: NRF24L01 RF Transceiver

Tue Mar 12, 2013 7:58 pm

After reading the datasheet again i'm puzzled too... it works.... but the ce and csn are connected wrong on the rpi...

Return to “HATs and other add-ons”