nRF24L01+ Module Documentation

nRF24L01+

Library

Arduino Library Download
Copy to ‘Libraries’ folder within your main Arduino folder.

Pins:

MISO -> 12
MOSI -> 11
SCK -> 13

Configurable:

CE -> 8
CSN -> 7

Properties:

byte cePin
CE Pin controls RX / TX, default 8.

byte csnPin
CSN Pin (Chip select not), default 7.

byte channel
RF Channel 0 – 127 or 0 – 84 in the US, default 0.

byte payload
Size in bytes, default 16, max 32.
Note: channel and payload must be the same for all nodes.

Methods:

void init(void)
Initialize the module, set the pin modes for the configurable pins and initialize the SPI module.
Example:
Mirf.csnPin = 9;
Mirf.cePin = 7;
Mirf.init();
void setRADDR(byte *addr)
Set the receiving address. Addresses are 5 bytes long.
Example:
Mirf.setRADDR((byte *)"addr1");
void setTADDR(byte *addr)
Set the sending address.
Example:
Mirf.setTADDR((byte *)"addr1");
void config(void)
Set channel and payload width. Power up in RX mode and flush RX fifo.
Example:
Mirf.payload = 32;
Mirf.channel = 2;
Mirf.config();
bool dataReady(void)
Is there data ready to be received?.
Example:
if(Mirf.dataReady()){
//Get the data to play with.
}
void getData(byte *data)
Get the received data. 'data' should be an array of bytes Mirf.payload long.
Example:
byte data[Mirf.payload]
Mirf.getData(data);
void send(byte *data)
Send data. 'data' should be Mirf.payload bytes long.
bool isSending(void)
Return true if still trying to send. If the chip is still in transmit mode then this method will return the chip to receive mode.
Example:
Mirf.send(data);
while(Mirf.isSending()){
//Wait.
}
//Chip is now in receive mode.
NB: Lots more information is available from the status registers regarding acknowledgement or failure status. See Mirf.cpp:218.
bool rxFifoEmpty(void)
Is the RX Fifo Empty.
bool txFifoEmpty(void)
Is the TX Fifo Empty.
byte getStatus(void)
Return the status register.
void powerUpRx(void)
Power up chip and set to receive mode. Also clear sending interrupts.
void powerUpTx(void)
Power up tx mode.
Exa

Examples

See examples folder in zip file.
Arduino Library Download

Advertisements

What's The Word?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: