How to Make a Wireless Communication Using a Radio Module

How to Make a Wireless Communication Using a Radio Module

This project will show you how to transmit variables to control a servo motor.

  • 3,492 views
  • 5 comments
  • 27 respects

Components and supplies

Apps and online services

About this project

Radio transmitter (nRF24l01)

nRF24l01 is a radio transmitter which can transmit and receive data on the frequency range of 2, 4GHz.

Radio modules have two type of antenna : ceramic antenna and antenna trace.

Some module have a voltage regulator which supports 5V and 3.3V, but this module ( that I use, photo in "Basics" ) don't have regulator so he can only supports 3.3V.

Library

For this code we use a library, named "Mirf".

Mirf : https://github.com/aaronds/arduino-nrf24l01

Schematics

Code

Transmitter Arduino
#include <SPI.h>      
#include <Mirf.h>    
#include <nRF24L01.h> 
#include <MirfHardwareSpiDriver.h> 
 
void setup() {
  Serial.begin(9600);
  Serial.println("Library initialization; EC/CSN pin and channel definition and module transmission and reception address definition");
  delay(2000);
  Mirf.cePin = 9; 
  Mirf.csnPin = 10; 
  Mirf.spi = &MirfHardwareSpi; 
  Mirf.init();  
  Mirf.channel = 1; 
  Mirf.payload = sizeof(float); 
  Mirf.config(); 
  Mirf.setTADDR((byte *) "nrf02"); 
  Mirf.setRADDR((byte *) "nrf01");
}
 
void loop() {
  float value = analogRead(A0); 
  Serial.println(value);
  
  Mirf.send((byte *) &value); 
  while(Mirf.isSending()); 
}  
Receiver Arduino
#include <SPI.h>     
#include <Mirf.h>     
#include <nRF24L01.h> 
#include <MirfHardwareSpiDriver.h> 
#include <Servo.h>

Servo servo;

void setup() {
  Serial.begin(9600);
  servo.attach(3);
  Mirf.cePin = 9;
  Mirf.csnPin = 10; 
  Mirf.spi = &MirfHardwareSpi; 
  Mirf.init(); 
  Mirf.channel = 1;
  Mirf.payload = sizeof(float); 
  Mirf.config();
  Mirf.setTADDR((byte *) "nrf01"); 
  Mirf.setRADDR((byte *) "nrf02"); 

  Serial.println("Reception of the value :"); 
}

void loop() {
  float value;

  if(Mirf.dataReady()){
    Mirf.getData((byte *) &value); 
    Serial.println(value); 
    
    int degree = map(value, 0, 1080, 0, 180);
    servo.write(degree);
    delay(15);
  }
}

Schematics

Schematics ( transmitter and receiver )
nrf24l01_xuWutpstYH.fzz

Comments

Similar projects you might like

Morse Code Communication Using Laser Module (Both)

Project tutorial by SURYATEJA

  • 1,388 views
  • 1 comment
  • 9 respects

Wireless Magnetic Data Transfer

Project tutorial by Tomi Chen

  • 5,549 views
  • 4 comments
  • 23 respects

Using the RAK811 LoRa module with Arduino

Project tutorial by Naresh krish

  • 10,334 views
  • 4 comments
  • 11 respects

Communication Between Arduino UNO

by Giovanni Gentile

  • 3,683 views
  • 1 comment
  • 6 respects
Add projectSign up / Login