Go Down

Topic: Difficulties with the virtual wire library and 433RF (Read 2742 times) previous topic - next topic

Targettio

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: [Select]

// 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: [Select]

// 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

Nick Gammon

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

Also, is this line needed?

Code: [Select]
    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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Targettio

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: [Select]

   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.

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Targettio

#5
Apr 24, 2011, 12:33 pm Last Edit: Apr 24, 2011, 12:36 pm by Targettio Reason: 1
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.

Nick Gammon


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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Targettio

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

Nick Gammon

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

Code: [Select]
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: [Select]
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: [Select]
    vw_set_ptt_inverted(true); // Required for DR3100

But you don't have that part.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy