I'm trying to create a simple link between two arduinos using an RF transmitter/receiver combo I got from SparkFun. It's my first time working with wireless and Arduino, and it's proving to be quite a challenge! Upon wiring everything and uploading sample software, my receiver is not getting anything at all. I researched this problem on this forum and many others, but most posts end in dead ends or solutions which don't work for me or apply to my situation.
In a desperate attempt to troubleshoot the problem, I removed the transmitter/receiver and just ran a wire directly from the transmitting arduino's tx pin to the rx pin on the receiving arduino. Still nothing! This made me wonder if anything is being sent at all. I don't have an oscilloscope, but I used a voltmeter to see if there is any change in voltage when a signal is being transmitted, and there is. It jumps up to about 1.3V when something is sending. So ~something is sending, but the rx pin is not seeing it. What could be wrong?
One thing to note is that when I check the signal with the voltmeter, it's about 1.3V with respect to the sending arduino's ground, but the needle just barely twitches (really tiny voltage) with respect to the receiving arduino's ground. Is this normal?
Also, one of my arduinos (the transmitting one) is a breadboard version as described here:
It runs some test programs just fine (like blink, fade, etc.) so I think it's set up correctly. I don't have a second "real" arduino to test with though, which makes things difficult.
I appreciate any input/hints!
PS: Here is my code:
// TRANSMITTER CODE
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_set_tx_pin(5);
pinMode(8, INPUT);
pinMode(9, INPUT);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
}
void loop()
{
char *msg;
if(digitalRead(8) == LOW){
char *msg = "1";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);}
if(digitalRead(9) == LOW){
char *msg = "2";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);}
}
*/
//END TRANSMITTER CODE
// RECIEVER CODE
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_set_rx_pin(4);
vw_rx_start(); // Start the receiver PLL running
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13, OUTPUT);
//pinMode(10, OUTPUT);
//pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(13, LOW);
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
Serial.println("Entered Loop");
int i;
digitalWrite(13, true); // 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]);
if(buf[i] == '1'){digitalWrite(8, HIGH);}
if(buf[i] == '2'){digitalWrite(9, HIGH);}
Serial.print(" ");
}
Serial.println("");
digitalWrite(13, false);
}
}