RF link transmitter and Receiver pair

``Hi all!

I am totally new to the us of RF modules and I just got a pair of 315mhz from cutedigi.

http://www.cutedigi.com/wireless/non-2-4ghz/rf-link-transmitterreceiver-pair-virtual-wire-for-arduino.html

And I am using an arduino Mega for the transmitter and an arduino UNO for the receiver.
I followed the example code given in the virtualwire.h library given below:

Transmitter

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

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
}

void loop()
{
    const char *msg = "hello";

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}

The receiver code:

// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

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(buf[i], HEX);
	    Serial.print(" ");
	}
	Serial.println("");
        digitalWrite(13, false);
    }
}

My problem is that I do not get anything at all on the serial monitor, except for “setup”. I do get the led in 13 to be completely lit up on both arduino boards. But I get no message at all… Can anyone help me out? I am programming the Mega (transmitter) then I am plugging it into an alternate power source. Then I upload the receiver code in the UNO and leave it plugged into the computer, so I can monitor the serial window… But there is nothing!

Any help would be greatly appreciate it… I just need to pass a single character or number from transmitter to receiver… nothing major…

Thanks!
Totally lost!

You have soldered 1/4-wave antenna wires to the modules?

I haven't used that library, but the example on the site you linked to had a call to vw_set_rx_pin() in the receiver setup code and your code doesn't. Have you tried running the examples exactly as they are?

Also, please use [ code ] [ /code ] tags when posting code.

You should use : for the transmitter

#include <VirtualWire.h>

void setup()
{

  pinMode(13, OUTPUT);

  vw_set_ptt_inverted(true);  
  vw_setup(2000);            // Bits per sec
  vw_set_tx_pin(3);          //Tx pin
  
}


void loop()
{
  
  delay(100);               //Send a message every half second

  
  char *msg = "12321";
  digitalWrite(13, HIGH ); // Flash a light to show transmitting
  vw_send((byte *)msg, strlen(msg));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, LOW);


}

and : for the receiver.

#include <VirtualWire.h>


int i =0;
int msg_received = 0;

void setup()
{

  Serial.begin(9600);
  Serial.println("Started");
  
  vw_set_ptt_inverted(true); 
  vw_setup(2000);	         // Bits per sec
  vw_set_rx_pin(2);              //Rx pin
  vw_rx_start();               

  pinMode(13, OUTPUT);  

}

void loop()
{


  byte buf[VW_MAX_MESSAGE_LEN];
  byte buflen = VW_MAX_MESSAGE_LEN;

 
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    
    digitalWrite(13, HIGH);
    
    Serial.print('\n');
    Serial.println("Receiving data");
    Serial.print('\n');
    
    for (i = 0; i < buflen; i++)
    {
      Serial.print(buf[i]);
    }
    
    for (i = 0; i < buflen; i++)
    {
      buf[i] = buf[i] -48;
    }
    Serial.print('\n');
    for (i = 0; i < buflen; i++)
    {
      Serial.print(buf[i]);
    }
    
    Serial.print('\n');
    Serial.print("------------------------");
    
    
    delay(10);
    digitalWrite(13, LOW);
    
  }
}

Dont forget to use the lastest librairy virtualwire 1.14.

johnyboy:
You should use : for the transmitter

#include <VirtualWire.h>

void setup()
{

pinMode(13, OUTPUT);

vw_set_ptt_inverted(true); 
  vw_setup(2000);            // Bits per sec
  vw_set_tx_pin(3);          //Tx pin
 
}

void loop()
{
 
  delay(100);              //Send a message every half second

char *msg = “12321”;
  digitalWrite(13, HIGH ); // Flash a light to show transmitting
  vw_send((byte *)msg, strlen(msg));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, LOW);

}




and : for the receiver.



#include <VirtualWire.h>

int i =0;
int msg_received = 0;

void setup()
{

Serial.begin(9600);
  Serial.println(“Started”);
 
  vw_set_ptt_inverted(true);
  vw_setup(2000);         // Bits per sec
  vw_set_rx_pin(2);              //Rx pin
  vw_rx_start();

pinMode(13, OUTPUT);

}

void loop()
{

byte buf[VW_MAX_MESSAGE_LEN];
  byte buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
  {
   
    digitalWrite(13, HIGH);
   
    Serial.print(’\n’);
    Serial.println(“Receiving data”);
    Serial.print(’\n’);
   
    for (i = 0; i < buflen; i++)
    {
      Serial.print(buf[i]);
    }
   
    for (i = 0; i < buflen; i++)
    {
      buf[i] = buf[i] -48;
    }
    Serial.print(’\n’);
    for (i = 0; i < buflen; i++)
    {
      Serial.print(buf[i]);
    }
   
    Serial.print(’\n’);
    Serial.print("------------------------");
   
   
    delay(10);
    digitalWrite(13, LOW);
   
  }
}




Dont forget to use the lastest librairy virtualwire 1.14.

Thank you! I do have the latest library, it took me awhile to realize why I was getting so many error messages and I finally updated the library. I will try your code and see if it works.

MarkT:
You have soldered 1/4-wave antenna wires to the modules?

As far as the antenna wires, the modules are not that far apart so I really do not need the antenna right now. I have them a few feet apart, I am just testing at this point.

Thanks to all of you and I will probably be back.

Yesenia:
As far as the antenna wires, the modules are not that far apart so I really do not need the antenna right now.

I wouldn't make that assumption until you have got it working.