Pages: [1]   Go Down
Author Topic: Difficulties with the virtual wire library and 433RF  (Read 2222 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have bought a 433Mhz transmitter and receiver and want to use them to get 2 arduinos to communicate.
http://www.farnell.com/datasheets/54125.pdf
http://www.farnell.com/datasheets/54130.pdf

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
Code:
// 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
Code:
// 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?

Thanks in advance
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't see where you are setting pin 13 to an output (in either sketch).

Also, is this line needed?

Code:
    vw_set_ptt_inverted(true); // Required for DR3100

The module doesn't specifically say it is a DR3100.

Do they both have 433 stamped on the crystal?
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2 separate UNOs with two separate breadboards.

Second and fifth lines in the loop() turn led 13 on and off as info is transmitted.

I do have
Code:
   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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't see where you are setting pin 13 to an output (in either sketch).
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, I see what your trying to say...

I can add a pinmode but I am not sure how that will help as LED 13 is just there for a visual representation of a transmission, which it is doing.
« Last Edit: April 24, 2011, 05:36:02 am by Targettio » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The transmitter sits an happy blinks led13 all day long, but I never receive a message on the receiver.

How does it blink, if it isn't defined as an output? And how do you know you didn't get a message on the receiver?
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It doesn't default as an output. I tried this sketch:

Code:
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:

Code:
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:

Quote
I have bought a 433Mhz transmitter and receiver ...

Not the transceiver, right?

But you have in your code:

Code:
    vw_set_ptt_inverted(true); // Required for DR3100

But you don't have that part.
Logged


Pages: [1]   Go Up
Jump to: