参考https://shumeipai.nxez.com/2017/03/20/communication-between-arduino-and-raspberry-pi.html
nRF2401代码下载git clone https://github.com/nRF24/RF24.git
arduino端代码没什么问题.
树莓派端:
1. Raspberry Pi Model B Rev 2 版本需要修改代码:
RF24 radio(22, 0); 替换为:
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
sudo ./gettingstarted
sudo: unable to resolve host rpi-b: Name or service not known
RF24/examples/GettingStarted/
================ SPI Configuration ================
CSN Pin = CE0 (PI Hardware Driven)
CE Pin = Custom GPIO22
Clock Speed = 8 Mhz
================ NRF Configuration ================
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x65646f4e32 0x65646f4e31
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0x70
TX_ADDR = 0x65646f4e32
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x40
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN
心得:关键是spi 的CE和CSN信号.根据提示nRF2401板的CSN信号连接Pi的CE0 , 根据提示nRF2401板的CE信号连接Pi的GPIO22
来源:oschina
链接:https://my.oschina.net/yuxitao/blog/3192010