How 433 MHz RF Module Works & Interfacing With Arduino

Overview

In this video, we will be learning about then 433MHz RF Wireless Transmitter and Receiver Module & its interfacing with Arduino. We will also learn how this module works and how wireless communication occurs. And finally, we will learn how to use this module with Arduino to transmit and receive data packet wirelessly.

433MHz RF Module

433 Mhz RF Module

So this module looks exactly something like as shown in the figure above. And also available in different packages. But basically, all these modules have the same function. You can purchase any of these modules. The transmitter section is tiny and has 4 pins, while the receiver section is a little bigger in size and has 8 pins.

Transmitter Section

433 Mhz Transmitter

This little module is a transmitter. The heart of the module is the SAW resonator which is tuned for 433 MHz operations. There are a switching transistor and a few passive components.

433 Mhz RF Transmitter Working

When a logic HIGH is applied to the DATA input, the oscillator runs producing a constant RF output carrier wave at 433 MHz and when the DATA input is taken to logic LOW, the oscillator stops. This technique is known as Amplitude Shift Keying which is discussed below.

Receiver Section

433 Mhz Receiver

This one is a receiver module. It consists of an RF tuned circuit and a couple of OP Amps to amplify the received carrier wave from the transmitter.

433 Mhz RF Receiver Working

The amplified signal is further fed to a PLL (Phase Lock Loop) which enables the decoder to “lock” onto a stream of digital bits which gives better-decoded output and noise immunity.

What is Amplitude Shift Keying (ASK)?

For sending the digital data over the radio, these modules use a technique called Amplitude Shift Keying (ASK). In Amplitude Shift Keying the amplitude of the carrier wave is changed in response to the incoming data signal. This is very similar to the analogue technique of amplitude modulation similar to AM radio. It’s sometimes called binary amplitude shift keying because there are only two levels. It’s similar to an ON/OFF switch.

• For Digital HIGH – This drives the carrier at full strength. • For Digital LOW – This cuts the carrier off completely.

Amplitude Shift Keying

Amplitude Shift keying is very simple to implement and inexpensive too which is a plus point factor. It is quite simple to design the decoder circuitry. Also, ASK needs less bandwidth than other modulation techniques like FSK.

Interfacing 433Mhz RF Module with Arduino

Let’s learn how to Interface 433Mhz RF Module with Arduino. We will be sending data between two Arduino boards, so we will need two Arduino boards, two breadboards and a couple of jumper wires. The RF module in both sections has an antenna. The actual height of the antenna should be 69 cm. but such a long antenna is not a feasible option. So you can use any wired antenna around 17 cm in length.

Transmitter Section Wiring

The wiring for the transmitter is simple. It has only three connections. Connect the VCC pin to 5V pin and GND to ground on the Arduino. The Data-In pin should be connected to Arduino’s digital pin 12 as by the default library. library.

Interfacing 433Mhz RF Module with Arduino

Receiver Section Wiring

The wiring for the receiver is just as easy as the transmitter. Once again there are only three connections to make. Connect the VCC pin to 5V pin and GND to ground on the Arduino. Any of the middle two Data-Out pins should be connected to digital pin 11 as shown in the figure.

Interfacing 433Mhz RF Module with Arduino

So you can see below how we have connected 433Mhz RF Module to Arduino in both the transmitter & Receiver Section.

Source Code/Program

Before going to upload the code, you need to install one library called a Radiohead library. Radiohead is a library that allows simple data transfer between Arduino boards. It’s so versatile that it can be used to drive all sorts of radio communications devices, including our 433MHz modules.

Radiohead Library: Download

Transmitter Section

#include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library #include <SPI.h> // Include dependant SPI Library // Create Amplitude Shift Keying Object RH_ASK rf_driver; void setup() { // Initialize ASK Object rf_driver.init(); // Setup Serial Monitor Serial.begin(9600); } void loop() { const char *msg = "Hello World"; rf_driver.send((uint8_t *)msg, strlen(msg)); rf_driver.waitPacketSent(); { // Message Transmitted Serial.println("Message Transmitted: "); delay(1000); } }
12345678910111213141516171819202122232425 #include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library#include <SPI.h> // Include dependant SPI Library// Create Amplitude Shift Keying ObjectRH_ASK rf_driver;voidsetup(){// Initialize ASK Objectrf_driver.init();// Setup Serial MonitorSerial.begin(9600);}voidloop(){constchar*msg="Hello World";rf_driver.send((uint8_t *)msg,strlen(msg));rf_driver.waitPacketSent();{// Message TransmittedSerial.println("Message Transmitted: ");delay(1000);}}

Receiver Section

#include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library #include <SPI.h> // Include dependant SPI Library // Create Amplitude Shift Keying Object RH_ASK rf_driver; void setup() { // Initialize ASK Object rf_driver.init(); // Setup Serial Monitor Serial.begin(9600); } void loop() { // Set buffer to size of expected message uint8_t buf[11]; uint8_t buflen = sizeof(buf); // Check if received packet is correct size if (rf_driver.recv(buf, &amp;buflen)) { // Message received with valid che-cksum Serial.print("Message Received: "); Serial.println((char*)buf); } }
123456789101112131415161718192021222324252627 #include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library#include <SPI.h> // Include dependant SPI Library // Create Amplitude Shift Keying ObjectRH_ASK rf_driver; voidsetup(){// Initialize ASK Objectrf_driver.init();// Setup Serial MonitorSerial.begin(9600);} voidloop(){// Set buffer to size of expected messageuint8_t buf[11];uint8_t buflen=sizeof(buf);// Check if received packet is correct sizeif(rf_driver.recv(buf,&amp;buflen)){// Message received with valid che-cksumSerial.print("Message Received: ");Serial.println((char*)buf);}}

Code Explanation

Transmitter sketch:

The sketch starts by including Radiohead ASK library. We also need to include the Arduino SPI Library as the RadioHead library is dependent on it.

Next, we need to create an ASK object in order to access special functions related to Radiohead ASK library.

In the setup function, we need to initialize the ASK object. In the loop function, we start by preparing a message. It’s a simple text string and stored in a character pointer named msg.

The message is then transmitted using a send() function. It has two parameters: first is an array of data and second is a number of bytes (length of the data) to be sent. The send() function is usually followed by waitPacketSent() function which waits until any previous transmit packet is finished being transmitted.

After that, the sketch waits for a second to give our receiver time to take in everything.

Receiver sketch:

Just like the transmitter code, receiver code starts by loading both the Radiohead and SPI libraries and creating an ASK object.

In the setup function: we initialize the ASK object and also set up the serial monitor as this is how we will view our received message.

In loop function: we create a buffer of size same as the transmitted message.

Next, we call a recv() function. This turns the receiver on if it not already on. If there is a valid message available, it copies the message to its first parameter buffer and returns true else return false. If the function returns true, the sketch enters into if statement and prints the received message on the serial monitor.

Video Tutorial & Explanation

How 433 MHz RF Module Works & Interfacing with Arduino Watch this video on YouTube.

Tag » Arduino Rf 433 Example