RF Transmission and Receiving help needed

Hello, If anyone can help me it would be much appreciated.
I am trying to learn how to use radio Frequency transmissions to make my Arduino projects wireless but I can't seem to get it to work. I downloaded the Virtual Wire library and bought some 433Mhz Rf Transmitter and Receiver modules. This is the amazon link i bought from https://www.amazon.com/gp/product/B017AYH5G0/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1


I am working with an Elegoo Arduino Mega (2560) for the transmitter and an Arduino Uno for the receiver.
I am using the example codes found with the Virtual Wire Library They are attached below


Attached are pictures of my setup for both transmitter and receiver setups.
I am certain that all of the pins are correctly connected but if someone can verify that would be awesome.

Transmitter:
gnd: black wire
5v: yellow Wire
data: red wire to pin 12

Receiver:
gnd: green wire
vcc: tried both 3.3v and 5v, red wire
data: white wire pin 12

Also on the transmitter and receiver I soldered on a copper wire to act as an antenna. Its length is 17 cm, if someone can verify for me that the length is the correct one for a half wave of transmission?


Receiver


Transmitter


Any help is welcome and I will try to reply asap to any suggestions, comments and/or advice
Thank You

transmitter.pde (1.06 KB)

receiver.pde (1.35 KB)

I do not know why I attached the code rather than posting it in the forum so here it is so no one has to download it to look at it.

Transmitter Code

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);       // Bits per sec
    pinMode(led_pin, OUTPUT);
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}

Receiver Code

// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 13;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3;

void setup()
{
   delay(1000);
   Serial.begin(9600); // Debugging only
   Serial.println("setup");

   // Initialise the IO and ISR
   vw_set_tx_pin(transmit_pin);
   vw_set_rx_pin(receive_pin);
   vw_set_ptt_pin(transmit_en_pin);
   vw_set_ptt_inverted(true); // Required for DR3100
   vw_setup(2000); // Bits per sec

   vw_rx_start();       // Start the receiver PLL running

   pinMode(led_pin, OUTPUT);
}

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(led_pin, 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], HEX);
   Serial.print(' ');
}
Serial.println();
       digitalWrite(led_pin, LOW);
   }
}

17 cm wire is correct for a 1/4 wave antenna and is what you should use for now.

The receiver requires 5V and probably won't work on 3.3V. Otherwise, the setup and code you have should work.

Triple check all your connections and pin assignments and if you have more than one TX or RX module, try different ones.

If you accidentally connected power backwards at any point, it may have been destroyed.

Edit: I just checked the TX module I have, which looks extremely similar to the one in your Amazon link. However, the lettering over the pins is different and on yours, it is misleading.

Vcc on mine is the CENTER pin, and data (spelled ATAD) is the OUTER pin, opposite GND. Compare with this tutorial: 433 MHz RF module with Arduino Tutorial 1

The module should survive swapping the data and Vcc pin connections.

I got it working thank you. I could not tell you exactly what the problem was but i think it may have to do with me not fully understanding virtual wire and what pins are used for what. I ended up following the guide you linked and got that working then moved onto Radio Head instead of Virtual wire and I got that working no problem. Thanks again. :smiley: