Introduction: 433 MHz RF Links Theory, Circuit and Program
The video above explains the basic theory that relates to data transmission, namely how electromagnetic waves are generated by antennas and how they encode 1's and 0's. Non essential information for a hobbyist, but really interesting none the less.
Component list:
•1 X Arduino Uno
•1 X 433MHz RF link pair
•3 X LED
•1 X Piezo Buzzer
•1 X Push Button
•1 X Resistor 330Ω
•50cm Single Core Wire
Equipment needed:
Soldering Iron
Step 1: Build the Transmitter
Observe the schematic and the completed circuit (video tutorial also available)
Make sure you do ALL of the following:
1. Connect the module in the following manner Vcc pin connects to Arduino 5V GND to Arduino GND and DATA to Arduino Pin 12
2.The button connects to Arduino pin 2 and needs to be earthed
3. The antenna needs to be soldered onto the module. The antenna is 35cm long and soldered into an antenna slot in the transmitter module.
4. The antenna is to be straight if possible.
Watch the video from time: 00:40 to see the circuit built from scratch
Step 2: Building the Receiver
Observe the schematic and the completed circuit
Make sure you do ALL of the following:
1. Connect the module in the following manner Vcc pin connects to Arduino 5V GND to Arduino GND and DATA (Adjacent to to Arduino Pin 12
2. Connect a red LED to Arduino pin 5
3. Connect 1 or more Green LED's to Arduino pin 7
4. Connect a piezo buzzer to Arduino pin 8
Watch the video from time: 04:11 to see the circuit built from scratch
Step 3: Upload Transmitter Code
Upload this code onto the Arduino in the transmitter circuit
Watch the video from time: 07:58 for some extra information on the code
Attachments
Step 4: Upload Receiver Code
Upload this code onto the Arduino in the receiver circuit
Watch the video from time:10:03 for some extra information on the code
THATS IT YOURE DONE!!!
24 Comments
5 years ago
your code do not compile.
6 years ago
Hhope this helps someone. Updated these sketches to use RadioHead library.
Transmitter
*****************************
//This code was written using the functions of the Virtual Wire Library.
//Function list here: http://www.airspayce.com/mikem/arduino/VirtualWir...
Please note the default values used in the RadioHead Library as follows
RH_ASK::RH_ASK(
uint16_t speed = 2000,
uint8_t,rxPin = 11,
uint8_t,txPin = 12,
uint8_t,pttPin = 10,
bool,pttInverted = false
)
***Updated for RadioHead Library
****************************************************************************
//This code was written using the functions of the Virtual Wire Library.
//Function list here: http://www.airspayce.com/mikem/arduino/VirtualWir...
// Written by Sanjin Dedic as a part of Robotix Arduino Tutorial Course
// http://robotix.com.au/tutorials.html
//#include <VirtualWire.h>
//#include <RadioHead.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
const char *message = "Merry Christmas";
int button = 2;
RH_ASK driver;
void setup() {
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init of receiver failed");
pinMode(button,INPUT);
//vw_set_ptt_inverted(true); // On a communication line means that each
// party is either transmitting or receiving ( like a walkie talkie)
//vw_set_tx_pin(12); // set transmitter pin
//vw_setup(4000);// speed of data transfer Kbps
}
void loop(){
if (digitalRead(button) == HIGH){
message="X";
driver.send((uint8_t *)message, strlen(message)); // send the message
driver.waitPacketSent(); // Wait until the whole message is gone
Serial.println(message);
Serial.println(strlen(message));
delay(2000);
}
}
**********************************************************
Receiver - Updated for RadioHead Library
********************************************************
//This code was written using the functions of the Virtual Wire Library.
//Function list here: http://www.airspayce.com/mikem/arduino/VirtualWir...
// Written by Sanjin Dedic as a part of Robotix Arduino Tutorial Course
// http://robotix.com.au/tutorials.html
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
int ledPassive = 5; //standby light
int ledActive = 7; //green LED's
int buzzer = 8;
void setup()
{
pinMode(ledPassive,OUTPUT);
pinMode(ledActive,OUTPUT);
pinMode(buzzer,OUTPUT);
// vw_set_ptt_inverted(true); // On a communication line means that each
// party is either transmitting or receiving ( like a walkie talkie)
// vw_set_rx_pin(12); // set receiver pin
// vw_setup(4000); // Bits per sec
// vw_rx_start(); // Start Phase Locked Loop (listening to the receiver)
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init of receiver failed");
}
void loop()
{
digitalWrite(ledPassive,HIGH);
digitalWrite(buzzer,LOW);
digitalWrite(ledActive,LOW);
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) { // if message received
for(int i=0;i<sizeof(buf);i++)
Serial.print(char(buf[i])); //test display output
if(buf[0]=='X'){ // and if the first letter in message array is X
digitalWrite(ledPassive,LOW);
for(int i=0;i<10;i++){ // loop alternates between LED and buzzer
digitalWrite(buzzer,LOW);
digitalWrite(ledActive,HIGH);
delay(200);
digitalWrite(buzzer,HIGH);
digitalWrite(ledActive,LOW);
delay(200);
}
}
else if(buf[0]!='X'){
digitalWrite(ledPassive,HIGH);
}
}
}
Reply 5 years ago
Hello sir new your code work or not.
5 years ago
Hey thx for sharing. what about 2 transmitter and 1 receiver. can u help with code?
6 years ago
Im trying to use the TX module in a project with 12V supply. But now I don't know what voltage is required to set HIGH on the data pin? Is it a percentage of the VCC voltage or is it a fixed limit no matter what the VCC is supplied? Dose anyone know?
6 years ago
Is there an update for the new RadioHead Library?
6 years ago
hello sir i am doing same thing but getting nothing ,
what should i do plz reply
6 years ago
how to find signal connectivity status
6 years ago
Wow, using a 3.3VDC Arduino Pro-Mini and using 3.7 to 4.2 volts to the 433MHz TX is getting me 80 feet (24M). The RX is at 5VDC. That is with 17cm antennas on both.
6 years ago
I'm going to try using a ATtiny85 for the TX and RX on this project. If it works I will use it in my bicycle siren project I am working on. A button on the handlebars to activate lights/siren sitting in the trailer puller behind the bicycle. The idea is to scare away animals ahead of the bicycle's path on the roadway.
7 years ago
For anyone reading this and looking for good antenna advice, I've found that the tiny 'Helical antenna 433MHz' ones you find for 5 a dollar on ebay actually work reaally well, using one of those with one of the cheap green square transmitters has put me from a few meter on the same floor (with ~17cm wire) to all over the house, all three levels, and the shed outside :)
7 years ago
Wonderful
7 years ago
Is it need two pcs of Arduinos on the project for the future use? or just for the testing.
8 years ago on Introduction
hello, i need help
I am designing a distance meter, but for that I will use (read) the signal strength value (the RSSI technique) sent by TX. I will can do with this RX and TX?
8 years ago on Introduction
My code does not compile?
it says
Arduino: 1.0.6 (Mac OS X), Board: "Arduino Leonardo"
/Users/luigipizzolito/Desktop/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DARDUINO=106 -I/Users/luigipizzolito/Desktop/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Users/luigipizzolito/Desktop/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/leonardo -I/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire /var/folders/gb/cl6mrjbs3vq4hz2wmlpvxprc0000gq/T/build7192067266878744403.tmp/sketch_jul03a.cpp -o /var/folders/gb/cl6mrjbs3vq4hz2wmlpvxprc0000gq/T/build7192067266878744403.tmp/sketch_jul03a.cpp.o
In file included from sketch_jul03a.ino:9:
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:14:20: warning: wiring.h: No such file or directory
In file included from sketch_jul03a.ino:9:
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:54: warning: 'vw_set_tx_pin' initialized and declared 'extern'
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:54: error: variable or field 'vw_set_tx_pin' declared void
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:54: error: 'uint8_t' was not declared in this scope
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:58: warning: 'vw_set_rx_pin' initialized and declared 'extern'
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:58: error: variable or field 'vw_set_rx_pin' declared void
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:58: error: 'uint8_t' was not declared in this scope
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:62: warning: 'vw_set_ptt_pin' initialized and declared 'extern'
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:62: error: variable or field 'vw_set_ptt_pin' declared void
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:62: error: 'uint8_t' was not declared in this scope
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:66: warning: 'vw_set_ptt_inverted' initialized and declared 'extern'
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:66: error: variable or field 'vw_set_ptt_inverted' declared void
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:66: error: 'uint8_t' was not declared in this scope
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:71: warning: 'vw_setup' initialized and declared 'extern'
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:71: error: variable or field 'vw_setup' declared void
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:71: error: 'uint16_t' was not declared in this scope
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:90: error: 'uint8_t' does not name a type
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:96: error: 'uint8_t' does not name a type
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:99: error: 'uint8_t' does not name a type
/Users/luigipizzolito/Documents/Arduino/libraries/VirtualWire/VirtualWire.h:104: error: 'uint8_t' does not name a type
sketch_jul03a.ino: In function 'void setup()':
sketch_jul03a:18: error: 'vw_set_ptt_inverted' was not declared in this scope
sketch_jul03a:20: error: 'vw_set_tx_pin' was not declared in this scope
sketch_jul03a:21: error: 'vw_setup' was not declared in this scope
sketch_jul03a.ino: In function 'void loop()':
sketch_jul03a:28: error: 'vw_send' was not declared in this scope
Reply 8 years ago on Introduction
That is in version 1.0.6 of Arduino
Reply 8 years ago on Introduction
Hi Ploopy. I'd try using a different computer for another try at compiling. I have several different computers and often have errors on one attempt on computer 'A" but no errors when compiling on computer 'B'. With both computers running 1.0.6 My best result are usually achieved when compiling on my Linux laptop.
Reply 8 years ago on Introduction
I'll try it.
8 years ago on Introduction
is there any possibilty to send back a message from receiver site like an acknowledge?
8 years ago on Introduction
Well it appears 17.2cm antennas for both TX and RX work best. With clear line of sight I'm getting a reliable signal at 300FT (91.44meters) with the FS1000A/XY-MK-5V TX/RX modules. Since about 5mm is used in the coils on those 433MHz modules you can make antenna length about 16.7cm. Both antennas are straight (not coiled) 22ga wire. Will test tomorrow using a RXB6 433mhz receiver module with a standard FS1000A transmitter both with 17.2cm antenna.