433mhz RF Transmitter and Receiver module with Arduino
Hello, welcome back. In this tutorial, we will learn what is the RF transmitter-receiver module and how it works with the Arduino platform. We can mainly use this module for wireless communication. That is, it can be used to communicate data between two Arduino boards. It uses 433MHz radio waves. Also, we can buy this module at a low cost and communicate data easily. This tutorial presents step by step how to communicate data between two Arduino boards using the example of rotating a servo motor by a potentiometer.
This RF transmitter-receiver module consists of two main components. That is,
Transmitter
This module was created using a component called SAW Resonator. We can consider it as the main component here. Also, it operates at a radio frequency of 433MHz. An antenna must be connected to transmit the signal more distance.
Receiver
This captures the signals sent by the transmitter. To do that, it includes an RF tuned circuit and two op-amps. For this module, we need to connect an antenna.
How does this module work?
Data transmission through these two modules takes place according to a special process. This is called Amplitude Shift Keying (ASK). That is, when a HIGH signal is received for the transmitter module, the constant oscillation activates and produces an RF output carrier wave, and when a LOW signal is given, the oscillation stops. This process is the same as the AM radio process. This is also called binary amplitude shift keying. Because the process works HIGH or LOW in two ways.
The PIN structure of this sensor
Okay, let’s see step by step how this module works with Arduino. The required components are as follows.
- Arduino Nano board x 1 — Our Store / Amazon
- Arduino UNO board x 1 — Our Store / Amazon
- RF transmitter-receiver module x 1 — Our Store / Amazon
- Potentiometer x 1 — Our Store / Amazon
- Servo motor x 1 — Our Store / Amazon
- Breadboard x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Step 2
Secondly, connect these components. To do this, use the circuit diagrams below.
Transmitter circuit diagram
Receiver circuit diagram
Step 3
Thirdly, let’s create the programs for these two circuits. They are given below.
Transmitter program
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop() {
int value = analogRead(A1);
value = map(value, 0, 1024, 0, 180);
mySwitch.send(value, 30);
}
Code Explanation
Firstly, the library is included and object is created for this library.
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
In the setup function, the library is enable.
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
In the loop function, get the potentiometer values and send them to the receiver module.
void loop() {
int value = analogRead(A1);
value = map(value, 0, 1024, 0, 180);
mySwitch.send(value, 30);
}
OK, now select the board and port. After, upload this code to the transmitter circuit.
Receiver program
#include <Servo.h>
#include <RCSwitch.h>
Servo servo;
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0);
servo.attach(3);
}
void loop() {
if (mySwitch.available()) {
Serial.println(mySwitch.getReceivedValue());
servo.write(mySwitch.getReceivedValue());
mySwitch.resetAvailable();
}
}
Code Explanation
Firstly, the RCSwitch and servo libraries are included. After, objects are created for these libraries.
#include <Servo.h>
#include <RCSwitch.h>
Servo servo;
RCSwitch mySwitch = RCSwitch();
In the setup function, the RCSwitch is library enable. Also, the pin that connects the servo motor is included.
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0);
servo.attach(3);
}
In the loop function, the transmitter values are checked using the IF condition and those values are obtained. Then, the servo motor rotates according to those values.
void loop() {
if (mySwitch.available()) {
Serial.println(mySwitch.getReceivedValue());
servo.write(mySwitch.getReceivedValue());
mySwitch.resetAvailable();
}
}
OK, now select the board and port. After, upload this code to the receiver circuit.
Okay, now power up the two circuits and enjoy this project. The full video guide is given below. So, we will meet in the next video. Have a good day.
433mhz RF Transmitter and Receiver module with Arduino