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
CartYou'll need
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.
- Download the Mirf library from GitHub (arduino-nrf24l01).
- In Arduino IDE, go to Sketch → Include Library → Add .ZIP Library.
- Select the downloaded Mirf library zip file.
- 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.
- Connect NRF24L01 to Arduino: VCC→3.3V, GND→GND, CE→Pin 9, CSN→Pin 10, SCK→Pin 13, MOSI→Pin 11, MISO→Pin 12.
- Connect potentiometer: outer pins to 5V and GND, center pin to A0.
- 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.
- Connect NRF24L01 to second Arduino using the same pin connections as transmitter.
- 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.
- Connect Arduino #1 (transmitter) to computer.
- Open Arduino IDE and copy the transmitter sketch below.
- Upload to Arduino #1.
#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.
- Connect Arduino #2 (receiver) to computer.
- Copy the receiver sketch and upload.
#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.
- Power both Arduinos independently (USB or battery).
- Open Serial Monitor on transmitter to see values being sent.
- Turn the potentiometer on the transmitter.
- 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.