Can't get my 433MHZ pair to work

Hello,
I'm pretty new to the ardiuno stuff. All I want is to use a 433Mhz sender/receiver pair to communicate with each other. I'm using the VirtualWire libary.
Here is my sending Arduino Nano's code:

#include <VirtualWire.h>
const int tx_pin = 12;

void setup() {
  Serial.begin(9600);  // Debugging only
  Serial.println("setup");
  vw_set_tx_pin(tx_pin);
  vw_setup(2000); 
}

byte count = 1;

char charBuf[3] = {'1','#',' '};

void loop() {
  charBuf[2] = char(count++);
  bool success = true;
  
  digitalWrite(LED_BUILTIN, HIGH);
  Serial.println("sending:");
  Serial.print(charBuf[0]);
  Serial.print(charBuf[1]);
  Serial.println(byte(charBuf[2]));
  //vw_send((uint8_t *)charBuf, sizeof(charBuf));
  success = vw_send((uint8_t *)charBuf, 3);
  vw_wait_tx();
  if (success) {
    Serial.println("finished");
  } else {
    Serial.println("error while sending message");
  }
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}

And here the receiving end of this (running on an Arduino Uno):

#include <VirtualWire.h>
const int rx_pin = 12;

void setup()
{
  Serial.begin(9600);  // Debugging only
  Serial.println("initializing....");
  
  vw_set_rx_pin(rx_pin);
  vw_setup(2000);      // Bits per sec
  vw_rx_start();       // Start the receiver PLL running
  Serial.println("done");
}

void loop()
{

  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  vw_wait_rx_max(2000);
  
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    int i;

    digitalWrite(LED_BUILTIN, HIGH); // 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]);
      Serial.print(" ");
    }
    Serial.println("");
    digitalWrite(LED_BUILTIN, LOW);
  }

  Serial.print("Bad messages received:"); Serial.println(vw_get_rx_bad());
  Serial.print("Good messages received:"); Serial.println(vw_get_rx_good());

  delay(1000);
}

Very rarely I get a bad message received count. But only like 1 in a 500 shows up like that. I never get a good message through.

I'm currently using these 433Mhz modules:
Receiver module (RX470-4)
Transmitter module (WL102-341)

I also tried to connect the two data-out and data-in ports of the two board directly (practically having a real wire for the 433mhz connection), but that led to the same results.

Any ideas on what's wrong here?

That should work.

What are you using for antennas? At the minimum, you should have 17 cm of straight wire soldered to the ANT terminal of both transmitter and receiver.

also tried to connect the two data-out and data-in ports of the two board directly

Did you also connect the grounds?

jremington:
Did you also connect the grounds?

No, I did not. Thanks for the hint. When I do connect data and ground, the setup works as expected.
So there seems to be something missing with the RF modules (I also already tried different modules, with the same result).

And yes, I got antennas soldered to the modules.

Use 17 cm of straight wire, not coils, for the antennas.

Those spring antennae are utter garbage. I use solid core wire from ethernet cable for antennae.

I would also try swapping in different transmitter and receiver modules. Yours looks like a good receiver (is that a SYN470 IC on there? Those work very well); I didn't try any transmitters with an IC in SOIC-8 package when I was testing these, so can't comment on that.

Also, try touching the two antennae together, and see if that works.

Have you tried the bare example sketches that came with the library?

How far apart are the modules?
If you have them really close together like 10 cms or less the transmitter can overload the receiver causing
erratic operation.
The helical antennas arnt as good as 17cm antennas, but they wont stop the modules working.
The other possibility is that there is an interfering source nearby.

I have the same cheap modules, and also had similar problems with them.
So, I discovered that they do not take 3-12V for Tx and 5V for Rx, like most of tutorials are saying, but are completely different modules.
These modules you have are new versions, and if you read their specs, Tx must be fed with 2-3.6V and Rx with 2.2-5V. If this does not help, try changing the pins, for me non-pwm digital pins work better.

Hi,
You can check if your code is working by removing the TX and RX and connecting the gnd of the two Arduinos and the output and input pins directly.
The Tx and Rx are only RF modulators, no special digital encoding or such.

Tom... :slight_smile:

Hi, did you ever get your modules working? I am having the same problem with these exact models.