I got this RF module (http://www.sparkfun.com/commerce/product_info.php?products_id=7813) last week.
I have the transmitter sitting on a (ladyada) protoshield on top of an Diecimila. Transmitter GND and VCC are connected to GND and +5, DATA is connected to digital pin 3. I have the optional antenna installed, 30cm. Here’s the transmit code:
#include <SoftwareSerial.h>
byte data = 16;
int rxPin = 2;
int txPin = 3;
SoftwareSerial rfSerial = SoftwareSerial(rxPin,txPin);
void setup() {
pinMode(rxPin,INPUT);
pinMode(txPin,OUTPUT);
rfSerial.begin(2400);
}
void loop() {
rfSerial.print(data,BYTE);
delay(30);
}
The receiver is attached to an Arduino NG. 3 GNDs (why so many, btw?) are attached to GND and two +5 (?) are hooked up right. The right DATA pin is connected to digital pin 2. Another 30cm antenna here. USB cable plugged in. Here’s the receive code:
#include <SoftwareSerial.h>
byte data = 0;
int rxPin = 2;
int txPin = 3;
SoftwareSerial rfSerial = SoftwareSerial(rxPin,txPin);
void setup() {
pinMode(rxPin,INPUT);
pinMode(txPin,OUTPUT);
rfSerial.begin(2400);
Serial.begin(2400);
}
void loop() {
data = rfSerial.read();
Serial.println(data,DEC);
}
Both Arduinos are running from the same power bus, which is a regulated 5V. The units are closer than 2 inches from each other. I’m running 0011 and remembering to send with the right board for each chosen in the menu, if that makes any difference.
The output I expect is:
16
16
16
16
16
16
16
…
Or roughly similar. The output I get is:
0
0
136
16
0
16
16
16
32
255
75
65
195
2
130
0
4
4
0
8
8
8
16
0
17
Notice how non-random this is. What it looks like to me is a synchronization problem, with a bunch of 1 or 2 bit errors thrown in to make it interesting. Or maybe it is random, but I only get 1 or 2 bits turned on at a time in each value. In any case, I have explored many different hardware and software setups, none of which worked (to varying degrees). Possibly I just have a bad RF module?
If this just won’t work (either because the module is bad or because I’m an idiot or whatever) is there a wireless solution that is a little less…raw while not being as expensive as XBee? ($50 for a single pair?)