Skip to content

Wireless Communication with Arduino

Create a wireless communication system using Arduino and NRF24L01 radio transmitters to control a servo remotely.

  • Arduino
  • Advanced
  • 75 minutes
  • 6 steps

Shop this project

Cart

Prices from vilros.com. Tax and shipping at checkout.

Before you start, you'll need

  • 2× Arduino Uno
  • 2× NRF24L01 radio transmitter modules (2.4GHz)
  • Rotary potentiometer (10kΩ)
  • Servo motor
  • Jumper wires
  • Breadboards (2)

Install the Mirf library

About 10 minutes

Add NRF24L01 support to Arduino IDE.

  1. Download the Mirf library from GitHub (arduino-nrf24l01).
  2. In Arduino IDE, go to Sketch → Include Library → Add .ZIP Library.
  3. Select the downloaded Mirf library zip file.
  4. Restart Arduino IDE.

You should see

The Mirf library is installed and available.

Wire the transmitter circuit

About 20 minutes

Connect NRF24L01 and potentiometer to Arduino #1.

  1. Connect NRF24L01 to Arduino: VCC→3.3V, GND→GND, CE→Pin 9, CSN→Pin 10, SCK→Pin 13, MOSI→Pin 11, MISO→Pin 12.
  2. Connect potentiometer: outer pins to 5V and GND, center pin to A0.
  3. Important: NRF24L01 modules are 3.3V only—do not connect to 5V!

You should see

All connections are secure and NRF24L01 is powered at 3.3V.

Wire the receiver circuit

About 20 minutes

Connect NRF24L01 and servo to Arduino #2.

  1. Connect NRF24L01 to second Arduino using the same pin connections as transmitter.
  2. Connect servo: red wire→5V, black/brown→GND, signal wire→Pin 6.

You should see

Receiver circuit is complete.

Program the transmitter

About 10 minutes

Upload code to read potentiometer and transmit value.

  1. Connect Arduino #1 (transmitter) to computer.
  2. Open Arduino IDE and copy the transmitter sketch below.
  3. Upload to Arduino #1.
cpp
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup() {
  Serial.begin(9600);
  Serial.println("Library initialization");
  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());
  
  delay(100);
}

The addresses 'nrf01' and 'nrf02' must match between transmitter and receiver.

You should see

Transmitter code uploads successfully.

Program the receiver

About 10 minutes

Upload code to receive values and control servo.

  1. Connect Arduino #2 (receiver) to computer.
  2. Copy the receiver sketch and upload.
cpp
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
#include <Servo.h>

Servo myServo;

void setup() {
  Serial.begin(9600);
  myServo.attach(6);
  
  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");
}

void loop() {
  if (Mirf.dataReady()) {
    float value;
    Mirf.getData((byte *) &value);
    
    int angle = map(value, 0, 1023, 0, 180);
    myServo.write(angle);
    
    Serial.print("Received: ");
    Serial.print(value);
    Serial.print(" -> Angle: ");
    Serial.println(angle);
  }
}

The servo maps potentiometer values (0-1023) to servo angles (0-180°).

You should see

Receiver code uploads successfully.

Test wireless control

About 5 minutes

Verify the servo responds to potentiometer.

  1. Power both Arduinos independently (USB or battery).
  2. Open Serial Monitor on transmitter to see values being sent.
  3. Turn the potentiometer on the transmitter.
  4. Watch the servo on the receiver move accordingly.

You should see

The servo moves as you turn the potentiometer wirelessly.

It didn't work
  • No communication between modules.

    Check that both NRF24L01 modules are powered at 3.3V (not 5V). Verify channel and addresses match in both sketches. Ensure modules are within range (~10m line of sight).

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.