• Admin

1.1KM Wireless Communication using Arduino & NRF24L01



nRF24L01 Module


The nFR24L01 is a transceiver module which means that it can both send and receive the data.

These modules are very cheap, smaller in size and has a lot of specifications. Some of the specifications of these modules are as follows


Specifications of nRF24L01 Module

  • Power consumption is around 12mA during transmission which is even lesser than the led.

  • It can operate with baud rates from 250Kbps up to 2 Mbps.

  • Its range can reach up to 100 meters if used in open space and with antenna.

  • It can both send and receive the data simultaneously.

  • Each module can communicate with up to 6 other modules.

  • It uses the 2.4 GHz band.

  • It can send 1 to 25 bytes of raw data at the transmission rate of 1 MB.

  • It has 125 different channels.

CODE FOR RECEIVER

#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>


#define relayPin1 A0

#define relayPin2 A1


int buttonState = 0;


RF24 radio(9, 10); // CE, CSN

const byte address[6] = "00002";


void setup() {

Serial.begin(9600);

pinMode(relayPin1, OUTPUT);

pinMode(relayPin2, OUTPUT);

digitalWrite(relayPin1, HIGH);

digitalWrite(relayPin2, HIGH);

radio.begin();

radio.openReadingPipe(0, address);

radio.setPALevel(RF24_PA_MIN);

}


void loop() {

radio.startListening();

while (!radio.available());

radio.read(&buttonState, sizeof(buttonState));

Serial.println(buttonState);


if (buttonState == 1) {

digitalWrite(relayPin1, LOW);

}

else if (buttonState == 0) {

digitalWrite(relayPin1, HIGH);

}

else if (buttonState == 3) {

digitalWrite(relayPin2, LOW);

}

else if (buttonState == 2) {

digitalWrite(relayPin2, HIGH);

}

}



CODE FOR TRANSMITTER


#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>


#define buttonPin1 A0

#define buttonPin2 A1