Wireless Communication Using NRF24L01 Transceiver Module [PDF]

  • 0 0 0
  • Suka dengan makalah ini dan mengunduhnya? Anda bisa menerbitkan file PDF Anda sendiri secara online secara gratis dalam beberapa menit saja! Sign Up
File loading please wait...
Citation preview

Wireless Communication Using NRF24L01 Transceiver Module Aim: Study of Wireless Communication Using NRF24L01 Transceiver Module Objective: 1. To study the pin configuration of nRF24L01 module 2. To and study & use of NRF24L01 Transceiver Module 3. To setup the configuration and program to transmit the analog pots value using Arduino. 4. To setup the configuration and program to receive data value from nRF24 using Arduino & control LED brightness. Diagram/Block diagram:



Fig.a. nRF24L01 Transmitter interfacing circuit



Theory: nRF24L01 Interfacing with Arduino UNO



Fig.b. nRF24L01 Receiver interfacing circuit



Introduction NRF24L01 is a wireless transceiver module which operates in the 2.4GHz ISM frequency band. It is used to communicate data wirelessly which is specially designed for ultra-low power applications. It can be configured and operated through SPI Protocol. It can transmit data at a rate up to 2 Mbps. This module can use 125 different channels which makes possible to have network of 125 independently working modems in one place. Each channel has up to 6 addresses that means it can communicate with 6 other devices simultaneously. The communication range is up to 100 meters and it specially designed for ultra-low power applications. It operates on 1.9V to 3.6V power supply range, it takes 12mA of current during transmission mode which is even less than a single LED.  



The multi-receiver capacity of nRF24L01 is having up to 6 channels (pipes) of radio communication open in a receiving or read mode simultaneously. This takes the form of a hub receiver (PRX - primary receiver) and up to six transmitter nodes (PTX1 - PTX6 primary transmitters). In the above diagram, six reading (Data) pipes are opened in the primary receiver hub (PRX). Each PTX node links to one of these pipes to use both in transmitting and receiving (TX toward the hub being the primary direction of data flow, but the PTX nodes are RX capable as well). Note: that the hub can also stop listening and act as a  transmitter, transmitting (or writing) to the PTX nodes but this can only be done one pipe or node at a time. The addresses or pipes must have a distinct pattern of bytes, only the fifth byte is entirely unique among all the pipes and is known as the Least Significant Byte (LSB). Pipe 0 is assigned all five bytes independently. Pipe 1 is also assigned all five bytes independently, but then the first four bytes (MSBs) of pipe 1 also become the first four bytes of pipes 2 - 5 if they exist.   Pin diagram of nRF24L01



nRf24L01 module



nRF24l01 Connections to Arduino UNO nRF24L01



Arduino UNO



VCC



3.3V



GND



GND



SCK



D13



MISO



D12



MOSI



D11



CSN



D7



CE



D8



Procedure: Download RF24 library from here. Download SPI library from here. Extract these libraries and add it to the libraries folder path of Arduino IDE. For information about how to add a custom library to the Arduino IDE and use examples from it, refer Adding Library To Arduino IDE in the Basics section. Once the library has been added to the Arduino IDE, open the IDE and open the example sketch you want from the list of examples from the library added.



Arduino Uno Programming: Arduino Uno IDLE a. Open new sketch Write a program to __________________________and save as with namexxx..ino b. Select your board type and port c. You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino board. Select the serial device of the board from the Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port. d. Upload the program



Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done



uploading." will appear in the status bar.



e. Repeat all step for other program.



Code Sketch for Transmitter  //Adding Libraries #include



/* to handle the communication interface with the modem*/



#include



/* to handle this particular modem driver*/



#include



/* the library which helps us to control the radio modem*/



#define pot_pin A0



/*Variable pin of POT is to be connected to analog pin 0 i.e.A0*/



RF24 radio(7,8);



/* Creating instance 'radio' ( CE , CSN ) CE -> D7 | CSN -> D8 */



const byte Address[6] = " 00009 " ;



/* Address to which data to be transmitted*/



void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(pot_pin,INPUT); radio.begin ();



/* Setting A0 (POT pin) as input*/



/* Activate the modem*/



radio.openWritingPipe (Address); /* Sets the address of transmitter to which program will send the data */



} void loop() { // put your main code here, to run repeatedly: radio.stopListening ();



/* Setting modem in transmission mode*/



int value = analogRead(pot_pin);



/*Reading analog value at pin A0 and storing in varible 'value'*/



int data = map( value , 0 , 1023 , 0 , 255 ); /* Convering the 10 bit value to 8 bit */ radio.write(&data, sizeof(data));



/* Sending data over NRF 24L01*/



Serial.print("Transmitting Data : "); Serial.println(data);



/* Printing POT value on serial monitor*/



}



Sketch for Receiver //// Adding Libraries #include #include #include



/* to handle the communication interface with the modem*/ /* to handle this particular modem driver*/ /* the library which helps us to control the radio modem*/



#define led_pin 3



/* Connect LED anode to D3 (PWM pin) */



RF24 radio(7,8);



/* Creating instance 'radio' ( CE , CSN ) CE -> D7 | CSN -> D8 */



const byte Address[6] = "00009"; /* Address from which data to be received */ void setup() { // put your setup code here, to run once: Serial.begin(9600); radio.begin();



/*Setting baudrate of Serial Port to 9600*/ /* Activate the modem*/



radio.openReadingPipe(1, Address); /* Sets the address of receiver from which program will receive the data*/ } void loop() {



// put your main code here, to run repeatedly: radio.startListening();



/*Setting modem in Receiver mode*/



if (radio.available()) { while (radio.available())



/* Loop until receiving valid data*/



{ int rx_data = 0 ;



/* Variable to store received data */



radio.read(&rx_data, sizeof(rx_data));/* Read the received data and store in ' rx_data ' */ Serial.print("Received Data : "); Serial.println(rx_data);



/* Print received value on Serial Monitor */



analogWrite(led_pin , rx_data);/* Write received value to PWM pin 3 to which LED is connected */ } } else { Serial.println("Not Receiving !!!"); /* If not receiving valid data print " Not Receiving !!! " on Serial Monitor */ } ///// END OF LOOP ////// }



Functions Used in Sketch 1.      RF24 radio(7,8)  



This function is used to set the CE and CSN pin connection for nRF24l01. It connected CE pin to D7 and CSN pin to D8 of Arduino UNO.



2.      const byte Address[6] = " 00009 " 



This function is used to define the address of nRF24l01.



3.      radio.begin () 



This function activates the modem.



4.      radio.write(&data, sizeof(data))    This function is used to write or transmit the data.  &data transmit the data presents at the address location of “data”.  sizeof(rx_data) automatically calculates the number of bytes in a “rx_data” string. 5.      radio.read(&rx_data, sizeof(rx_data));    Result: Conclusion:



This function is used to read the received data.  &rx_data receive and store the data at the address location of “rx_data”. sizeof(rx_data) automatically calculates the number of bytes in a “rx_data” string.