I'm new to arduino and RF modules so I bought some cheap set (XY-MK-5V and FS1000A) to transfer data between two arduinos. Transmitting the data looks fine to me, but I can't receive any Data so far.
This is my Receiver source. It's connected to pin 11. When I start the receiving board, the TX-LED won't turn off, in case this is important somehow. The RX-LED is off, the TX-LED of my sending arduino is turning on and off when I send a message.
I set my buffer size to the VW_MAX_MESSAGE_LEN (30). I just wan't to transfer "hello" for the first time. Is this the correct setup?
/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 11
*/
#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to hold the incoming messages
byte msgLength = VW_MAX_MESSAGE_LEN; // the size of the message
void setup()
{
Serial.begin(9600);
Serial.println("Ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
if (vw_get_message(message, &msgLength)) // Non-blocking
{
Serial.print("Got: ");
for (int i = 0; i < msgLength; i++)
{
Serial.write(message[i]);
}
Serial.println();
}
}
Transmitting Arduino :
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
*/
#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
Serial.begin(9600);
Serial.println("Ready transmitter");
}
void loop()
{
send("hello");
Serial.println("transmitted");
delay(100);
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
Ís it possible that the receiving module is not working?
Serial.println(vw_get_message(message, &msgLength));
It only returns 0 values. \$\endgroup\$