Skip to content

Arduino - Wireless Communication

Simple 433MHz or 315MHz ASK (Amplitude-Shift Keying) RF modules are a low-cost way to create a wireless data link between two Arduinos. While they have limitations, they are excellent for learning the fundamentals of wireless communication.

Important Note: These modules are very basic. They are prone to interference, have a short range, and offer no security. For more robust projects, consider modern alternatives like nRF24L01, LoRa, or ESP32-based Wi-Fi/Bluetooth solutions.

  • 2 × Arduino UNO (or similar)
  • 1 × 433MHz RF Transmitter Module (e.g., FS1000A)
  • 1 × 433MHz RF Receiver Module (e.g., XY-MK-5V)
  • Breadboards and jumper wires
  • 2 × Antennas (a simple ~17.3cm solid core wire for 433MHz works well)

The older VirtualWire library is deprecated and no longer maintained. The current standard for these modules is the RadioHead library. It is more powerful, reliable, and supports a wide variety of wireless hardware.

  1. Open the Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries…
  3. In the search box, type RadioHead.
  4. Find the library by Mike McCauley and click Install.

An antenna is critical for performance. Solder a 17.3 cm wire to the ‘ANT’ pad on both modules.

  • Transmitter GND → Arduino GND
  • Transmitter VCC → Arduino 5V
  • Transmitter DATA (or ATAD) → Arduino Pin 12
  • Receiver GND → Arduino GND
  • Receiver VCC → Arduino 5V
  • Receiver DATA → Arduino Pin 11

This project uses one Arduino to transmit ON/OFF commands and another to receive them and control its built-in LED.

#include <RH_ASK.h>
#include <SPI.h> // Not used by ASK but required by RadioHead
// Create an instance of the driver. Default pins are 12 for TX, 11 for RX.
RH_ASK driver;
void setup() {
Serial.begin(9600);
if (!driver.init()) {
Serial.println("RadioHead driver init failed");
while (1); // Halt on failure
}
Serial.println("RF Transmitter Initialized");
}
void loop() {
const char *msgOn = "LED:ON";
driver.send((uint8_t *)msgOn, strlen(msgOn));
driver.waitPacketSent(); // Wait for the message to be sent
Serial.println("Sent: LED:ON");
delay(2000);
const char *msgOff = "LED:OFF";
driver.send((uint8_t *)msgOff, strlen(msgOff));
driver.waitPacketSent();
Serial.println("Sent: LED:OFF");
delay(2000);
}
#include <RH_ASK.h>
#include <SPI.h> // Not used by ASK but required by RadioHead
// Create an instance of the driver. We will use a non-default pin for RX.
RH_ASK driver(2000, 11, 12, 0); // (speed, rx pin, tx pin, ptt pin)
void setup() {
Serial.begin(9600);
if (!driver.init()) {
Serial.println("RadioHead driver init failed");
while (1); // Halt on failure
}
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("RF Receiver Initialized");
}
void loop() {
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
// Check if a message has been received
if (driver.recv(buf, &buflen)) {
// Message received, print it to serial monitor
Serial.print("Received: ");
Serial.println((char*)buf);
// Control the LED based on the message
if (strcmp((char*)buf, "LED:ON") == 0) {
digitalWrite(LED_BUILTIN, HIGH);
} else if (strcmp((char*)buf, "LED:OFF") == 0) {
digitalWrite(LED_BUILTIN, LOW);
}
}
}
  • Antenna is Mandatory: Without a properly sized antenna, your range will be a few centimeters at best.
  • Power Supply: A clean power source is vital. Noise from other components can interfere with the receiver. Adding a small capacitor (e.g., 100uF) across VCC and GND on the receiver can help.
  • Data Rate: The default 2000 bps is reliable. Pushing the speed too high can increase errors.
  • Protocol: RadioHead includes a preamble, header, length, and checksum, making it much more reliable than sending raw data. For custom data, consider sending it in a struct for better organization.