Arduino Nano 433 MHZ transmitter/receiver pair unable to receive/transmit data

Hello, I'm new to arduino + electronics. I am trying to send a simple open/close message with my transmitter to my receiver. However, I'm having trouble getting this to work for some reason, I've followed multiple tutorials and tried all kinds of things, I'm unsure what it is that I'm doing incorrectly.

The transmitter and receiver each sit on their own arduino nano.

Transmitter is connected as following:

VCC => 5V
Data => D12
GND => GND

Receiver is connected as following:

VCC => 5V
Data => D12
GND => GND

This is the code for the transmitter

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.H>
char *controller;
void setup() {
  pinMode(13, OUTPUT);
  vw_set_ptt_inverted(true); //
  vw_set_tx_pin(12);
  vw_setup(4000);// speed of data transfer Kbps
}

void loop() {
  controller = "1" ;
  vw_send((uint8_t *)controller, strlen(controller));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, 1);
  delay(2000);
  controller = "0" ;
  vw_send((uint8_t *)controller, strlen(controller));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, 0);
  delay(2000);

}

This is the code for the receiver

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
void setup()
{
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_set_rx_pin(12);
  vw_setup(4000); // Bits per sec
  pinMode(13, OUTPUT);

  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
  {
    if (buf[0] == '1') {


      digitalWrite(13, 1);
    }
    if (buf[0] == '0') {
      digitalWrite(13, 0);
    }

  }
}

This is not the only code I've tried, I'm utilizing the (old) VirtualWire library from this tutorial. Is anyone able to assist me in figuring out what's going wrong here?

Hi,

I just started experimenting with VirtualWire as well.

First off, try vw_set_ptt_inverted(false); on both codes. I think it is for DR3100 transceiver only (I assumed you have modules like this)
On receiver end, try the LED blink outside IF statement, to see if you are receiving anything at all. Or better print the result, something like below:

if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    Serial.println(buf[0]);
  }

Here's my post, maybe that also helps somehow.

Good Luck
Sergi

You don't need this line at all, so remove it from both TX and RX code. You don't have a Push To Talk input.

  vw_set_ptt_inverted(true); //

This is wrong. "1" is a two byte C-string, not the ASCII character '1'. Change the double quotes to single quotes. Same for "0".

  controller = "1" ;

sergi_jini:
Hi,

I just started experimenting with VirtualWire as well.

First off, try vw_set_ptt_inverted(false); on both codes. I think it is for DR3100 transceiver only (I assumed you have modules like this)
On receiver end, try the LED blink outside IF statement, to see if you are receiving anything at all. Or better print the result, something like below:

if (vw_get_message(buf, &buflen)) // Non-blocking

{
Serial.println(buf[0]);
}





Here's my [post](https://forum.arduino.cc/index.php?topic=687446.0), maybe that also helps somehow.

Good Luck
Sergi

I tried this and the receiver doesn't seem to be receiving any message at all (nothing is printed to the serial monitor). I also tried taking a look at the forum thread you posted, I reconfigured the pins and code to what had worked for you, and still nothing -- no RXD light and nothing in the serial monitor.

Also, if it matters -- i am using these

jremington:
You don't need this line at all, so remove it from both TX and RX code. You don't have a Push To Talk input.

  vw_set_ptt_inverted(true); //

This is wrong. "1" is a two byte C-string, not the ASCII character '1'. Change the double quotes to single quotes. Same for "0".

  controller = "1" ;

I tried making these changes as well, and still no success.

Please post the revised code, using code tags.

It is always a good idea to use Serial.print() to see what is actually being transmitted and received.

To Hardwirednerd:
There are quite a few 433Mhz radio pairs out on the market today.
There are a few libraries that work with these pairs and some don't.
The FS1000A works with the GitHub - sui77/rc-switch: Arduino lib to operate 433/315Mhz devices like power outlet sockets. library.
Please install this library and see if it works for you.

All the ASK/OOK boards with a single data in (on transmitter) or data out (on receiver - sometimes 2 pins tied together) are interchangible, in my experience. I had no issues swapping between half a dozen transmitter and receiver models. Those green receivers are trash, by the way (though the transmitters that come with them are fine) - you get >20x the range if you switch to the ~$1 RXB-12, or other receiver is based on the SYN470/480 receiver IC from Synoxo (great part by the way - I made a working receiver PCB with only like 5 PCB designs under my belt a few years back first try - and cheap as dirt)

But at short range that shouldn't be the issue.

Are you sure the tiny is actually running at the speed you think it is? People often don't realize they need to "burn bootloader" even when not using a bootloader in order to set the fuses for the clock speed they want. They come from factory set to 1MHz, not 8 or 16. Since those modules are timing critical (think morse code), this will prevent communication from working. After choosing the desired clock speed and source (probably 8 internal or 16 pll/internal for a t85) be sure to do "burn bootloader" to configure the chip that way - you must repeat this if you wish to change to a different clock source or speed. This is required even if you are not using a bootloader - if the board definition you are using does not have a bootloader "burn bootloader" just sets the fuses.

Are you sure the tiny is actually running at the speed you think it is?

Good point!

@OP: As a quick test, run the Arduino Blink LED program, set for 1 second blink cycle.