Loading...

0

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!

nRF24L01 Wireless Module with Arduino

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

The nRF24L01 module is worked at 3V voltage level , so the Arduino 5V pins may destroy it , so we need to add some resister to protect the module – using the 10K and the 15K resister 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 form 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 transmit form the TX module and print it to 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 you can see the data that received.

If you want to change Arduino pin connecting to module , just modify the define on the NRF24L01.h .

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

  nRF24L01 Demo code for Arduino (unknown, 5,589 hits)

You can fine the cables , resisters and the nRF24L01 module that used in the demo on our webshop.