I got the 315MHZ receiver and transmitter from sparkfun.
But when I use the VirtualWire library I get a blank serial monitor.
Here is my code for receiver:
#include <VirtualWire.h> // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
Serial.begin(9600);
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for RX Link Module
vw_setup(2000); // Bits per sec
vw_set_rx_pin(3); // We will be receiving on pin 3 () ie the RX pin from the module connects to this pin.
vw_rx_start(); // Start the receiver
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // check to see if anything has been received
{
int i;
// Message with a good checksum received.
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i]); // the received data is stored in buffer
}
Serial.println("");
}
}
Code for transmitter:
#include <VirtualWire.h> // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for RF Link module
vw_setup(2000); // Bits per sec
vw_set_tx_pin(3); // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs.
}
void loop()
{
const char *msg = "Hello, wireless World!"; // this is your message to send
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait for message to finish
delay(200);
}
At first i thought maybe my RF modules were bad, so I tried it using
the SoftwareSerial library, but that works.
I had my transmitter send a bunch of 7's to the receiver and the serial monitor displayed the 7's, plus a some other numbers, figure
that was just noise.
So my modules are fine, but I don't understand why using the VirtualWire library doesn't work.
I don't get any compiling error's, I have my serial monitor set to 2400.
I've tried other baud rates but I still get nothing.
This one has me stumped. I pretty much copied and pasted the code from here:http://letsmakerobots.com/node/12336
I just changed the pin numbers since Im not using a mega.
I'm using a Duemilanove w/328 as the receiver and a BBB from Modern devices as transmitter.