Virtualwire RF 433mhz Voltage problem

Hi,
i am trying to have it switch a 5v relay on pin 8 receiver side only when pin 2 transmitter side in held down.
I have set up a XY-MK 5v transmitter ,
Push button to pin 2 live when pushed 3.3v
Data rf transmitter to pin 4
and 5v,gnd
and receiver,
data pin 2
5v and gnd
led to pin 8 and gnd
Here are the codes.

Transmitter Code=
#include <VirtualWire.h>

const int button = 2;
const int transmit_pin = 4;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
  // Initialise the IO and ISR
  Serial.begin(9600);
  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
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};
  if
 
  (digitalRead(button) == HIGH)
  {Serial.println("on its way");
  msg[6] = count;
  //digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  Serial.println("on its way");
  vw_wait_tx(); // Wait until the whole message is gone
  //digitalWrite(led_pin, LOW);
  //delay(1000);
  count = count + 1;
}
}
And receiver code =
#include <VirtualWire.h>

const int led_pin = 8;
const int transmit_pin = 12;
const int receive_pin = 2;
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
}

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, print it.
Serial.print("Got: ");

for (i = 0; i < buflen; i++)
{
     Serial.print(buf[i], HEX);
     Serial.print(' ');
}
Serial.println();
        digitalWrite(led_pin, LOW);
    }
}
I have tried many different codes i have found and this works the best but.........the voltage is only going from 0.20v to 0.40 on the receiver pin 8. i need this to be 5v any ideas?


Senken (author) 2 years ago

sorry it going from 0.14 when no pressed to 0.23 when pressed