Using rf link reciever and transmitter with arduino

29,741 Views
Using rf link reciever and transmitter with arduino

style="display:inline-block;width:468px;height:15px"
data-ad-client="ca-pub-3507530299542268"
data-ad-slot="6937426494">

Need a simple, one-way, wireless data transmission for your microcontroller projects? This tutorial will guide you to setup wireless link between two arduinos using cheap rf link transmitter and reciever(315Mhz).

For this you will need

  1. Two arduinos
  2. Rf link transmitter
  3. Rf link reciever

We will be using Virtualwire.h library for this project.Download the library from here and copy paste it in the library folder of your arduino IDE.

Reciever

Connect the reciever to arduino as shown in below image

The data pin(yellow wire) can be connected to any pin on arduino as per your needs.

The brown wire on the first pin of the reciever is the antenna wire.It should be approx. 30 to 35 cm long.The other end should be left open.

Reciever code


#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(4);           // We will be receiving on pin 4 i.e 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

Connect the transmitter to the arduino as 

The data pin(yellow wire) can be connected to any pin on arduino as per your needs.

The brown wire on the last pin of the reciever is the antenna wire.It should be approx. 30 to 35 cm long.The other end should be left open.

Transmitter code


#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 as per your needs  
}

void loop()
{
    const char *msg = "Community of Robots";       // this is your message to send

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

After uploading the reciever and transmitter codes open the serial monitor of your arduino IDE and you should see Community of robots printed on the serial monitor.

Should you have any questions then please post in the forum

Thanks for reading.

Comments

ErokOverflow's picture

A better or short way?

Hi all -

Is there a way to bypass the installation of an Arduino at the transmitter?, I mean, just only to have an arduino Nano at the receiver, and in the transmitter side any simple module? I'm thinking to take this installation to a another scale, the production scale :) and is a little expensive to put double Arduinos to a 5000 products... Can you help me?

jupiterelectrnics's picture

Thanks for such an amazing

Thanks for such an amazing post, just got to know much on such topics...!!!! air velocity transmitter

Subhendu's picture

Rf link

Can u please tell how to do this. How can i tell a Arduino robot fitted with a Rf receiver to come to the place where the RF transmitter is.

OR

How can i tell the Arduino Robot to go to a particular place within a room.?

Add a new comment

Login or register to post comments

New to community of robots ?

Ratings

0

Advertisement