ErriezNRF24L01Iface
1.0.0
이것은 SPI 인터페이스를 사용하여 NRF24L01 (+) 레지스터를 읽고 쓰는 최적화 된 저수준 Arduino 라이브러리입니다. 더 높은 레벨 읽기, 쓰기 및 구성 기능을 포함하는 파생 클래스와 함께 사용해야합니다.
NRF24L01 (+)을 포함 된 Arduino 보드에 연결하십시오.
많은 Arduino 보드가 NRF24L01 칩에 충분한 전력을 제공 할 수 없기 때문에 NRF24L01을 Arduino 보드의 3.3V에 직접 연결할 때 재전송 또는 통신 손실이 발생할 수 있습니다. 이는 별도의 전압 조절기 또는 NRF24L01 전력 어댑터로 해결할 수 있습니다.
북유럽 NRF24L01 또는 NRF24L01 (+) 2.4GHz 무선 트랜시버는 별도의 3.3V 전압 조절기와 100UF ELCO를 갖춘 Arduino UNO 보드에 연결된 무선 트랜시버 :
통신 신뢰성을 높이려면 다음과 같은 별도의 3.3V 전압 조정기가 장착 된 NRF24L01 전원 어댑터를 사용하십시오.
| NRF24L01+ 핀 | NRF24L01+ 기능 | NRF24L01+ 어댑터 | Arduino Uno/Mini | Mega2560 | ESP8266 Nodemcu |
|---|---|---|---|---|---|
| +3.3v | 3.3V 직접 | - | 3.3v | 3.3v | 3.3v |
| - | 어댑터를 통해 +5V | +5V | +5V | +5V | - |
| 1 | Gnd | Gnd | Gnd | Gnd | Gnd |
| 3 | CE | CE | 7 | 7 | D0 |
| 4 | CSN | CSN | 8 | 8 | D8 |
| 6 | 모시 | 모 | 11 | 51 | D7 |
| 7 | 된장 | 미 | 12 | 50 | D6 |
| 5 | SCK | SCK | 13 | 52 | D5 |
NRF24L01 (+) 인터페이스 | 레지스터 액세스
CE 핀은 파생 클래스 내에서 제어해야합니다.
다음 라이브러리가 사용됩니다.
# include < nRF24L01Iface.h > class nRF24L01Example : nRF24L01Iface
{
public:
// Constructor, initialize base class with SPI clock and SPI chip-select
nRF24L01Example ( uint32_t spiClock, uint8_t cePin, uint8_t csnPin) :
nRF24L01Iface (spiClock, csnPin),
_cePin (cePin)
{
};
// Read status register
uint8_t readStatus () {
// Read status register
return readRegister (REG_STATUS);
}
// Read from config register
uint8_t readConfig () {
// Read config register
return readRegister (REG_CONFIG);
}
// Write to config register
void writeConfig ( uint8_t val) {
// Write to config register
writeRegister (REG_CONFIG, val);
}
// Write to TX pipe (0) registers
void openWritePipe0 ( const uint8_t *address) {
// Write 5 Bytes transmit pipe
// Now pipe 0 cannot be used for receive
writeRegister (REG_TX_ADDR, address, 5 );
}
// More functions such as read and write
// ...
private:
uint8_t _cePin;
}; // CE pin to enable RX and TX modes
# define CE_PIN 7
// SPI chip select pin
# define CSN_PIN 8
// Create object and initialize with SPI clock, CE pin and SPI chip-select pin
static nRF24L01Example radio (( uint32_t )10000000UL, CE_PIN, CSN_PIN); // Read status register
uint8_t status = radio.readStatus();
// Read from config register
uint8_t config = radio.readConfig();
// Write to config register
radio.writeConfig( 0x08 );
// Define an address pipe for transmit
const uint8_t pipeAddress[ 5 ] = { 0x55 , 0xa5 , 0x5a , 0xaa , 0x99 };
// Configure write pipe0
radio.openWritePipe0(pipeAddress);