How to make Wireless Warning System | nRF24L01 Communication | Arduino



In this tutorial we will learn how to make the wireless warning system. We will use the nRF24L01 wireless communication module for this. An ideal tutorial for beginners. The source code explained line by line. In this project you can use any sensor you want. Required Hardwares : Any Arduino Board - 2 pcs Arduino Uno -- https://goo.gl/RcRmi1 Arduino Nano -- https://goo.gl/h6nzyC Arduino Mega -- https://goo.gl/PfP5p7 nRF24L01 Wireless Module - 2 pcs nRF24L01 with External Antenna -- https://goo.gl/FePZu9 nRF24L01 with Internal Antenna -- https://goo.gl/uxR2Gj nRF24L01 For Power - 2 pcs nRF24L01 Adapter -- https://goo.gl/HSfTWq 10uf Capacitor -- https://goo.gl/NHP4pi LM35 Temperature Sensor -- https://goo.gl/F1HR9E Buzzer -- https://goo.gl/4GgSgy LED Kit Set -- https://goo.gl/uKJ5XX Breadboard -- https://goo.gl/ExxNWy Jumper Wires -- https://goo.gl/EGTafY ------------------------------------------------ Optional : HC-SR501 PIR Sensor -- https://goo.gl/o5ryt8 MQ-2 Smoke Gas Sensor -- https://goo.gl/qGiFMB SD Card Module -- https://goo.gl/PLf1cz Mini Speaker -- https://goo.gl/nRz4wi ------------------------------------------------ Virtual Circuit Program Fritzing -- http://fritzing.org/download/

------------------------------------------------
Source Code and Library RF24 Library -- https://github.com/maniacbug/RF24

//Transmitter

#include <SPI.h>        //SPI library for communicate with the nRF24L01+
#include "RF24.h"       //The main library of the nRF24L01+

const int lm35Pin = 0;

int data[1];

//Define object from RF24 library - 9 and 10 are a digital pin numbers to which signals CE and CSN are connected.
RF24 radio(9,10);

//Create a pipe addresses for the communicate                                    
const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup(void){
  Serial.begin(9600);
  pinMode(lm35Pin, INPUT);
  radio.begin();                 //Start the nRF24 communicate     
  radio.openWritingPipe(pipe);   //Sets the address of the receiver to which the program will send data.
}

void loop(void){
  data[0] = analogRead(lm35Pin);
  Serial.println(data[0]);
  radio.write(data, sizeof(data));
}
//Receiver

//Add the necessary libraries
//You can find all the necessary library links in the video description
#include <SPI.h>      //SPI library for communicate with the nRF24L01+
#include "RF24.h"     //The main library of the nRF24L01+

#define buzzerPin 2
#define threshold 90

int led1 = 4;

int data[1];

//Define object from RF24 library - 9 and 10 are a digital pin numbers to which signals CE and CSN are connected
RF24 radio(9,10);

//Create a pipe addresses for the communicate
const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup(){
  pinMode(led1, OUTPUT);
  Serial.begin(9600);
  radio.begin();                    //Start the nRF24 communicate            
  radio.openReadingPipe(1, pipe);   //Sets the address of the transmitter to which the program will receive data.
  radio.startListening();             
  }

void loop(){
  if (radio.available()){
    radio.read(data, sizeof(data));
    Serial.println(data[0]);

    if(data[0] > threshold){
      tone(buzzerPin, 440);
      digitalWrite(led1, HIGH);
      delay(400);
      noTone(buzzerPin);
      digitalWrite(led1, LOW);
      delay(50);
    }
    else {
      noTone(buzzerPin);
      digitalWrite(led1, LOW);
    }
  }
}