Instructables

RF 315/433 MHz Transmitter-receiver Module and Arduino

Picture of RF 315/433 MHz Transmitter-receiver Module and Arduino
RF_315Mhz_Transmitter_Receiver-500x500.jpg
RF Module 017.JPG
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" .

 
Remove these adsRemove these ads by Signing Up

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

Picture of schematics
TX.png
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
1-40 of 106Next »
spudziuvelis18 hours ago

Arduino: 1.5.7 (Windows 8), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from transmitter.pde:6:0:
C:\Program Files (x86)\Arduino\libraries\VirtualWire/VirtualWire.h:14:20: fatal error: wiring.h: No such file or directory
#include
^
compilation terminated.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

i was trying to compile trasmitter example aaaaand this error appeared

hi there!!!!!

how do i add multiple switch to transmitter and the receiver is connected to a simple numeric display where it will show which switch is switched in order?

//code for the tx
#include <VirtualWire.h>

//Assigning controller buttons to Digital Pins

int s5 = 8;
int s4 = 9;
int s3 = 10;
int s2 = 11;
int s1 = 12;
int remotePins[]= {8,9,10,11,12};//array to store pin nos

void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_setup(2000); // Bits per sec
vw_set_tx_pin(3); //Transmitter Data Pin to Digital Pin 3


for(int i = 0; i<6 ; i++)
{
pinMode(remotePins[i], INPUT);
digitalWrite(remotePins[i],HIGH);
}
/*
This is what the loop above does :-
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);

digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);*/
pinMode(groundpin, OUTPUT);
pinMode (powerpin,OUTPUT);
digitalWrite(powerpin, HIGH);
digitalWrite ( groundpin , LOW);
}//close setup

void loop()
{
char *msg2;




if (digitalRead(s1)HIGH);
{
char *msg2 = "1";//send 1 to the receiver
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}

if (digitalRead(s2)HIGH);
{
char *msg2 = "2";//send 1 to the receiver
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}

if (digitalRead(s3)HIGH);{
{
char *msg2 = "3";//send 1 to the receiver
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}

if (digitalRead(s4) HIGH);{
{
char *msg2 = "4";//send 1 to the receiver
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}

}
}}
}
}

ERROR help!


transmitter.pde: In function 'void setup()':
transmitter:19: error: 'vw_set_ptt_inverted' was not declared in this scope
transmitter:20: error: 'vw_setup' was not declared in this scope
transmitter.pde: In function 'void loop()':
transmitter:28: error: 'vw_send' was not declared in this scope
transmitter:29: error: 'vw_wait_tx' was not declared in this scope

library would be in wrong place. I had the same problem, I deleted the library downloaded it once more and it worked.

Thanks man. It Worked! Sir can i Have your email? i would like to asked some questions regarding programming wireless communicaiton. I hope it's okay, thanks.

you could send a private message on instructables itself.

Don't know if it helps. But i replaced <WProgram.h> with <Arduino.h> in virtualWire.cpp

raininmyhead6 months ago

it's possible create a 433 mhz jammers? i try but it's very difficoult!

why would you want to jam 70cm band? it's main use is for radio navigation and position finding, jamming that would be potentially a felony, and could put others in danger. jammers in general are also not legal, since by definition they create harmful interference preventing use of the band by legitimate users.
liptaka18 days ago

Very useful stuff, thanks! Is it possible that the transnitter module could communicate to more than 1 pcs receiver?

My use case would be: with 1 arduino I would like to control more (e.g. 4 pcs) relays (4 x 1 channel wireless received relay module, like this:

http://www.ebay.com/itm/NEW-DC12V-1-CH-RF-Wireless-Receiver-Relay-Module-Switch-315-433MHz-Learning-Code-/121412715478?pt=LH_DefaultDomain_0&var=&hash=item1c44c303d6

).

I assume that the arduino will send the data with different coding so only the relevant relay will get it.

Is that possible?

liptaka

Eko9881 month ago

Hi!

What is the working distance of these modules?
I tried this sketch but the Rx is blinking only when the distance of the Tx and Rx is less than 2 centimeters :/

At the best 50-100m. Maybe you are facing some problem with the antennae.

At the best 50-100m. Maybe you are facing some problem with the antennae.

letrovin Eko98829 days ago

You need an antenna e.g. a simple wire of specific length, there is a solder point for an antenna on the module. The recommended length is usually (lambda/4=)17cm, but I had better ranges with longer wire (27cm straight wire). With this antenna I got through 2 concrete walls and a distance of 20m. Now I wonder what the best antenna length would be.

R-A6 months ago

Can this be used to transmit data? i.e. let's say I have an Arduino with some sensors in a remote location, say 100m away, and I want to know what the sensor values are from another arduino, can I use this kind of setup?

raininmyhead R-A6 months ago

yes, good signal 70m

Which antenna do you use?

you could make your own antenna. Take a 30 cm long wire and coil it up.

MarkK324 days ago

First VirtualWire tutorial that led me to success, thank you my friend!

warej27 days ago

Hi there! Could someone tell me one simple thing? Mohannad wrote that it should be connected to D12 (SPI) port, but in the code I can see that Rx port number is set by:

vw_set_rx_pin(12);
So can I connect it to a different port?
In general I'd like to have two sensors in two different locations and collect their data in one arduino i.e. have 2 receivers connected to one arduino. Is it possible?
Thanks for any help :)

Franscois29 days ago

Hi there,

Hope there is someone on here who might be able to give some advice please. I want to build a tiny temp sender/receiver unit. All it need to do, is to read a temperature from about -5 °C to ± 95 °C, and send that reading via a analog or digital transmitter to a receiver. The distance is not very important and should only be able to send it about 10 meters. The main focus will be on 'tiny' and 'low' power consumption, and with a low voltage use. I'm not up to date with all the latest devices out there and will really appreciate it if someone can tell me which parts I can link up to get the result. Thanks in advance !!!

hola buen dia, podian ayudarme,}

tengo arduino uno, el cual tengo que conectarle una pantalla LCD 16x2, al igual que un modulo bluetooth, y enviar la informacion por via bluetooth a 20mtros. el msj que se envia y se visualiza en ambas pantallas es el que entra al arduino, de un enoder´s. que tiene 4 canales de salidas, en forma QAM. los cuales 2 son ascendente y 2 descendente. espeo su ayuda con la programacion. porfavor

pudes ampliarme la informacion a mi correo jadasupport@ gmail.com

hola, queria saber que programa estan usando para correr el programa del transmisor y receptor. me podian ayudar porfavor

hola, queria saber que programa estan usando para correr el programa del transmisor y receptor. me podian ayudar porfavor

hola, queria saber que programa estan usando para correr el programa del transmisor y receptor. me podian ayudar porfavor

hola, queria saber que programa estan usando para correr el programa del transmisor y receptor. me podian ayudar porfavor

smalik0071 month ago
Bigdee121 month ago

hi, can anyone help me please. I'm a doing a wireless weather station project. I have two sensors connected to my arduino micro-controller. sensor dht11 connected to A0 and the bmp085 sensor connected to A4 and A5. the codes i have for my sensors i can see the humidity, temperature and pressure via the serial port.

on the Rx side my Rx module is connected on the arduino on pin 12 Tx module connected to pin 11.

But i can not get it to to wirelessly transmit between my 433Mhz Tx and the Rx. Anyone with a code to make this work. when i combile Mohannad Rawashdeh's Transmitter and receiver codes i get no errors with the combiler, but i can not get anything on my receiver (LCD). Thank you in advance. i want temperature, humidity and pressure displayed on my LCD.

TaitS12 months ago

Mohannad, This is a really helpful instructable. It would be even more helpful if it was de-jargonized. Could you please explain the acronyms before you start using them, and any other code-language that would not be immediately transparent to beginners? It would turn a good instructable into a great one.

deji6 months ago

Hi , can you help me please, when i compile the program for Transmitter I get "vw_set_ptt_inverted" was not declared in this scope. What I am doing wrong .Thanks

sssww1234 deji2 months ago

make sure that there is only one virtualwire library in arduino folder.set the baud rate in above pgm to make it run

zcui deji5 months ago

try this downlaod it worked for me and try to import it in zip form http://www.pjrc.com/teensy/td_libs_VirtualWire.html

how to replace whit new library?

deji zcui5 months ago
It works , thanks is very usefull
TimoP1 made it!2 months ago

Thanks for a nice instructible! Hooked up the transmitter and receiver with two Arduinos and got them working.

The VirtualWire library did throw some errors first with the Arduino 1.0.5 software version, but they were easily fixed as follows:

1) in the VirtualWire.cpp file, replace the line #include <wiring.h> with #include <Wire.h>

2) in the VirtualWire.h file, replace #include "WProgram.h" with #include "Arduino.h"

For the transmitter and receiver codes, added the line #include <Wire.h> before the line #include <VirtualWire.h>.

In case anybody is interested, note that it is also possible to transmit data and ascii text with this setup. Below is my code for doing that.

To transfer text, open up the Serial Monitor, type text to the input box and press enter. The text is output to the Serial Monitor on the receiving Arduino.

TRANSMITTER CODE:

//simple Tx on pin D12

//Written By : Mohannad Rawashdeh

// 3:00pm , 13/6/2013

//http://www.genotronex.com/

//..................................

// added serial data transmission

// 22.9.2014/Timo.Peltonen [at] iki.fi

#include <Wire.h>

#include <VirtualWire.h>

#include <Serial.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 bps

Serial.begin(9600); // Serial Monitor used to enter data

Serial.println("Ready to transmit. Write data here.");

}

void loop(){

if (Serial.available() > 0) { // read data from PC Serial Monitor

controller = ""; // delete any old data

controller[0] = (uint8_t)Serial.read(); // read the incoming byte

controller[1] = '\0'; // terminate string with a null character

Serial.print(controller[0]); // output character on Serial Monitor

if(controller[0]==13)

Serial.println(""); // write a newline for enter

digitalWrite(13,1); // turn led on

vw_send((uint8_t *)controller, strlen(controller)); // send string over radio link

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(13,0); // turn led off

delay(100); // wait a little while before the next character

}

}

RECEIVER CODE:

//simple Rx on pin D12

//Written By : Mohannad Rawashdeh

// 3:00pm , 13/6/2013

//http://www.genotronex.com/

//..................................

// added serial data reception

// 22.9.2014/Timo.Peltonen [at] iki.fi

// NOTE: the receiver needs a better antenna; solder a wire to the receiver ANT connector!

#include <Wire.h>

#include <VirtualWire.h>

#include <Serial.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);

Serial.begin(9600); // open Serial Monitor to PC

vw_rx_start(); // Start the receiver PLL running

Serial.println("Receiving...");

}

void loop()

{

uint8_t buf[VW_MAX_MESSAGE_LEN];

uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking

{

digitalWrite(13,1); // turn on led

if(buflen == 1) { // if just one character per time

if(buf[0]==13)

Serial.println(""); // newline

else

Serial.print(char(buf[0]));

}

else

for(int n=0;n<buflen;n++) {

if(buf[n]==13)

Serial.println(""); // newline

else

Serial.print(char(buf[n]));

Serial.println(""); // insert newline at end of buffer

}

digitalWrite(13,0); // turn off led

}

}

unnamed.jpg
Indergod3 months ago

Hi,

In your multi-receiver example, the transmitter is defining the controller code "A1" or "B1" in the sketch before sending it via:

vw_send((uint8_t *)controller, strlen(controller));


is it possible to define the controller code from a client.read instead?

I'm getting error messages as my client.read if of type "char", whereas the above send is looking for it to be of type "char const*" ???

Any help appreciated :-)

zhaymoor3 months ago

thank you muhannad but I want to ask you about the "uint8_t*" ,, what does it mean?

uint8_t is the same as a byte.


its shorthand for: a type of unsigned integer of length 8 bits

1-40 of 106Next »