Is my RF setup good?

Hi,

sorry for all the recent posts just need some guidance still to get me started

So I have my RF transmitter which is a Radiometrx TX2S-433-40-3V-10mW - datasheet: http://www.radiometrix.com/files/additional/tx2s.pdf
and my reciever which is a Radiometrix WRX2 - datasheet: http://radiometrix.com/files/additional/wrx2.pdf

according to the WRX2 datasheet these two are matching so should be able to communicate.

I have attached a pictures of how I have setup the two and here I will describe what I have put into the pins

reciever - WRX -
PIN 1 - aerial
PIN 2 - NOTHING
PIN 3 - NOTHING
PIN 4 - ground (0v)
PIN 5 - 5v
PIN 6 - NOTHING
PIN 7 - data line which goes to my arduino

Transmitter - TX2S
PIN 1 - aerial
PIN 2 - NOTHING
PIN 3 - ground (0v)
PIN 4 - data line from arduino through the 11k ohm and a 6k ohm resistors then to the data line (this is to bring the 5v output to less than 4v)
PIN 5 - 3.3v

From the pictures you should be able to see my homebrew aireal which I guess would work and I do know there is a connection between the exposed part and input to the breadboard.

Basically I just followed this tutorial (http://www.youtube.com/watch?v=e8RhXtst7ME) and used VirtualWire to try to connect the two together.

In short I can not get the LED on the nano to light up:

Here is the transmitter code

//Transmitter
#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);
  vw_setup(2000);
  vw_set_tx_pin(7);
//  pinMode(7, OUTPUT);
//  digitalWrite(7, HIGH);
}

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

here is the reciever code

//Reciever

#include <VirtualWire.h>

void setup()
{
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  vw_setup(2000);
  vw_set_rx_pin(12); 
  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(13, HIGH); //tap on
          break;
        }
        else
        {
         digitalWrite(13, LOW); //tap off
         break;
        }
      }
    }  
  }
}

Transmitter pic:

Reciever pic:

Thanks for all the help I hope I can repay it at some point

Hi, do you have a second pc/laptop to connect to the nano? If so, add code to the nano sketch to echo the received codes to the second pc. Maybe its receiving something but not the ‘1’ you expected? If no second pc available, change the transitting Arduino sketch to send the ‘1’ & ‘0’ codes in turn repeatedly with a pause between. Then connect the nano to the pc to view the received codes.

Paul

The simplest tuned antenna/aerial that will work well with 50 ohm transmitter is a half-wave dipole. Connect two wires, each 1/4 wavelength long, one to the aerial pin and one to the ground pin next to it. Both are needed to get good efficiency. The two wires should point in opposite directions, and away from all other metal and wiring (or at right-angles to them).

The 433MHz a 1/4 wavelength is about 17cm.

Another simple antenna configuration is a 1/4 wave wire above a groundplane, basically the ground wire is replaced by a sheet of metal that is at least 1/2 wavelength across and connected to the ground pin next to the antenna pin.

Receiving aerials are less critical in design.

@Markt,

Can you see the aerial that I have from my pictures? It is effectivly a strip of wire out of pin 1 I have nothing else

@PaulRB I am booting up the worlds most ancient laptop ever

new receiver code

//Reciever

#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  vw_setup(2000);
  vw_set_rx_pin(12); 
  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(13, HIGH); //tap on
          break;
        }
        else
        {
         digitalWrite(13, LOW); //tap off
         break;
        }
        
        Serial.print(buf[i]); 
     } 
  }
}

and still nothing is shown

So you know it is not receiving any codes, rather than just the wrong codes. Are there any indicator leds on the tx or rx units? What do they show? If not, can you add leds to the tx & rx pins to prove there is activity at either pin?

Paul cracking IDEA i did check put LEDs and they are both lighting up on the send and receive so I guess that proves it is sending something.

So is it my sketch then?

I guess so, yes. But I can't see what's wrong. I would compare your sketch to other examples and try to spot any differences. For example:

http://www.pjrc.com/teensy/td_libs_VirtualWire.html

Take a look at the simple VirtualWire examples. For one, in your transmit routine you are not waiting until the transmission is finished before proceeding to the next program step. True, some time is spent printing to the monitor, but that may not be enough. Try something like this:

   vw_send((uint8_t *)msg, strlen(msg));    
   vw_wait_tx(); // Wait until the whole message is gone

http://www.airspayce.com/mikem/arduino/VirtualWire/transmitter_8pde-example.html

Could it be the voltage? I checked the voltage across the LED and it is 1.6v? Is this potentially to low?

I am really struggling as not sure what to do any more

I second jremington's suggestion. Try the transmitter and receiver code examples from that link with as few modifications as possible. If that works at least you know the hardware side is definitely OK. Then start changing them, one small step at a time, into what you want.

wishywashy: Could it be the voltage? I checked the voltage across the LED and it is 1.6v? Is this potentially to low?

What LED? Your original post didn't show any. If it is the leds I suggested before, they were meant only to be added temporarily to check that data was going to the tx unit and from the rx unit. If you left them in, they may well drag the voltage down too low for the arduino input to read.

In that example what pin is it sending out of though? just the standard tx pin?

So I now have the tx pin as my data on my transmitter and the rx pin as my data line for my reciever.

I ran the example and I noticed that pin 13 on the transmitter (UNO) would not light up as the voltage kept varying between 0.07-0.13v so I guess that it keeps going up and down shows at least it is trying to output, however I am surprised that the voltage stayed so low.

With the reciever I used the rx for my data to be inputted to the arduino and I noticed the LED was not lighting up so I switched it around and it did light up meaning the the rx line is outputting a signal not looking to recieve one!

wishywashy:
In that example what pin is it sending out of though? just the standard tx pin?

No, that would interfere with the serial comms to the pc. Confusingly, the examples don’t use the functions to set the tx an rx pins for the radio modules. The documentation says they default to pins 11 & 12.

Still nothing coming through on the reciever!!! AHHHH this is so frustrating.

I put back the LED's on the reciver and the transmitter and the voltage across the transmitter LED peaks at 0.27v and the voltage across teh reciever LED peaks at 0.57v

Could this be a contributor?

wishywashy: I put back the LED's on the reciver ...Could this be a contributor?

Yes! The leds proved there is data going into the transmitter and coming out of the receiver, now get rid of them!

I have got rid of them and tested but still nothing. i only put them back temporarily to see the voltage

Write a test sketch for the receiving arduino that simply does repeated digitalRead on the pin connected to the rx data and echoes the value back to the pc. If you see both zeroes and ones when a transmission is sent, you will know that the hardware is fine and you can stop worrying about voltages.

My new receiver code:

int ledPin = 13; // LED connected to digital pin 13
int inPin = 7;   // pushbutton connected to digital pin 7
int val = 0;     // variable to store the read value

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
  pinMode(inPin, INPUT);      // sets the digital pin 7 as input
}

void loop()
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
  Serial.print(val);
}

So when I put uploaded the code I did not have the transmitter plugged in and I was receiving a flood of 1's and 0's and then I plugged in the transmitter and I got a more steady 'burst' of 1's and 0's. If the transmitter is plugged in and then I remove the dataline the led on the receiver stops.

Also thanks so much for the help really appreciate you taking the time to help me