Go Down

Topic: Difficulties with the virtual wire library and 433RF (Read 2 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?

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. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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


Go Up