Help Please! RF Transmitter Issue

Trying to do a simple RF transmitter receiver test using the RX and TX pins on two Arduino's. Wire hookup is just to the TX (pin 1) plus 5V and GND on the transmitter Arduino, then RX (pin 0), 5V, and GND on the receiver side. Code is below, when I open the Serial Monitor on the receiver side, all I'm getting is:

p
p
p
p
p
p
p
p
p

{lol}
What did I do wrong?


Transmitter Code:

void setup(){
//4800 baud for the 315 hz model
Serial.begin(4800);
pinMode(13,OUTPUT); //hooked up an LED to visually see transmitting
}

void loop(){
digitalWrite(13, HIGH);
//send out to transmitter

Serial.println("hello friend");
digitalWrite(13,LOW);
delay(1000);
}

Receiver Code

int incomingMessage;

void setup(){
//4800 baud for the 315hz model
Serial.begin(4800);

}
void loop(){
if (Serial.available()) {
incomingMessage = Serial.read();
Serial.println(incomingMessage);
}
}

Your test code works as written for me when I use two Arduinos connected TX to RX and no radios involved. Is that what you are doing? If so, did you connect the grounds? Did you upload the sketch into the receiver before connecting the RX pin to the transmitter TX?

If you are trying to use the radios, many different things can be wrong, including the fact that the receiver needs a series of training pulses to drop its automatic gain circuit and will not work with raw serial data.

I would encourage you to use Virtual Wire(or the follow on library RadioHead) with these RF ASK modules.

I just tried connecting both Arduinos with a wire going from tx to rx in each with a wire also going to ground. The Rx Arduino is receiving information from the Tx in the serial monitor, but its just a bunch of random numbers every line. I even tried to make it simpler and make the hello message an integer (1234) and the Rx Arduino is still interpretting that as random numbers. Both baud rates are the same in the Rx and Tx arduinos.

That won't work. Serial won't send a training burst to get the receivers AGC locked on, only sends the message once (you want to send the message multiple times to ensure receipt), and since it's high when idle, the AGC will crank the threshold so high that it won't be able to pick out data when you start sending. You absolutely will not get successful transmission using the transmitters and receivers like that. The transmitters you're using don't have any smarts built-in that takes serial and turns it into something appropriate to send over the air. There exist fancier, more expensive RF modules that do, though.

Use a library like VW/RH for transmitters like that.

Is the baud rate set to 4800 in the serial monitor when you are trying to view what is coming to the RX Arduino?
There is a baud rate button at the lower right of the screen. The sketches may have the same baud rates, but the monitor needs to be set to that baud rate as well.

Can you see the message being printed when the monitor is set to the com port of the TX Arduino?

I am trying to help you work with your sketch if you have no radios currently hooked up. As you have now heard from two people, this approach will not work with the radios. You will be better off trying to use VW/RH as suggested.

VirtualWire and RadioHead can be found here. I recommend VirtualWire. Don't worry about it being phased out, it works well.

  1. Connect grounds together
  2. cross wire the TX and RX pins between Arduinos.
  3. set bauds rates to the same value (use the default 9600, or for faster speeds, use 115200)
  4. Use char instead of int when reading in characters.
  5. Unless you are using an Arduino with multiple UART pins, you should be using either SoftwareSerial or NewSoftwareSerial to send and receive the data and regular Serial to show it in the Serial Monitor.

Put this code on both arduinos, send something and see what you get back

/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

If you are using the RF transmitter that I think you are using then you need to download the Virtual Wire library.