I have bought a 433Mhz transmitter and receiver and want to use them to get 2 arduinos to communicate.
I have connected them to the arduino as shown in the pdfs (double checked) and tried to run the examples included in the library:
Transmitter
// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#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
}
void loop()
{
const char *msg = "hello";
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);
delay(200);
}
Receiver
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#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_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(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], HEX);
Serial.print(" ");
}
Serial.println("");
digitalWrite(13, false);
}
}
The transmitter sits an happy blinks led13 all day long, but I never receive a message on the receiver. I am starting to think that the transmitter and receiver aren't suitable to work together. Can any one help?
You're not trying to run both on the same arduino are you? I have not seen anyone get that to work. You need to have them running on separate arduinos.
You have 17cm antenna wire on both?
Second and fifth lines in the loop() turn led 13 on and off as info is transmitted.
I do have
vw_set_ptt_inverted(true); // Required for DR3100
commented out in the examples I have been using, but I just copy/pasted from the example so it is missing here.
The transmitter has R433A on the crystal but a big sticker saying A434. The receiver doesn't have a frequency on the crystal, just "N6.722 AC20PB". Both the receiver and transmitter are available in 315 and 433Mhz, I should have got the 433 versions of both (at least that's what my receipt says).
They both have a ~10cm piece of wire for an antenna, and the bread boards are physically touching, so there is probably less than 3 inches between the two units.
The reciever is connected to my PC via a USB cable and it should report the recieved message in the serial monitor, but it just say "Setup" but no message.
And I guess pin 13 is defaults as an output(?). I have added a pinmode to the setup and it doesnt make any difference (i.e. it flashes either way).
It doesn't default as an output. I tried this sketch:
void setup ()
{
digitalWrite (13, HIGH);
} // end of setup
void loop () {}
I must admit that pin 13 glows very faintly, but that is because the pull-up resistor has been enabled. You should add:
pinMode (13, OUTPUT);
... to setup to see it more clearly.
As for your problem, checking the pdf file about VirtualWire, he seems to be talking about a transmitter (TX-C1), a receiver (RX-B1) and a transceiver (DR3100).
Now you said:
I have bought a 433Mhz transmitter and receiver ...