SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By callagga
#103442
Hi,

Background - I've just a pair of low cost RF Transmitter & Receiver (http://www.sparkfun.com/commerce/produc ... ts_id=8946, and http://www.sparkfun.com/commerce/produc ... ts_id=8950

Issue - I've set them up for the test program (see code below), however I'm not seeing any response from the receiving Arduino.  I note that when I put a multimeter on the transmitter the +ve voltage on VCC is OK, and when I look at teh DATA line I see it stays at around VCC voltage but the needle moves a little every second, so it seems as if it getting the transmit signal ok.  I don't have antenna wires on them, but they are only a few centimeters apart so this should be ok no?

Question - Any advice on how to trouble shoot in this situation?  I only order one of each of the units.  

Transmitter Code
Code: Select all
/* * Simple Transmitter Code 
* (TX out of Arduino is Digital Pin 1) 
* (RX into Arduino is Digital Pin 0) */

byte counter;

void setup(){ 
	//2400 baud for the 434 model 
        //Serial.println("setup");
	Serial.begin(4800); 
	counter = 0;
} 

void loop(){
	//send out to transmitter 
        digitalWrite(13, HIGH); // Flash a light to show transmitting
	Serial.print(counter); 
	counter++;
        delay(50);
        digitalWrite(13, LOW);
	delay(1000);
}

Receiver Code
Code: Select all
/* * Simple Receiver Code 
* (TX out of Arduino is Digital Pin 1) 
* (RX into Arduino is Digital Pin 0) */

int incomingByte = 0;

void setup() { 
  //2400 baud for the 434 model
  Serial.begin(4800);
  //Serial.println("setup");
} 

void loop(){
	// read in values, debug to computer 
	if (Serial.available() > 0) {
                digitalWrite(13, HIGH); // Flash a light to show receiving
		incomingByte = Serial.read(); 
		Serial.println(incomingByte, DEC);
                digitalWrite(13, LOW);
	} 
	incomingByte = 0; 
}
thanks
By waltr
#103449
These are OOK transmitter/receivers. What does the receiver output look like on an O'scope?

Try bit-banging a 1200Hz waveform into the transmitter and see if it shows up at the receiver. Don't use serail tranfer functions yet. Just poll the input pin to detect the square wave.
Then read up on how to use OOK modulation for serial data.
By stevech
#103456
OOK receivers need a preamble to set the data slicer threshold (integrator), that being a long string of 1010101... then in the data, code it so that long strings of all 1's or 0's cannot occur. Manchester coding, or byte table lookups.

Or simplify, use Digi XBee series on modules from SFE. More costly, but plug and play.
By callagga
#103468
stevech wrote:OOK receivers need a preamble to set the data slicer threshold (integrator), that being a long string of 1010101... then in the data, code it so that long strings of all 1's or 0's cannot occur. Manchester coding, or byte table lookups.
thanks - can I ask:
a) but the code I've posted should work though correct?
b) re "need a preamble" - are you saying the receiver won't actually work without this? My understanding of these tx/rx pair that the receive line (on/off) should just reflect the transmitter (on/off), so if fact the preamble would be more to do with the arduino's serial operations expectation then? i.e. not to do with the transmitter itself

PS. I don't have a CRO :(
By waltr
#103474
Yes, to actually pass data the Preamble is mandatory with OOK modulation.
No, the code you posted will not work with OOK. Although with some modification it may work part of the time. You can try sending data that keeps changing the level of the bits as Steve suggested. The letter 'U' is ASCII is 0x55 and a good one to use. Change the code to send this a 100 times without any breaks or delays between characters. The Receiver and receive code should be able detect these.
This will prove that the RF units work. Then look up the info that Steve suggested.

Also, search through the threads here as the problem has been discussed and solutions presented a number of times.
There is a real reason why OOK RF units are so cheap. You pay by added complexity of the interface and supporting code.
By 60amp_relay
#103476
This is something that trips up a lot of people. You need to have a low->high or high->low transition on the transmitter's data line at least once every 30ms or so. If you simply output a constant "1" on the transmitter, you'll get 30ms of "1" on the receiver and then a stream of garbage. In your program, when you delay(50), the receiver loses sync with the transmitter. Ditto for delay(1000).

About the baud rate: I use these units at 600 or 1200 baud - so far I've never gotten reliable data transmission at 4800 baud. But 600 baud works great (works fine at 50+ feet in my testing)

In your code, try setting the baud rate to 600 and removing all the delay()s so that you're constantly outputting data. With any luck, the receiving end should be able to pick up something.

Incidentally, a good starting point is to just constantly output the char "U" and see if you can read a "U" on the receiving end.
By callagga
#103479
ok - thanks (will try this tonight) - the reason I went to 4800 baud was I saw only this mentioned for the receiver at http://www.sparkfun.com/commerce/produc ... ts_id=8950, but perhaps this was just the max then?

Also I was going to use VirtualWire but it didn't seem to work after hooking things up, so I thought I'd try the simpler test. http://www.open.com.au/mikem/arduino/VirtualWire.pdf. The code I had was:

Transmitter
Code: Select all
#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);
}
Receiver
Code: Select all
#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);
    }
}
By callagga
#103497
PS another piece of advice I got from another forum was:

Connect the transmitter input to a pull-down resistor (5-10k should be fine) and use a button (or just touch a wire) to pull it up to the transmitter power. Connect the receiver output to a transistor switch and an LED, the same way you would do with n Arduino digital output pin. You should be able to turn the receiver LED on and off by taking the transmitter pin high and low.
By callagga
#103511
Just tried removing delays, sending the "U" constantly, and setting to 600 baud rate (Serial.begin(600);) - but still can't receive anything.

Then I tried the no-Arduino test. Just applied (based on a button push) either 0V or 5V to the transmitter input. However at the receiver I don't see any change when I push the transmitter button. The receiver data pin just shows a constant 2V (where VCC = 4V for the receive). Does this imply do you think one of the devices is faulty? I'm assuming on the receiver that where it's got multiple 5V, GND pins etc, that I only have to connect one correct? (i.e. I don't have to hook up 5V inputs to the two +5V pins of the receiver)

EDIT - Actually I just connected an LED on the receiver directly from GND to DATA. I also took the LED out and just measured voltage on the receiving DATA pin and it sits at VCC (=4V) and doesn't change when I push the button on transmitter to toggle input voltage on it's data line.
By waltr
#103523
I'm assuming on the receiver that where it's got multiple 5V, GND pins etc, that I only have to connect one correct? (i.e. I don't have to hook up 5V inputs to the two +5V pins of the receiver)
That is a bad assumption unless you know for certian that all of the common pins are connected together on the board. An Ohm meter would confirm whether they are or or not. My guess is that they are not.
By 60amp_relay
#103568
How come you're using +4V to power the receiver? The (admittedly shoddy) datasheet says +4.5V is the bare minimum on Vcc, with +5V recommended.

You can use the unit with only one Vcc, Gnd, and Data pin connected. It's OK to leave the others disconnected, it still works fine. But the range is only a few feet if you don't hook up an antenna.
By callagga
#103591
Update: I'm still not able to receive serial data on the receiver HOWEVER I have managed to prove to myself that the receiver is receiving something from the transmitter.

When I connect an LED to the DATA pin of the transmitter and the other end to earth, I see the LED flickering, fairly soft (never hard on). I can adjust the timing of the transmitter with the delay() (i.e. put it back in for a bit) and I can see that the flickering on this LED on the receiver matches the timing of when the transmitter is sending.

When I connect the DATA pin up to PIN 0 of the receiver Arduino board however I note that:
(a) I still get no output in the Arduino serial monitor, i.e. when I click on "serial monitor", nor see the pin 13 on board LED flash
(b) I also not that the LED in the chain (Rx_Data_Pin => LED & Arduino Rx Pin 0) that the LED go full on with no flickering when I connect the Rx_Data_Pin to the Arduino Rx Pin 0 too? Is this an issue? Should the LED effectively from the Arduino Rx Pin 0 to GND still not keep flickering just as it was?

Any other ideas? Should I try bringing the RF Rx receiver signal into a normal Arduino input pin and monitor for a change in this and flash a LED if it changes, just to prove the RF Rx is picking up true on/off signals? (as opposed to just letting the RF Rx output com into the Arduino pin 0 Rx)

thanks

PS Receiver code again is:
Code: Select all
int incomingByte = 0;

void setup() { 
  Serial.begin(600);
} 

void loop(){
	if (Serial.available() > 0) {
		    digitalWrite(13, HIGH); // Flash a light to show receiving
		incomingByte = Serial.read(); 
		Serial.println(incomingByte, DEC);
		    digitalWrite(13, LOW);
	} 
	incomingByte = 0; 
}
Transmitter
Code: Select all
byte counter;

void setup(){ 
	//2400 baud for the 434 model 
        //Serial.println("setup");
	Serial.begin(600); 
	counter = 0;
} 

void loop(){
	//send out to transmitter 
        digitalWrite(13, HIGH); // Flash a light to show transmitting
        Serial.print("U"); 
	counter++;
        digitalWrite(13, LOW);
	//delay(10);
}
By callagga
#103594
PS I've been leaving my USB connections (two, one for each arduino) from my Macbook USB ports connected during testing. Is this ok? Doesn't pose any issues with my attempted use of the pin 1 and pin 0 serial communications?