RF links using virtualWire.h not working

hello guys,
i am making a simple wireless communication using RF links and virtual wire, but seems not it’s not working
these are the RF links that i am using (433 Mhz) :
http://www.ekt2.com/products/productdetails?ProductId=3f806822-c96b-43c6-8b93-153c980a4e2d
and picture in the attachment files

i am thinking not the Antennas might be a problem

Transmitter:
Data pin is connected to PWM pin 3 of arduino
GND to GND from arduino
VCC to +5 from arduino
antenna dimension is 25cm (copper wire like half a millimeter)

Receiver:
Data pin is connected to PWM pin 10 or arduino
GND to GND of arduino
VCC to +5V of arduino

Pin 2 of arduino is connected to LED
antenna dimension is 32cm (copper wire like half a millimeter)

TX :

//Transmitter

#include <VirtualWire.h>

void setup(){
  Serial.begin(9600);
  
  vw_setup(2000);
  vw_set_tx_pin(3);
}

void loop(){
  if(Serial.available()){
    char c = Serial.read();
    
    if(c == '1'){
      
      vw_send((uint8_t *)c, 1);
    
    }else if(c == '0'){
    
      vw_send((uint8_t *)c, 1);
    
    }
  }
}

RX :

//Reicever

#include <VirtualWire.h>

void setup(){
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  
  vw_setup(2000);
  vw_set_rx_pin(10);
  vw_rx_start();
}

void loop(){
  
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   uint8_t buf[buflen];
   
   if(vw_get_message(buf, &buflen)){
     for(int i = 0; i < buflen; i++){
       if(buf[i] == '1'){
         digitalWrite(2, HIGH);
       }
       else if(buf[i] == '0'){
         digitalWrite(2, LOW);
       }
     }
   }
    
   
}

using RF links

For which you provided no links and no schematics.

You've said nothing about antenna design, or how far apart the devices are.

info provided

It’s a little hard to see, but it looks like you have the Tx pin on the transmitter connected to pin 8 or 9 on the Arduino. You transmit sketch says it should be conneted to pin 3 ( vw_set_tx_pin(3); ).

If that doesn’t help, you should make sure your Rx pin is hooked up to pin 10 on the Arduino.

info provided

Not much info on that link you sent. Yes, there’s a PDF that gives a little rudimentary information, but no real datasheet, and you certainly didn’t tell us which pins on the Arduino are connected to which pins on the modules.

You are asking for help from people who do this for their own reasons, be it fun, or to learn from the questions, or just because we like to get beginners off to a good start. The least you could do is to give us all the details so we don’t have to guess by looking at low-res pictures.

sorry about that, about the datasheet that's all i could find about these RF links :S i searched a lot for this type even on ebay for maybe someone have uploaded the datasheet

Transmitter: Data pin is connected to PWM pin 3 of arduino GND to GND from arduino VCC to +5 from arduino antenna dimension is 25cm

Receiver: Data pin is connected to PWM pin 10 or arduino GND to GND of arduino VCC to +5V of arduino

Pin 2 of arduino is connected to LED antenna dimension is 32cm

Your picture shows a red wire that REALLY looks like it's not connected to pin 3.

lar3ry: Your picture shows a red wire that REALLY looks like it's not connected to pin 3.

ah you're right the first picture sorry about that but in fact i changed it

i just wired the antennas thinking that maybe it's loosing signal from the rf link the antennas are copper wires about a half a millimeter it started to work right now but it's not like 99% working because sometimes it's like loosing signal so how can i correct that ?

so how can i correct that ?

Buy better radios.

Hi there firashelou

I have these working perfectly and they actually work extremely well !
And virtualwire totally rocks !! Well done and thank you to the virtualwire guys !
What code are you using ?
Did you include virtual wire the library ?
In testing the modules keep them well away from the breadboard i have them on wires standing up off the breadboard …like a daddy long legs spider :slight_smile:
The antenna wire should be between 14 and 17cm’s (I haven’t experimented with longer or shorter yet…let me know how your experiments go :slight_smile:
And make sure the are at least more than a metre apart for… I think this is one of your major problems… use two breadboards or just plug them straight into the arduinos and make sure they are at least 2 to 3m apart !
I will check the pictures you posted now and check if wiring is correct etc.
I have just checked…
Make sure not to have the modules on the breadboard otherwise you will have capacitance and inductance noise and some odd problems like noise etc.
When I test them they are completely separated and on opposite side of the room or house.
And use the serial monitor to check the incoming signal.
I just have the transmitter connected to one notebook and the receiver to another and I use the IDE serial monitor to check the received character stream(incoming data) which should be ‘hello world’ according to the example.
Use the code I sent you and the pins i selected to test and make it work first …them experiment :slight_smile:
I also noticed that the spec sheet doesn’t really mention any max baud rate/bps so once they are working experiment more,

I hope this helps you

Kind regards
Denman

Here’s the transmit code I use:

#include <VirtualWire.h>

void setup() {
//pinMode(13,OUTPUT);
// vw_set_ptt_inverted(true); //

vw_set_tx_pin(7);
vw_setup(2000);// speed of data transfer Kbps
}

void loop()
{
send(“hello world”);
delay(1000);
}

void send (char *message)
{
//controller=“1” ;

vw_send((uint8_t *)message, strlen(message));
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 here’s the receive code:
/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 3
*/
#include <VirtualWire.h>

byte message[VW_MAX_MESSAGE_LEN]; // a buffer to hold the incoming messages
byte msgLength = VW_MAX_MESSAGE_LEN; // the size of the message

void setup()
{
Serial.begin(9600);
Serial.println(“Ready”);

// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
vw_set_rx_pin(3);

}

void loop()
{
if (vw_get_message(message, &msgLength)) // Non-blocking
{
Serial.print("Got: ");
for (int i = 0; i < msgLength; i++)
{
Serial.write(message*);*

  • }*
  • Serial.println();*
  • }*
    }

denman: In testing the modules keep them well away from the breadboard i have them on wires standing up off the breadboard ...like a daddy long legs spider :-) The antenna wire should be between 14 and 17cm's (I haven't experimented with longer or shorter yet..let me know how your experiments go :-) And make sure the are at least more than a metre apart for.... I think this is one of your major problems.... use two breadboards or just plug them straight into the arduinos and make sure they are at least 2 to 3m apart !

That's some really good information denman! I have a couple of similar modules, and was a little disappointed that they would not reliably get data across from about 25 metres away, through a window. I'll definitely get them up off the breadboards. I really should have thought of that, but it's been a little over 50 years since I worked on radars and radios. Have you found that a lower bps helps with reliability as well? I'm running mine at 2000.

Big thanks Denman amazing info :)

by the way about the antennas, the datasheet says it should be 32cm for receiver and 25cm for transmitter, now i am using these antennas dimensions but before i used to put a small piece of wire and it worked fine with separate breadboard so now i will change the breadboard, i guess antenna have influence on the distance right ? if i want to get 150 meter coverage i should use the antennas of datasheet ?

firashelou: hello guys, i am making a simple wireless communication using RF links and virtual wire, but seems not it's not working these are the RF links that i am using (433 Mhz) :

antenna dimension is 25cm (copper wire like half a millimeter)

Receiver: antenna dimension is 32cm (copper wire like half a millimeter)

Those antenna wires should be half-dipoles, in other words each 17cm long.

but the datasheet of these modules says it should be 32cm for receiver and 25cm for transmitter so is this for the maximum 200 meters coverage ?

The datasheet is wrong. 17 cm = 1/4 wavelength. The antenna will work better if you have a "ground plane", i.e. a sheet of metal or some 1/4 wavelength wires extended perpendicular to the base, and grounded. Or buy a good antenna.

i attached now antenna to the transmitter like the one in this picture and when extended it's length is a little bit more than 32cm : http://thumbs1.ebaystatic.com/d/l225/m/mPyBqmKlT8kMOvD0H5-SCzA.jpg

and for the receiver i attached this in the picture and antenna in contact with it from a cheap rc car : http://usih.merchantrunglobal.com/ImageHosting/ViewImage.aspx?GlobalID=1004&MerchantID=10602&ImageID=3163&DisplaySize=-1&ListingID=25059