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

Re: NRF24L01 RF Transceiver

Mon Jan 28, 2013 6:32 pm

Hi everybody on this thread

I am very happy to see that others have the same idea about using nRF24.. as a link to Arduino. And that it indeed is possible :-)

As I read the posts until now, it is only possible for the Pi to have communication with one Arduino. I would like to have the Pi as a sort of "HUB" that gathers information from, and sends information to several Arduinos. I think one other mentioned that scenario.

Could these examples be modified to such a setup.

A few months ago i played around with some Arduinos, and only managed to establishing communication between two at time, as each sketch is programmed with a unit name and a name for the target. I did not manage to make a flexible way to have this target change, as would be nessesary for the "HUB", in this case the Pi.

Has anyone a solution, or an idea for a solution?

/Niels

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

Re: NRF24L01 RF Transceiver

Mon Jan 28, 2013 7:29 pm

when the addresses are in the same range I think it would be easy for 5 nodes.
I haven't tried it yet because I have only an rpi and an arduino.
My idea of the hub was to do something like the elektor bus protocol wireless.
Simple star networks should not be too hard. for meshed networks a workaround is to make a tree.
Full mesh is beyond my knowledge...

bertux
Posts: 6
Joined: Fri Jan 25, 2013 2:10 am

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 4:15 pm

I'm using nRF24L01+ too, what changes I need to do?

The code is https://github.com/gnulnulf/RF24 and the pins are
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)

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 = Model = CRC Length = PA Power = Now sending length 4...Failed, response timed out.
Now sending length 6...Failed, response timed out.
Now sending length 8...Failed, response timed out.


I see that the values are all 0x00. I don't know what I'm doing wrong...

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

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 4:29 pm

Are you sure it's connected correctly? What model rpi you have?

bertux
Posts: 6
Joined: Fri Jan 25, 2013 2:10 am

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 7:30 pm

I need change something for nRF24L01+?

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

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 8:16 pm

I also have the + version. The only way I get 0x0000 is to disconnect any the power/miso/mosi/sck lines.
If I remove the spi module I get another error.
Can you confirm the module is working on your arduino?

bertux
Posts: 6
Joined: Fri Jan 25, 2013 2:10 am

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 9:06 pm

I fix the error 0X000 now it's ok, but no response.
On the arduino the response is "yyyyyyyyyyyyyyyyyyyyyyy" , I think is some trash.

bertux
Posts: 6
Joined: Fri Jan 25, 2013 2:10 am

Re: NRF24L01 RF Transceiver

Tue Jan 29, 2013 9:07 pm

I'm usinig Rpi version B and Arduino Duemilanove.

Ac0lyte
Posts: 1
Joined: Mon Feb 04, 2013 6:23 am

Re: NRF24L01 RF Transceiver

Mon Feb 04, 2013 6:30 am

gnulnulf,

Many thanks!

The libs and info posted seem to have allowed me to get the nRF24L01+ connected to the rPi. So far I've just run the examples, but it finds the board w/o any issues. Next step is to connect one to an Arduino and make 'em talk.

For anyone who has issues where /dev/spi* were not in existence what worked for me was upgrading the firmware of the rPi ( see http://www.brianhensley.net/2012/07/get ... ry-pi.html ) and then mod probing spidev and spi-bcm2708

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

Re: NRF24L01 RF Transceiver

Tue Feb 05, 2013 6:39 pm

I have put a pongtest along with the pingtest in the github. Somehow the RF24-arduino part did not match the rpi part on git. I won't say it's perfect now but it seems to work in my setup.

Code: Select all

[email protected]:/usr/src/rf24-gnulnulf/RF24/librf24-rpi/examples# ./pingtest
RF24/examples/pingpair/
ROLE: Ping out
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         = 0x03
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_LOW
Now sending 2879849260...ok...Got response 2879849260, round-trip delay: 43
Now sending 2879850306...ok...Got response 2879850306, round-trip delay: 29
Now sending 2879851337...ok...Got response 2879851337, round-trip delay: 47
Now sending 2879852387...ok...Got response 2879852387, round-trip delay: 38

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

Re: NRF24L01 RF Transceiver

Wed Feb 06, 2013 1:55 pm

When you have a final working solution, can you put it in small tutorial together with the code (this is for arduino, this is for Pi).

You work is very appreciated.

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

Re: NRF24L01 RF Transceiver

Sat Feb 09, 2013 9:25 pm

Hi gnulnulf,

Thank you so much for this. I went the RF433 route and it proved very unreliable so have pinned all my hopes on this :)

Its probably a noob question but some assistance would be much appreciated. When I compile the library (on RPi) all is good:
~/librf24-rpi/librf24 $ make
But however when I try compile the the examples (on RPi):
~/librf24-rpi/examples $ make
I get an error:
/usr/bin/ld: cannot find -lrf24

Also the make file librf24-rpi makes the same error. I have tried lots of stuff like changing to -lRF24 (uppercase), using -L command etc but no success.

Thank you,

Dauhee

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

Re: NRF24L01 RF Transceiver

Sat Feb 09, 2013 10:17 pm

After make, do a make install

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

Re: NRF24L01 RF Transceiver

Sun Feb 10, 2013 9:11 am

perfect thanks bcatalin.

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

Re: NRF24L01 RF Transceiver

Sun Feb 10, 2013 11:04 am

Maybe its better to change the makefile to make lib, make libinstall and make examples... or cheat with a symbolic link ...
Ideas are welcome.

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

Re: NRF24L01 RF Transceiver

Mon Feb 11, 2013 9:19 am

With the following setup on arduino Leonardo and RPi

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

I don't see any traffic. It is strange that the RF_SETUP is 0x27 ( 250Kpbs and -0dBm) but the PA Power is showing PA_HIGH (-6dBm) and not PA_MAX (-0dBm) on both devices.

Also the library need to be changed a little bit, because the value for PA Power at one point is L(??)A_MED (this has no correspondence in datasheet).

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

Re: NRF24L01 RF Transceiver

Wed Feb 13, 2013 8:17 pm

In case there are any other noobs out there, I got the following error:

Code: Select all

RF24/examples/pingpair/
ROLE: Ping out
Segmentation fault
After calling ./pingtest

I enabled SPI by calling:

Code: Select all

sudo modprobe spi_bcm2708
sudo modprobe spidev
It still didn't work so I called sudo ./pingtest

modprobe additions need to be added after reboot also I believe

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

Re: NRF24L01 RF Transceiver

Wed Feb 13, 2013 9:27 pm

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

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

Re: NRF24L01 RF Transceiver

Wed Feb 13, 2013 9:29 pm

Within the same room pa_low seemed to work better.

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

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 9:26 am

After I've change the RF_SETUP register (date rate or power) I've noticed the same problem with communication between Arduino and Rpi.

So, I remove the 3.3 V from Pi and plug it back. This is working every time.

Also sometime even the Rpi is sending and the Arduino is replaying back I've :


Now sending 3623408229...ok...Failed, response timed out.
Now sending 3623409445...ok...Failed, response timed out.
Now sending 3623410661...ok...Failed, response timed out.

In order to solve this you need to add a small delay (I've added 5ms) in the while loop.
This delay need to be bigger then 2ms (the time for radio.available to produce a valid output

Code: Select all

    while ( ! radio.available() && ! timeout )
    {
     __msleep(5); //add a small delay to let radio.available to check payload
      if (__millis() - started_waiting_at > 200 )
        timeout = true;
    }
Now with this setup:

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         = 0x23
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 250KBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_LOW
Now sending 3624177587...ok...Got response 3624177587, round-trip delay: 34
Now sending 3624178624...ok...Got response 3624178624, round-trip delay: 33
Now sending 3624179660...ok...Got response 3624179660, round-trip delay: 34
Now sending 3624180697...ok...Got response 3624180697, round-trip delay: 33
Now sending 3624181733...ok...Got response 3624181733, round-trip delay: 33
Now sending 3624182769...ok...Got response 3624182769, round-trip delay: 34
Now sending 3624183806...ok...Got response 3624183806, round-trip delay: 33
I have a constant RTD with 33 or 34 ms.

Now is working also at 250kbs with RF_CONFIG 0x27 displaying PA_HIGH but is working
at PA_MAX (-0dBm). RTD 33ms. Nice.

Adding 5ms delay to let radio.available consuming the payload is fine for me.

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

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 5:50 pm

Should the wait be implemented in the library itself?

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

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 6:40 pm

No, just in ping example for Rpi. Library need to be modified to display correctly the content for RF_CONFIG register for + version. It displays PA_HIGH instead of PA_MAX if the value of register is 0xX7.

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

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 7:01 pm

Is it a bug in the original arduino lib, or some porting residue?

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

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 7:42 pm

It is just a display problem, nothing functional. It comes from arduino's library, I guess, but I will check.

matheusbrat
Posts: 1
Joined: Thu Feb 14, 2013 7:18 pm
Contact: Website

Re: NRF24L01 RF Transceiver

Thu Feb 14, 2013 7:44 pm

Hey guys,

I have been working on other Network Protocol based on RF24 library from Maniacbug. Using directly his library, or his RF24Network library is good for advanced users that must know who is communicating to who because some configurations are needed to get each peer talking to other.

RF24SH has a Protocol layer to ID/Parent/Channel distribution from the Master Station on a Generic Channel. The down point is, since we need to fix one channel the numbers of nodes connected to the network are limited to 254 but I prefer to say it is 250.

It is a under development library and I still have a lot of work to do, but the basic codes are working with examples.

It has support to Arduino/Teensy/RPi.

I tested it with 5 stations (1 master and 4 regular stations), I have plans to go with more node testing.

You can find more information on:
http://www.matbra.com/en/code/rf24sh-in ... as-coisas/

Please contact me with suggestions and question.
http://www.matbra.com

Return to “HATs and other add-ons”