Wireless RF Arduino Communication problem

I have been trying to get two arduinos to communicate wirelessly. I am using an arduino pro 16MHz/5V and an arduino pro mini 16MHz/5V along with a transmitter ([<LINK_TEXT text=“http://www.sparkfun.com/commerce/produc … ts_id=8946”>http://www.sparkfun.com/commerce/product_info.php?products_id=8946</LINK_TEXT>) and receiver ([<LINK_TEXT text=“http://www.sparkfun.com/commerce/produc … ts_id=8949”>http://www.sparkfun.com/commerce/product_info.php?products_id=8949</LINK_TEXT>) pair from SparkFun. I have been reading and trying to learn how to do this and I have come a long way, but now I am stuck. My problem is that all I see on the serial monitor is garbage. I originally made it so the transmitter was sending a byte that continuously counted from 0-255 but I couldn’t decipher anything. Then I changed it so it was just sending the byte “65”, and it is now obvious that the receiver is receiving some useful information, but it is definitely not the byte “65”. Here is a picture of the serial monitor output, the top half of the screenshot is before I connect the data line to the transmitter, which looks like its just noise and is expected.

[screen1

This second screenshot is after I connect the data wire to the transmimtter, but it not showing the byte 65, which in ASCII would be “a”. What am I doing wrong wrong?

[screen2

Transmitter code:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);
byte outgoingByte = 65;

void setup() {
 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);
 rfSerial.begin(2400);
 Serial.begin(2400);
}

void loop() {
 Serial.println(outgoingByte, DEC);
 rfSerial.println(outgoingByte, BYTE);
 delay(500);
}

Receiver code:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

byte incomingByte = 0;

SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);

void setup() {
 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);
 rfSerial.begin(2400);
 Serial.begin(2400);
}

void loop() {
 incomingByte = rfSerial.read();
 Serial.println(incomingByte, DEC);
 incomingByte = 0;
}

Here are some pictures of my set up. Any help or advice would be much appreciated! Thanks!

[http://www.navy2x.net/photos/rf/Random_057.JPG

[http://www.navy2x.net/photos/rf/Random_058.JPG

[http://www.navy2x.net/photos/rf/Random_059.JPG

[http://www.navy2x.net/photos/rf/Random_060.JPG

[http://www.navy2x.net/photos/rf/Random_061.JPG](http://www.navy2x.net/photos/rf/Random_061.JPG)](http://www.navy2x.net/photos/rf/Random_060.JPG)](http://www.navy2x.net/photos/rf/Random_059.JPG)](http://www.navy2x.net/photos/rf/Random_058.JPG)](http://www.navy2x.net/photos/rf/Random_057.JPG)](http://www.navy2x.net/photos/rf/screen2.gif)](http://www.navy2x.net/photos/rf/screen1.gif)](http://www.sparkfun.com/commerce/product_info.php?products_id=8949)](RF Link Transmitter - 434MHz - WRL-08946 - SparkFun Electronics)

Try attaching 30-35 cm of wire to the antenna terminals. Also, in the product comments people said that the receiver AGC will cause noise to be output if you don’t transmit something at least every 10ms. Try reducing your delay to an amount less than that.

Try using the VirtualWire library, which is made for these things and Arduino. It has properly balanced transmission.

Ya, I just looked at the images. You have no antenna at all.

Also try separating your circuits all together, rather than using the same supply.

Not to hijack your thread, but I’m having a similar problem with the same RF links (315MHz version). The only difference with my situation is that I’m not getting ANY data from the receiver at all. I’ve been trying a simple loopback test, and I get absolutely nothing unless I run a direct line from rx to tx. Do you think one of the units could be defective?

#include <NewSoftSerial.h>

int rxPin = 2;
int txPin = 3;
NewSoftSerial rfSerial(rxPin,txPin);

void setup(){
  Serial.begin(2400);
  rfSerial.begin(2400);
  Serial.println("Loopback test ready.");
}

void loop(){
  rfSerial.print("Test");
  while(Serial.available()){
    char temp = Serial.read();
    Serial.print(temp);
  }
  delay(1000);
}

Here’s a picture of my setup:

http://img.photobucket.com/albums/v68/e … 01802a.jpg

Any luck/progress with this? I am able to get the the VirtualWire library working (I think…) - the serial monitor reads "Got: 68 65 6C 6C 6F

" which I think is the hex equivalent of ‘hello’.

However, I’m struggling because what I really want to do is have an LED on the receiver Arduino light up when a button on the transmitting Arduino is pushed. It’s not clear to me how I can use the VirtualWire to accomplish that. I’ve searched around for examples with no luck. Can anyone assist?

tikka308:
However, I’m struggling because what I really want to do is have an LED on the receiver Arduino light up when a button on the transmitting Arduino is pushed. … Can anyone assist?

A pair of Digi XBees can do this without writing any code.

tikka,

Yep, that’s the hex codes for “hello” so you have the pair working.

Read the “KLP walk through” on the transmitter’s SparkFun page. There is some info and ideas for reliable communication.

Then do some google searches on ASK data transmission, and Manchester encoding. There is a ton of good, easy to understand info.

The biggest down side of on ASK transmitter is that there is no RF on data ‘0’ only on data ‘1’. Next is the simple receiver design, it is just an RF detector that does not discriminate whether the RF is from the desired transmitter or just random RF noise. To over come the hardware simplicity one needs to do a little more in software.

Good luck and keep us posted with your results.

erickingston:
Not to hijack your thread, but I’m having a similar problem with the same RF links (315MHz version). The only difference with my situation is that I’m not getting ANY data from the receiver at all. I’ve been trying a simple loopback test, and I get absolutely nothing unless I run a direct line from rx to tx. Do you think one of the units could be defective?

If you are using a single Arduino, your program really isn’t loopback program. The rfSerial.print() function is going to send ALL of the data string, THEN your receiving routine is going to look for the data, which will be gone by the time you get ready to look for it. The first step to make this work is to put the receive routine in an interrupt handler. That way, your code can send the data without missing data.

Furthermore, again assuming a single Arduino is in use, the transmitter is going to completely swamp the receiver causing more problems. There are a number of strategies to get these devices to work together. The key is to set up a situation where the average data stream of 0/1 bits is balanced. One way is to use Manchester encoding as waltr said. You can also get pretty close by sending a data byte followed immediately by its complement. In all cases, the receiver needs some framing data to give it time to adjust its automatic gain control (AGC) circuitry for the incoming data. I use a short string like 0xE5, 0xAA, 0xE5 followed by my data packet (a byte followed by its complement).