Go Down

Topic: Can't get my 433MHZ pair to work (Read 219 times) previous topic - next topic

frooop

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:

Code: [Select]
#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):
Code: [Select]

#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?

jremington

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.

Quote
also tried to connect the two data-out and data-in ports of the two board directly
Did you also connect the grounds?

frooop

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.


jremington

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

DrAzzy

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.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

aarg

Have you tried the bare example sketches that came with the library?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

mauried

#6
Sep 26, 2017, 12:33 am Last Edit: Sep 26, 2017, 12:34 am by mauried
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.

Go Up