ADVERTISEMENT
Using NRF24l01 in hobby projects helps to make things wireless. I was using it with arduinos and was using one arduino attached to raspberry pi as the hub for various sensors used in home automation so that they can communicate with the raspberry pi and hence to the internet. So i just did a quick test to run the nrf module directly on the pi. There were plenty of documentations out there and i was a bit over whelmed.
So here is a pi-nrf24 gymnastic to test the things out on the weekend (see figure ). Every thing is hanging on the wall for a quick test. I used the latest build of raspbmc (as my primary use of the pi is for watching media). There are special software like Occidentalis which is specifically made for easy i2c, spi etc (from Adafruit)
I used Raspbmc and the first step was to get the SPI working and was pretty easy with the latest build. But for some reasons i need to use the following commands to make the spi up and running. So just type the code below before doing more experiments with SPI on raspbmc
A bit more on spi getting up on Pi can be read here ( very nice article by Brian). In the next step i downloaded the rf24 library for raspberry pi and can be accessed on git hub at here. To make it simple i have a fork of the part needed for the raspberry pi at here
So ssh in to the pi and issue the following commands to compile it on the pi
If everything went fine, you can hook up your pi with nrf module. You can do it nicely but it is also possible to follow my gymnastic way as shown above/below
To see the pins on the nrf module you can see this post. The gpio pins on the pi can be identified as follows
Connect the module as follows
To test cd to examples folder and run the scanner (sudo ./scanner) and it should show the rf signals around on different channels.
As a starting point, it may be easier to test a wifi scanner on the pi as described in this post, which will ensure that the module is working and connected properly (with a single module)
PIN Connections
So here is a pi-nrf24 gymnastic to test the things out on the weekend (see figure ). Every thing is hanging on the wall for a quick test. I used the latest build of raspbmc (as my primary use of the pi is for watching media). There are special software like Occidentalis which is specifically made for easy i2c, spi etc (from Adafruit)
Gymnstics with raspberry pi and nrf24l01 |
sudo boblightd --help
A bit more on spi getting up on Pi can be read here ( very nice article by Brian). In the next step i downloaded the rf24 library for raspberry pi and can be accessed on git hub at here. To make it simple i have a fork of the part needed for the raspberry pi at here
So ssh in to the pi and issue the following commands to compile it on the pi
git clone https://github.com/riyas-org/rf24pi
cd rf24pi
make
sudo make install
If everything went fine, you can hook up your pi with nrf module. You can do it nicely but it is also possible to follow my gymnastic way as shown above/below
Raspberry pi as nrf240l hub for wireless sensors |
GPIO piout on raspberry pi for spi |
Connect the module as follows
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 3.3V (Pin 17) to RF Module Pin 2 ( VCC/3.3V )
RPi Gnd (Pin 25) to RF Module Pin 1 (GND)
RPi GPIO 25 (Pin 22) to RF Module Pin 3 ( CE )
RPi GPIO8 (Pin 24) to RF Module Pin 4 ( CSN )
To test cd to examples folder and run the scanner (sudo ./scanner) and it should show the rf signals around on different channels.
As a starting point, it may be easier to test a wifi scanner on the pi as described in this post, which will ensure that the module is working and connected properly (with a single module)
PIN Connections
Connecting NRF24l01 module to the pi (Rev2 board) |
The last two lines are not correct:
ReplyDeleteRPi GPIO8 (Pin 24) to RF Module Pin 3 ( CE )
RPi GPIO 25 (Pin 22) to RF Module Pin 4 ( CSN )
The correct forms are:
RPi GPIO 25 (Pin 22) to RF Module Pin 3 ( CE )
RPi GPIO8 (Pin 24) to RF Module Pin 4 ( CSN )
I should've read the comments earlier. I was breaking my head on this strange gpio8 to ce connection, did not make sense.
DeleteI tried what you proposed and that seems to work!
Thanks for pointing it. Now i have fixed it
Deletei've been looking info on conecting rf24 and making it work to cubieboard since it has a faster processor than rpi, is there anyone to help on this task?
ReplyDeleteWill defenitely try when i get hold of a cubie
Deletethere is no scanner file
ReplyDeleteYou get it after compiling the scanner.cpp (source code) without any errors
Deletecd rf24pi
make
sudo make install
Good lucjk with the project!
Is it natural for it to get really hot?
ReplyDeleteNop.. 5volt can damage it. Make sure it is connected to 3.3v
DeleteAhhh darn, ok thanks.
DeleteI had a lot of difficulty on this on an older Pi (2011). It looks like there might have been a change in SPI for the Pi2. I pulled an older Wheezy image on my old Pi (from May 5) and it works fine. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=99227 I was stuck with "can't send spi message: Invalid argument". I think I could confirm by checking the parameters in the kernel headers... but I'm happy that it works for now. thanks!
ReplyDeletewhoops, my Raspbian image from the previous comment was Jan 2014.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHello, i ´m just playing with arduino and raspberry and nrf
ReplyDeleteif i use 2 arduino send and to receive is ok.
but if i want to use raspberry it don´t work. on logic analyser i can at least see that spi is working. ping and pong test don´t bring good result.
arduion nrf setting
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 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_HIGH
Raspberry nrf setting
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 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
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 3372907972...failed.
Failed, response timed out.
If i use scanner i get this:
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 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
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
000000000000000011111111111111112222222222222222333333333333333344444444444444445555555555555555666666666666666677777777
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
if i use nrf24scannerPi
Channel Layout
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <
| :WWWRWW: :: |5
| RW-++R*. * |6
| -*-*+*WR . |6
| -= WWWW* ... -..... |10
| :: W+RR= .: |7
| :: **RW= |5
| : Waaa+ W |4
who can help?
thanks