Let's Make Robots!

Arduino RF Communication using RX & TX link Modules

RF communication link between two Arduinos
  • Control method:

This Tip/Walk-Through will guide you through a simple one way communication link between two Arduinos.

The Project uses these RX/TX Radio Frequency (RF) Link Modules.

Edit :- Links updated - old ones where retired .Boooooo

(Thanks to Fritsl for bringing these cool babies to my attention ,i just had to try them out on my arduino and i am well impressed with thier performance )

Both Transmitter and Receiver together cost less than two tin cans with a piece of long string connected between !!!!!!!

You will have to download the Virtualwire.h library and install it to your arduinos  hardware/libraries folder

More info on the Virtualwire communications library can be found http://www.open.com.au as pdf file


Receiver :- Basic link Arduino Mega using a  RF Link Receiver - 315Mhz


Only Four wires are required, i have used a audio cable from a cd drive which i rewired to accept the cables (neat).

Yellow is the Antenna - approx 30cm long (other end connected to thin air)

Red is connected to 5 Volts

White is the Received data (in my case connected to pin 23 on the mega - can be easily assigned to another pin)

Black is Ground (it has three separate ground pins all connected together!!!!!!)


 // Receiver Code     (as the code is very short i post direct here, its adapted from Mike McCauleys pdf file above)


// RF Link using VirtualWire to receive messages
// simplex (one-way) receiver with a 315MHz RF Link Receiver module
// rx pin 23 on mega


#include <VirtualWire.h>  // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
    Serial.begin(9600);    

// Initialise the IO and ISR
    vw_set_ptt_inverted(true);    // Required for RX Link Module
    vw_setup(2000);                   // Bits per sec
    vw_set_rx_pin(23);           // We will be receiving on pin 23 (Mega) ie the RX pin from the module connects to this pin.
    vw_rx_start();                      // Start the receiver
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // check to see if anything has been received
    {
    int i;
     // Message with a good checksum received.
        
    for (i = 0; i < buflen; i++)
    {
        Serial.print(buf[i]);  // the received data is stored in buffer
        }
    Serial.println("");
     }
}


 

 

 


 Transmitter :- Basic link using an  Arduino Duemilanova and a  RF Link Transmitter - 315Mhz


 

This also has 4 wires and the same trick with the cd audio socket to make neat connection.

Black connected to Ground

White is the transmit data cable connected to pin 3 on the Arduino (however this is easy to re-assign to suit your needs)

Red is the power supply connected to 5 Volt pin on Arduino (actually you can apply anywhere between 2 Volts and 12 Volts - the higher the voltage the stronger the RF signal)

Grey (sticking out of the Top is the Antenna - around 30cm long


// Transmitter Code


 

// RF Link using VirtualWire to Transmit messages
// simplex (one-way) receiver with a 315MHz RF Link Transmitter module
// tx pin 3 on Duemilanova (arduino)

 
#include <VirtualWire.h>  // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
     // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for RF Link module
    vw_setup(2000);                 // Bits per sec
    vw_set_tx_pin(3);                // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs.
}

void loop()
{
    const char *msg = "LMR-II Rocks";       // this is your message to send

   vw_send((uint8_t *)msg, strlen(msg));
   vw_wait_tx();                                          // Wait for message to finish
   delay(200);
}


 


Power them both up and switch on the Serial monitor to 2400 Baud on the receiving Arduino (mega in our case)

 

Then Hey Presto Communication link established......... up to 152.4 Meters (thats 500 feet in old currency)

I tested (Tx at 5 Volts) from my Basement to roof (5 stories) no problem ( Mega impressed)

Ending Side Mystery :- Why did i use pin 23 as the Rx pin on the Arduino Mega ?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

arduino pro mini not working....

i hope this is alive yet, i've tried all combinations to make this thing works, i even tried with duemilanove but don't receive any feedback in the serial monitor, i've done all the steps in the tutorial 14 times. my goal is to make the comunication with this boards (arduino pro mini) i don't even want to change the program, just as it is...heeeelp please!!!

Ignore the previous message, I needed to use Serial.write instead or print.

I would still like to convert the received message to a string though, any ideas?

You'll have to add the bytes one by one into the string

I'm not sure if this works but have a while loop that exits when the received byte is a pre determined exit byte. For example, I would start my string with a "#" symbol, and end my string with a "$" symbol.

inByte = readRF();

if(inByte == '#') {

inByte = readRF();

String string = "";

while(inByte != "$") {

string += inByte;

inByte = readRF();

}

}

this is really pseudocode, I haven't actually tried this yet, I just wrote it in the comment box.

you may have to add delays for the RF module to receive the next byte.

Hi,

I am not sure what is going on but I get ascii code coming up in the serial monitor of the receiving arduino. If I send  

const char *msg = "AA";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();                  
delay(200);

I get 6565 in the serial monitor.

Can anyone help?

 

I found the sloution I instaled the virtualwire V1.0 and V1.1 and V1.4 non of them worke. But when i installed V1.9 it basically worked.Sorry for the troubles and thank you 

hi guys,,,

when i tryed to verify reciver code (from example>virtualWire>reciver)

it shows me this mistake

"vw_set_inverted" was not declared in this scope

 

PLZ help i tried every thing non is working .......

I'm thinking your library isn't installed correctly.

Thank you for the reply

I create a folder(libraries) in the target save folder

Then i put virtualwire folder there

What fo you think ???

I know in Mac OS you have to put it inside the package (Right Click on Arduino.app >> Show Package Contents >> Java >> libraries)

for Windows I think it goes inside Documents >> Arduino >> libraries

the problem still there ....

this is my code

#include <VirtualWire.h>

#undef int

#undef abs

#undef double

#undef float

#undef round

void setup()

{

    Serial.begin(9600); // Debugging only

    Serial.println("setup");

 

    // Initialise the IO and ISR

    vw_set_ptt_inverted(true); // Required for DR3100

    vw_setup(2000); // Bits per sec

 

    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

    {

int i;

 

        digitalWrite(13, true); // Flash a light to show received good message

// Message with a good checksum received, dump it.

Serial.print("Got: ");

for (i = 0; i < buflen; i++)

{

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

   Serial.print(" ");

}

Serial.println("");

        digitalWrite(13, false);

    }

}