ErriezNRF24L01Iface
1.0.0
هذه مكتبة Arduino ذات المستوى المنخفض المحسّن لقراءة وكتابة سجلات NRF24L01 (+) باستخدام واجهة SPI. يجب استخدامه في تركيبة مع فئة مشتقة تحتوي على وظائف القراءة والكتابة والتكوين العالية.
قم بتوصيل NRF24L01 (+) بأي لوحة Arduino التي تحتوي على:
قد تحدث إعادة الإرسال أو فقدان الاتصال عند توصيل NRF24L01 مباشرةً إلى 3.3 فولت من لوحة Arduino ، لأن الكثير من ألواح Arduino لا يمكنها تقديم طاقة كافية لرقاقة NRF24L01. يمكن حل ذلك باستخدام منظم جهد منفصل ، أو محول الطاقة NRF24L01.
جهاز استقبال لاسلكي NRF24L01 NRF24L01 أو NRF24L01 (+)
لزيادة موثوقية الاتصال ، استخدم محول الطاقة NRF24L01 مع منظم جهد سعة 3.3 فولت ، مثل:
| 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 (+) واجهة | registerAccess
يجب التحكم في دبوس 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);