RF Reciever & transmitter [433Mhz, 315Mhz] Library.

wireless communication and related Bees.

Moderators: lily.li, violet, jessie

Miles
Kindergarten
Kindergarten
Posts: 91
Joined: Thu Apr 23, 2009 7:41 pm
Location: UK London
Contact:

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by Miles » Wed Jul 15, 2009 8:24 pm

CaptainObvious wrote:Sorry if the questions.. seem a bit obvious, but, do I try connect the two arduinos together with the same code and try? Haven't had much experience with TX/RX pins, all I know so far is not to use them, and if I need to, don't connect the pins until after code is uploaded, but that's about it! :oops: Just a little worried about hooking it up incorrectly and damaging something! :D
Thanks for the quick response! :D (And thanks for taking sometime to try help the newb understand!:))
You should be fine


RX is the reciever port where, inversely, TX is the transmitter.

If you run a wire from the TX to RX and run the same code it operate exactly the same and rules out any problems with the hardware ;).

Try that and have a play around. I'm away on business at the moment so I wont be able to resond quickly
Many Thanks,
Miles
---------------
Software Engineering meets Physical Computing. Fantastic, I wish we had this good 20 years ago.

CaptainObvious
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Mon Jul 13, 2009 2:56 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by CaptainObvious » Tue Jul 21, 2009 4:08 pm

Sorry for the delayed response! I tried hooking the TX to the RX, and vice versa on the boards, with no luck.. it's gotta be user error.
Here's the code, I might have hooked up the tx/rx to the wrong ones. But I tried to switch em mid-code, I must be missing something. Or code issues.

Receiver

Code: Select all

// 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>
#undef int
#undef abs
#undef double
#undef float
#undef round
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);
    }
}
Transmitter

Code: Select all

// 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>
#undef int
#undef abs
#undef double
#undef float
#undef round
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);
}

Miles
Kindergarten
Kindergarten
Posts: 91
Joined: Thu Apr 23, 2009 7:41 pm
Location: UK London
Contact:

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by Miles » Sun Jul 26, 2009 6:02 am

Hi Captain. The code looks fine.

I suspect you've missed something or have a dodgy cable somewhere. VirtualWire is pretty reliable. Make sure you keep with the stock setup initally before you start playing with it otherwise you'll run into trouble :)

-Miles
Many Thanks,
Miles
---------------
Software Engineering meets Physical Computing. Fantastic, I wish we had this good 20 years ago.

jamie.wilson
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Mon Jul 27, 2009 3:38 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by jamie.wilson » Mon Jul 27, 2009 3:50 pm

So I was having trouble with these and gave up on them, didn't see this forum though!

Where i'm at:

void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("A");

// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
Serial.println("B");
vw_setup(2000); // Bits per sec
Serial.println("C");
}

Only produces an "A" and a "B" in the output. So I have worked out that vw_setup() is failing. I tried to go in and comment all of the content of the function out to see if I could test what in the Virtualwire Library was failing. But it still doesn't fire properly...

Any ideas? Has anyone got the library working successfully with these (http://www.seeedstudio.com/depot/433mhz ... p-127.html) ?? I don't care if I use Virtualwire or another method (like the sparkfun.com method) - but none are working and i'm desperate.

void vw_setup(uint16_t speed) { }

Miles
Kindergarten
Kindergarten
Posts: 91
Joined: Thu Apr 23, 2009 7:41 pm
Location: UK London
Contact:

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by Miles » Mon Jul 27, 2009 9:20 pm

I've not seen that problem before. I dont have the time at the moment to check but try my varient on this library.

http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1247875849

Change rf.send("your message"); to rf.send.("yourmessage", false);

Let me know how you go with that
Many Thanks,
Miles
---------------
Software Engineering meets Physical Computing. Fantastic, I wish we had this good 20 years ago.

Miles
Kindergarten
Kindergarten
Posts: 91
Joined: Thu Apr 23, 2009 7:41 pm
Location: UK London
Contact:

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by Miles » Mon Jul 27, 2009 9:25 pm

Oh in addition, I have those same modules you suggested and VW works great.
Many Thanks,
Miles
---------------
Software Engineering meets Physical Computing. Fantastic, I wish we had this good 20 years ago.

CaptainObvious
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Mon Jul 13, 2009 2:56 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by CaptainObvious » Tue Jul 28, 2009 6:00 am

Woot! User error, indeed. Turns out the new breadboard I got, is reaallllly touchy with the jumper wires I got, if it's not in like perfect, it won't receive. Haven't had the same problem with lighting LEDs, or anything else I've used, only when I've used the receiver so may be some kind of weird breadboard interference /shrug.

But it works! Once the LED started blinking, I cried a little bit on the inside.

Using the Virtual Wire examples,
Transmitter side = pin 12
Receiver side = pin 11
That was a bit confusing for me.

Next, hopefully... I'm going to hook up a 4x20 LCD, and put it in the next room, and talk crap to my brother :D Just for fun, and I really want to learn programming more, and so far the best way for me, is using previous code, breaking it down, re-writing it, and adding functions as I go.

Thank you for your patience, I'm slow at times, but each learning experience is worth it!

jamie.wilson
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Mon Jul 27, 2009 3:38 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by jamie.wilson » Tue Jul 28, 2009 9:57 am

So this Hypercom library looks alot more promising.

It took a while to get any response but where I'm at now is:

Transmitter is connected to Digital 10 on Arduino, using code from the link above. Is this right?
After startup the blue light stays solid for awhile and then the red light flashes 5 times (so failing to transmit).

The Receiver is connected to Digital 8 on Arduino. (??)
Red flahes twice
Green flashes twice
All three light up for maybe 5 seconds
Blue goes solid

And in the debug window I get these:
Unhandled status: 29
Unhandled status: 28
Unhandled status: 29
Unhandled status: 28
Unhandled status: 29
Unhandled status: 30
Unhandled status: 25
Unhandled status: 64
Unhandled status: 62
Unhandled status: 63
Unhandled status: 65
Unhandled status: 29
Unhandled status: 30
Unhandled status: 64
Unhandled status: 62
Unhandled status: 63
Unhandled status: 65
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 28
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 28
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24
Unhandled status: 29
Unhandled status: 30
Unhandled status: 25
Unhandled status: 64
Unhandled status: 62
Unhandled status: 63
Unhandled status: 65
Unhandled status: 29
Unhandled status: 30
Unhandled status: 64
Unhandled status: 62
Unhandled status: 63
Unhandled status: 65
Unhandled status: 29
Unhandled status: 30
Unhandled status: 24

Where can I find a list of what these mean??

jamie.wilson
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Mon Jul 27, 2009 3:38 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by jamie.wilson » Tue Jul 28, 2009 10:40 am

Well I feel pretty stupid, I didn't change the rf.send to include 'false'. That seems to have fixed the problem with the transmitter, but the receiver isn't happy.

I'm finally transmitting between the two which is exciting, but the receiver has 3 solid lights for a second, and then the green flashes (while it receives), then back to 3 solid lights. It does this over and over, receiving around one in every 5 sends from the transmitter.

I also have a question about speed, there is no delay in the transmitter sending its message, which is "T01.04.100" (this is the format i'll be sending in for my final app). It is probably firing 3-4 times a second. Is there a way to speed this up (i don't know too much about this stuff), as i'll be reading potentiometer values from a toy affecting sound and it needs to be realtime.

Something that has happened a couple of times since i've been working on this as well, is that there seems to be some sort of 'time-out' happening. Once the transmitter has been going hard for a while, it goes to 2 red blinks and 1 green blink, and the receiver gives up all together!

Cheers for all your help guys, i'd be screwed without you!

CaptainObvious
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Mon Jul 13, 2009 2:56 pm

Re: RF Reciever & transmitter [433Mhz, 315Mhz] Library.

Post by CaptainObvious » Tue Jul 28, 2009 11:15 am

Well I really like how.. simple the code looks for the VirtualWire. That's a big thing for me!

I'm still a wee-little nublet in the programming sense.. actually all of the electronics sense. I'm kind of looking to send commands to my LCD, having transmitter connected to the PC sending commands to it to say something, but it's a bit out of my league at the moment. one step at a time I suppose:D

Post Reply