Loading...

You have no items in your shopping cart.

 
 
 
×

Registration

Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

nRF24L01 Wireless Module with Arduino

Now we have a demo to show how to use the Arduino controlling the nRF24L01 module, and users need two Arduino boards and two modules, one to transmit and the other to receive. The connection of two parts is the same but with different software.

The nRF24L01 module works at 3V voltage level so Arduino 5V pins may destroy it, Therefore, we need to add some resistors to protect the module – using the 10K and the 15K resistors to reduce the voltage is a usual method.

Connect the module pins to Arduino as below:
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 from 0×00 to 0xFF.
void setup()
{
  SPI_DIR = ( CE + SCK + CSN + MOSI);
  SPI_DIR &=~( IRQ + MISO);
  Serial.begin(9600);
  init_io();
  TX_Mode();
}
void loop()
{
  unsigned char status=0;
  unsigned char key=0;
  for(;;)
  {
    tx_buf[1]=key;
    key++;
    status=SPI_Read(STATUS);
    if(status&TX_DS)
    {
      SPI_RW_Reg(FLUSH_TX,0);
      Serial.println(tx_buf[1],HEX);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);
    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);
    delay(1000);
  }

}

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

void setup()
{
  SPI_DIR = ( CE + SCK + CSN + MOSI);
  SPI_DIR&=~ ( IRQ + MISO);
  Serial.begin(9600);
  init_io();
  RX_Mode();
}
void loop()
{
  unsigned char status=0;
  unsigned char key=0;
  for(;;)
  {
    tx_buf[1]=key;
    key++;
    status=SPI_Read(STATUS);
    if(status&TX_DS)
    {
      SPI_RW_Reg(FLUSH_TX,0);
      Serial.println(tx_buf[1],HEX);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);
    }
    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 then users can see the data that is received.

If users want to change Arduino pin connecting to a module, just modify the definition on the NRF24L01.h .

All the project here (include API.h and NRF24L01.h)

  nRF24L01 Demo code for Arduino (unknown, 6,083 hits)

Users can find the cables, resistors and the nRF24L01 module that was used in the demo on our webshop.