I have been working with the SparkFun 315 and 434 MHz for almost 2 weeks now. I still haven't been able to connect them. I changed boards, I bought new a new USB cord, and I continually tested the volts.
I just wanted to check to see if my code is wrong because I believe there is no way an error in the wiring.
Thank you so much for any help.
Transmitter(uno)
#include <VirtualWire.h>
void setup()
{
Serial.begin(4800); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_setup(2000); // Bits per sec
vw_set_tx_pin(13);
}
void loop()
{
char *msg;
msg = "Hi";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
}
Receiver(mega)
#include <VirtualWire.h>
void setup()
{
Serial.begin(4800); // Debugging only
Serial.println("setup");
vw_setup(2000); // Bits per sec
vw_set_rx_pin(22); // receiver pin
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
{
for(int i =0; i < buflen; i++)
{
Serial.print(buf[i]);
}
}
}
I have also tried different combinations just in case I mixed them up and they still didn't work. I even matched up the pictures to double check I was testing the right pair.
The onboard LED is connected to this pin. Perhaps you should try a different pin.
That IS the pin that the radio is connected to, right?
A delay() in loop might not be a bad idea.
And, there is no reason to set the baud rate so low. It has nothing to do with the radios.
I even matched up the pictures to double check I was testing the right pair.
What pictures? Speaking of pictures, a picture of your wiring wouldn't be a bad idea. You know the kind we normally see here - out of focus, all the wires one color, all jumbled together, and dark. Oh, and something about 1920 x 1600.
Or a reasonable size, in focus, picture, well lit, with neat wiring of different colors. Whatever seems to work best for you.
First picture is of the breadboard connected to the receiver, second picture is of the actual board. Third picture is the transmitter connected to the BOE shield which is on an uno. Fourth picture is the transmitter showing where the pins go.
Wires labeled: Green is Ground, yellow is to 5v and orange is the antenna.
I used your sketches as well as the same boards, uno and mega (Arduino 1.5.4). Using the really cheap ebay 315mhz transmitter/receiver here. Your code works, except that I had to use 'Serial.write(buf*);' (instead of print). Hope this helps.*
I got it to work aswell and yes .write works better. I was using a 434 MHz pair instead and apparently I got a faulty pair. When I decided to use my 315 MHz pair it worked instantly.