2.4G Wireless RF Module Demo for Arduino

From: nRF24L01 Module Demo for Arduino | ElecFreaks

For this you need two Arduino boards and two RF modules, one to transmit and the other to receive.

The nRF24L01 module is worked at 1.9-3.6V voltage level, if you use standard Arduino board, you should use the Arduino board’s 3.3V pin?VDD3V3? to provide power for the nRF24L01 module. Please note, not use 5V pin(VDD5V) to provide power, which may destroy it.

The Demo pins to Arduino as below:
GND–GND, VCC–3.3V, CS–D8, CSN–D9, SCK–D10, MOSI–D11, MISO–D12, IRQ–D13

Download the code below into the TX Arduino (transmit) — This code will drive the nRF24L01 module to send out data form 0×00 to 0xFF .

Note, between the write TX_FIFO and clear RX_DR or TX_DS or MAX_RT interrupt flag, would better not serial print anything, which maybe case ACK failed.

void setup()
{
  SPI_DIR = ( CE + SCK + CSN + MOSI);
  SPI_DIR &=~ ( IRQ + MISO);
  //  attachInterrupt(1, _ISR, LOW);// interrupt enable
  Serial.begin(9600);
  init_io();                        // Initialize IO port
  unsigned char status=SPI_Read(STATUS);
  Serial.print("status = ");
  Serial.println(status,HEX);      // read the mode’s status register, the default value should be ‘E’
  Serial.println("*******************TX_Mode Start****************************");
  TX_Mode();                       // set TX mode
}
void loop()
{
  int k = 0;
  for(;;)
  {
    for(int i=0; i<32; i++)
        tx_buf[i] = k++;
    unsigned char status = SPI_Read(STATUS);           // read register STATUS's value
    if(status&TX_DS)                                        // if receive data ready (TX_DS) interrupt
    {
      SPI_RW_Reg(FLUSH_TX,0);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);    // write playload to TX_FIFO
    }
    if(status&MAX_RT)                           // this is retransmit than  SETUP_RETR
    {
      SPI_RW_Reg(FLUSH_TX,0);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);     // disable standy-mode
    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);  // clear RX_DR or TX_DS or MAX_RT interrupt flag
    delay(1000);
  }
}

Download the code below into the RX Arduino (receive) – This code will drive the nFR24L01 module to receive the data that transmit form the TX module and print it to serial port.

Note, clear RX_FIFO must bellow Read_FIFO

void setup()
{
  SPI_DIR = ( CE + SCK + CSN + MOSI);
  SPI_DIR &=~ ( IRQ + MISO);
  //  attachInterrupt(1, _ISR, LOW); // interrupt enable
  Serial.begin(9600);
  init_io();                        // Initialize IO port
  unsigned char status=SPI_Read(STATUS);
  Serial.print("status = ");
  Serial.println(status,HEX);  // read the mode’s status register, the default value should be ‘E’
  Serial.println("*****************RX_Mode start******************************R");
  RX_Mode();                        // set RX mode
}
void loop()
{
  for(;;)
  {
    unsigned char status = SPI_Read(STATUS);                // read register STATUS's value
    if(status&RX_DR)                                        // if receive data ready (TX_DS) interrupt
    {
      SPI_Read_Buf(RD_RX_PLOAD, rx_buf, TX_PLOAD_WIDTH);    // read playload to rx_buf
      SPI_RW_Reg(FLUSH_RX,0);                               // clear RX_FIFO
      for(int i=0; i<32; i++)
      {
          Serial.print(" ");
          Serial.print(rx_buf[i],HEX);                      // print rx_buf
      }
      Serial.println(" ");
    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);  // clear RX_DR or TX_DS or MAX_RT interrupt flag
    delay(1000);
  }
}

Now power on both Arduino , and connect the RX one to PC via USB. Open the IDE serial port monitor , change the baud rate to 9600 bps , and you can see the data that received.

More informations about RF module: nRF24L01 Module Demo for Arduino | ElecFreaks

Hi,

There are 3 or 4 similar RF modules, and I have been researching them some.. There are versions with a power amplifier for more RF output, and with both output amplifier AND a low-noise receiver preamplifier, both of which add a lot to the working range distance.

I will report on the tests I am doing soon ...

I will have the NRF24L01 available soon at about $4. Not sure about prices on the advanced versions yet...

These are VERY nice and easy-to-use units.

DISCLAIMER: I mentioned stuff from my own Shop...

Potential dumb question warning:
I need the pin out on this thing. Are yours in order, and does it do the down and reverse thing,

ground is square, then left to right, top row right to left?

Hi, The pinout on the one I'm using to test now is:

This is the bottom view..

Perfect! thank you. I just noticed how big a PITA this is gonna be, since the 2 rows are too close together to go on opposite sides of my breadboard. grr. :0

terryking228: Hi, The pinout on the one I'm using to test now is:

This is the bottom view..