RF 315/433 MHz Transmitter-receiver Module and Arduino

About: Maker, PCB designer , electronics instructor from Jordan just one word ! I Adore electronics follow me on FB https://www.facebook.com/Mohannad-Rawashdeh-Raw-774983565988641/

Intro: RF 315/433 MHz Transmitter-receiver Module and Arduino

Hi every body , I searched on Instructables about a simple RF Transmitter-receiver module , Which is used in Remote control for cars , or to control simple tasks , like control relay on/off unfortunately I didn't find What I need   , So i decided to write a simple artical about this transceiver and How we can connect it with arduino  and program it .

Materials: 

at first let's take a look for what we need :

1)  2 Arduino Board "I used Uno" 

2) RF 315MHz or 433MHz transmitter-receiver module .

3) jumper wire .

4) BreadBoard .

5)External Power supply (9V Battery *2) "Optional" .

Step 1: Module Specification

This module has a specification for :

Transmitter : 

Working voltage: 3V - 12V  fo max. power use 12V
Working current: max  Less than 40mA max , and min 9mA
Resonance mode: (SAW)
Modulation mode: ASK
Working frequency: Eve 315MHz  Or  433MHz 
Transmission power: 25mW (315MHz at 12V)
Frequency error: +150kHz (max)
Velocity :  less than 10Kbps

So this module will transmit up to 90m in open area .

Receiver :

Working voltage: 5.0VDC +0.5V
Working current:≤5.5mA max
Working method: OOK/ASK
Working frequency: 315MHz-433.92MHz
Bandwidth: 2MHz
Sensitivity: excel –100dBm (50Ω)
Transmitting velocity: <9.6Kbps (at 315MHz and -95dBm)

 the use of an optional antenna will increase the effectiveness of your wireless communication. A simple wire will do the trick.

Step 2: Schematics

the connection for this module is very easy .

for Transmitter :

Vcc >>>>5V
ATAD>>>D12"You can change it as you like from Software" .
Gnd >>> Gnd

Receiver :

Vcc>>>>5V
Data>>>D12
Gnd>>>Gnd

Step 3: Arduino Virtual Wire Library

Fortunately , There is a popular Library for arduino Called "" VirtualWire"" Created by Mike McCauley


VirtualWire is an Arduino library that provides features to send short messages, without addressing, retransmit or acknowledgment, a bit like UDP over wireless, using ASK (amplitude shift keying). Supports a number of inexpensive radio transmitters and receivers.

This library allow You to send and receive data"byte" and string easily ,

First Download the library from Here .

after extract the folder, and move it to " Libraries " on the arduino Folder

this is a simple code , it will send character '1' and after 2 sec will send character '0' and so on .

this code for transmitter :

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include

char *controller;
void setup() {
pinMode(13,OUTPUT);
vw_set_ptt_inverted(true); //
vw_set_tx_pin(12);
vw_setup(4000);// speed of data transfer Kbps
}

void loop(){
controller="1" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(2000);
controller="0" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,0);
delay(2000);

}

and this is code for receiver :

The D13 LED On the arduino board must be turned ON when received character '1' and Turned Off when received character '0'


//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include

void setup()
{
vw_set_ptt_inverted(true); // Required for DR3100
vw_set_rx_pin(12);
vw_setup(4000); // Bits per sec
pinMode(13, OUTPUT);

vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
{
if(buf[0]=='1'){


digitalWrite(13,1);
}
if(buf[0]=='0'){
digitalWrite(13,0);
}

}
}


Step 4: One Transmitter, Multi Receiver

You can connect many Receiver and send a Data from One Master Transmitter .

For more secret you may need Encoder-Decoder .

Encoder is a circuit that changes a set of signals into a code .

Decoder is a circuit that changes a code into a set of signals .

if You need an Encoder/Decoder  IC , You  can use PT2262 and PT2272   

this is a simple example , for 1 master Transmitter , 2 ReceiverS , and send a command through Serial for a receiver To Turn LED On/Off .

Tx code :

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
char *controller;
void setup() {
  pinMode(13,OUTPUT);
vw_set_ptt_inverted(true); //
vw_set_tx_pin(12);
vw_setup(4000);// speed of data transfer Kbps
}

void loop(){
controller="A1"  ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(1000);
digitalWrite(13,0);
delay(1000);
controller="B1"  ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(1000);
digitalWrite(13,0);
delay(1000);

}


First Rx 

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
void setup()
{
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_set_rx_pin(12);
    vw_setup(4000);  // Bits per sec
    pinMode(13, OUTPUT);

    vw_rx_start();       // Start the receiver PLL running
}
    void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if((buf[0]=='A')&&(buf[1]=='1')){   
      digitalWrite(13,1);
      delay(1000);
      }  
      }
      else{
  digitalWrite(13,0);
    }

}

 Second Rx 
 

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
void setup()
{
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_set_rx_pin(12);
    vw_setup(4000);  // Bits per sec
    pinMode(13, OUTPUT);

    vw_rx_start();       // Start the receiver PLL running
}
    void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if((buf[0]=='B')&&(buf[1]=='1')){   
      digitalWrite(13,1);
      delay(1000);
      }  
      }
      else{
  digitalWrite(13,0);
    }

}

Step 5: Virtual Wire ..... Inside

VirtualWire is an Arduino library that provides features to send short messages, without addressing, retransmit or acknowledgment, a bit like UDP over wireless, using ASK (amplitude shift keying). Supports a number of inexpensive radio transmitters and receivers.

Messages are sent with a training preamble, message  length and checksum. Messages are sent with 4-to-6 bit encoding for good DC balance, and a CRC checksum for message integrity.

Can we use Serial communication with ? answer is No 

ASK receivers require a burst of training pulses to synchronize the transmitter and receiver, and also requires good balance between 0s and 1s in the message stream in order to maintain the DC balance of the message, UARTs do not provide these. They work a bit with ASK wireless, but not as well as this code.

The full function for this library :

To use the VirtualWire library, you must have

#include <VirtualWire.h>

To select the Transmitter Data  Pin , void :

vw_set_tx_pin

To select the Receiver Data Pin , void :

vw_set_rx_pin

Setup the speed of transmission , The speed of Tx must be as same as On Rx .

the speed will be a Number of Bit Per Second between 0-9600 , for short distance you can use fast speed , For long distance "Up to 90m" you must use lower transmission speed as much as possible .

vw_setup(uint16_t speed);

 Start the receiver PLL running ,You must do this before you can receive any messages,Call 

vw_rx_start();

You must do this before you can receive any messages. When a messageis available (good checksum or not), vw_have_message() will return true.

vw_rx_stop();

Block and wait until the transmitter is idle,called :

vw_wait_tx();

Block and wait until a message is available from the receiver, call :

vw_wait_rx();

Send a message with the given length, call :

vw_send(uint8_t* buf, uint8_t len);

Returns true if an unread message is available from the receiver.,call :

vw_have_message();

10 People Made This Project!

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Furniture Contest 2018

    Furniture Contest 2018
  • Fix It! Contest

    Fix It! Contest

322 Discussions

0
None
Mohannad Rawashdehdharang1

Answer 19 days ago

LED has 2 pin (Anode & Cathode) , connect the anode pin to arduino digital pin (Pin D5 for example) and the cathode to a resistor (330 Ohm) and the other pin of the resistor to Gnd , simple isn't it ?

0
None
Mohannad RawashdehAhmedL31

Answer 2 months ago

actually nothing ! just upload the tx code to both tx circuit and change the character you want to send from each tx , so at least the rx will know from which tx the message came from.

0
None
jtancrede

Question 4 months ago

My car has the tpms system to monitor tire pressure. It transmits on 443MHz. Can I use this module to pick up those signals to display the tire pressure?

1 more answer
0
None
el_Kalebjtancrede

Answer 4 months ago

I might be wrong, but such device might use a encoder/decoder to transmit, therefore even though you manage to catch the transmission you might not be able to read it properly without the right decoder. But try along! :)

0
None
ÏmåN11

Question 4 months ago

i have a project of electromagnetic field meter, when you are an experiance for this project please help me

0
None
fitlife

Question 5 months ago on Step 3

Great Instructable, Mohannad! You mentioned lowering the baud rate for longer distances. How low do you mean ( 1? or 500? ) for can it go. Does the lower rate mean a more reliable transmission? Also what I have read is that the receiver and transmitter antennas need to be a certain length for the 433mhz, is that correct or if it is longer does to transmit further? One last question can you coil, the antenna mostly so my cats don't chew on it or does that lower the effectiveness of the antenna.

0
None
NucomJ

6 months ago

hello, do I need to put antenna to my transmitter and receiver, because my receivers seems to not receive anything or maybe because it doesn't have an antenna, but I already tried all the example codes for receiver nothing works

this is the receiver that I'm using

thanks

receiver.jpg
0
None
Kan Yu

7 months ago

One question, the LED connected to the receiver data pin was always on when nothing was connected to the transmitter data pin. I tried to feed 5V to the data pin of the transmitter and the LED stopped glowing, Is this how it's supposed to work? (HIGH on transmitter data pin gives LOW on receiver data pin and vice versa).

0
None
Kan Yu

Question 7 months ago

One question, the LED connected to the receiver data pin was always on when nothing was connected to the transmitter data pin. I tried to feed 5V to the data pin of the transmitter and the LED stopped glowing, Is this how it's supposed to work? (HIGH on transmitter data pin gives LOW on receiver data pin and vice versa).

0
None
MussaC

9 months ago

Thanks, I appreciate that. But can I use HT12E and HT12D as encoder and decoder instead of PT2262 and PT2272 ?

0
None
SandunS1

9 months ago

I got no knowledge on RF transmissions, so can you give me some tips or links or whatever clue where I could gain such knowledge.I appreciate your help!And also pretty interesting work.

0
None
jackie789

10 months ago

Is it possible to increase the transmission range from 90m to 500m?

0
None
GiacomoR5

10 months ago

why do i have to use 2 arduino?

can i use an arduino mega instead?