This is a work in progress for an NRF2401P

Dependents:   NRF_receiver sender locker4 Weather_Station_Ofiicial ... more

About

This is a simple library to drive the nRF24l01+.

Hardware

This uses the commonly available breakout. The connections are shown below /media/uploads/epgmdm/nrf24l01pinout.png

Software

Use case: For a simple transmitter

tx code snipet

#include "NRF2401P.h"
int main() {
*
*  long long addr1=0xAB00CD; // setup address - any 5 byte number - same as RX
*  int channel =0x12;  // [0-126] setup channel, must be same as RX
*  bool txOK;
*  char msg[32];
*  char ackData[32];
*  char len;
*
*  // Setup 
*  NRF2401P nrf1(PTD6,PTD7, PTD5,PTD4, PTC12); //mosi, miso, sclk, csn, ce)
*  nrf1.quickTxSetup(channel, addr1); // sets nrf24l01+ as transmitter
*
*  // transmit
*  strcpy (msg, "Hello"); 
*  txOK= nrf1.transmitData(msg,strlen(msg));
*
*  // read ack data if available
*  if (nrf1.isAckData()) { 
*      len= nrf1.getRxData(ackData); // len is number of bytes in ackData
*   }
*}

Use case: For a simple receiver

rx code snipet

#include "NRF2401P.h"
*int main(){
*        
*  long long addr1=0xAB00CD; // setup address - any 5 byte number - same as TX
*  int channel =0x12;  // [0-126] setup channel, must be same as TX
*  bool txOK;
*  char msg[32];
*  char ackData[32];
*  char len;
*
*  // Setup 
*  NRF2401P nrf1(PTD6,PTD7, PTD5,PTD4, PTC12); //mosi, miso, sclk, csn, ce)
*  nrf1.quickRxSetup(channel, addr1); // sets nrf24l01+ as  receiver, using pipe 1
*
*  // set ack data
*  sprintf(ackData,"Ack data");
*  nrf1.acknowledgeData(ackData, strlen(ackData),1); // ack for pipe 1
*    
*  // receive
*  while (! nrf1.isRxData()); // note this blocks until RX data
*  len= nrf1.getRxData(msg); // gets the message, len is length of msg
*
*}

Revisions of NRF2401P.h

Revision Date Message Actions
20:e61edde5680d 2016-02-25 Minor updates to make all returns void if possible File  Diff  Annotate
18:220df99d2d41 2016-02-08 updates; File  Diff  Annotate
17:b132fc1a27d2 2016-02-07 Updated; File  Diff  Annotate
15:9998698cb041 2015-06-18 Cleaned up code. most functions now return void. Status is tracked in the class. Use checkStatus(). File  Diff  Annotate
14:976a876819ae 2015-07-11 Minro housekeeping. File  Diff  Annotate
13:5cbc726f2bbb 2015-07-11 Provides isRPDset() - check if radio signal > -64dBm. File  Diff  Annotate
11:07f76589f00a 2015-07-11 Refactored printDetails and introduced printReg functions. File  Diff  Annotate
10:8a217441c38e 2015-07-11 Adds in ability to read multiple bytes from SPI and can now print address details. File  Diff  Annotate
9:c21b80aaf250 2015-07-11 Added basic function to display radio setup and configuration. Fix dynamic payload setup. File  Diff  Annotate
8:3e027705ce23 2015-07-05 Incremental improvement on documentation. File  Diff  Annotate
7:621a5b0cf1aa 2015-07-05 Doxygen example "template" for setRadio. File  Diff  Annotate
6:77ead8abdd1c 2015-07-05 Minor housekeeping. Tidied up function return values. For functions doing something the convention is to return a char - 0 on success, non-zero for failure. Query functions return bool. Reading and writing registers are now void functions. File  Diff  Annotate
5:7e253c677a1f 2015-06-12 Added documentation; File  Diff  Annotate
3:afe8d307b5c3 2015-06-11 No debug, transmitData returns bool not char - flushesTX if max RT File  Diff  Annotate
2:ca0a3c0bba70 2015-06-11 Ack working File  Diff  Annotate
1:ff53b1ac3bad 2015-06-11 Added a few extras File  Diff  Annotate
0:8fd0531ae0be 2015-06-11 First Commit File  Diff  Annotate