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

I am now transmitting pretty well between the two…

But this “Out of memory, cannot create packet” is my main problem, it stops the connection being fast. It has this message between every receive.

Any ideas about clearing the memory??

The problem is you are trying to send to much for the arduino to handle. It’s still quite an early build so it uses quite a lot of memory to send data.

Try and reduce the amount of data you send…

Hmm, it shouldn’t really crap out. That could be a bug you’ve uncovered.

The lights are basically my implementation. green light means it’s recieving a “packet stream”. Blue means it’s either pending recieving or sending and the blink green means it has been succesful.

If it takes “forever” and blinks red, that means it was expecting a confirmation but never recieved anything.

…Just while we’re on the topic…

For everyones information the diference between HyperCom, VirtualWire and, for example, software serial is reliability.

My library inparticular is focused around assuring a message is recieved by the remote client. VirtualWire adds some extra data which adds a little redudancy so it’s more likely the remote client will receive NON-CORRUPT data.

First off, I’d like to say thanks ALOT for the help Miles, I was tempted to just let my 2 pairs gather some dust! (along with a couple LCDs) I got it up and… well receiving! Just not able to send what I want at the moment.
Well, I’m a little confused on how to … send information! :smiley: I’ve used a sample sketch for a button and receiver setup using SoftWareSerial.

I think I understand how to use rfSerial.send(); but not really sure how the send syntax is, if I could send say… a few words and have the receiver receive, and print those words. Bit lost when it comes to that, and filtering out the noise. When I have the two running, transmitter and receiver, I only print… cbcbcbc to serial and lcd, which is the 99 and 98 button state… Confusing! lol

Ultimately, I’d like to have… say an Arduino connected via USB to the computer, sending data I input to the receiver, which will then print on an LCD. And also using potentiometer values on the Transmitting side, to change the value of LEDs on the receiving end. Psuedo(spelling?) code would be AMAZING. I’ve read the VirtualWire document and used the samples… but also a bit confused on receiving the data I want to send… and not the random RF waves. I’m just more comfortable at the moment with SoftWareSerial because the commands are so much like the Serial commands I’ve been working with.

I did try to edit some of the code I had to send values over, without any luck… Now all I’m reading is garbage. The sketch, previous to my edit was to read a button from the transmitter, and when I push the button, it would send a C rather than B, and vice versa (99 and 98 are B and C in decimal)

Any tips for… optimizing the code, and well, getting it to work correctly, would be much appreciated!:smiley:
Transmitter

[code]#include <SoftwareSerial.h>
/*
Read a pushbutton and send a value
to another microcontroller.
*/

#define rxPin 2
#define txPin 3
#define buttonPin 12
#define ledPin 13
#define potPin 0

// set up a new serial connection for communicating with RF transmitter
// (this also frees up Arduino’s built in serial port for PC communication)
SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);

byte potVal = 0;
byte val = 0;
byte onState = 99;
byte offState = 98;

byte prevpotVal = 0;

void setup() {
pinMode(buttonPin, INPUT); // declare pushbutton as input
pinMode(ledPin, OUTPUT); // declare led as output
rfSerial.begin(2400); // our RF Link is a 2400 baud model (make sure you check this!)
// start by blinking high and then low so we can tell the setup routine has been completed
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
}

void loop(){
val = digitalRead(buttonPin);
potVal = analogRead(potPin) /4;
delay(20);

if ( potVal != prevpotVal ) { // check if the input is HIGH (button pressed)
rfSerial.print(onState, BYTE); // OK send it to the RF transmitter
digitalWrite(13, HIGH);
} else {
rfSerial.print(offState, BYTE); // send a 0 through Transmitter
digitalWrite(13, LOW);
}
prevpotVal=potVal;
}
[/code]

Receiver[code]#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

#define rxPin 11
#define txPin 12
#define ledPin 13

LiquidCrystal lcd(9, 8, 2, 4, 5, 6, 7);

// set up a new serial connection for communicating with RF receiver
// (this also frees up Arduino’s built in serial port for PC communication)
SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);

char prevChar = 0;

void setup() {
lcd.begin(4, 20);
delay(100);
lcd.print(“Loading…”);
// set up the input and output pins
pinMode(rxPin, INPUT); // set up pins for serial comm. with RF receiver
pinMode(ledPin, OUTPUT);
// initialize serial comm
rfSerial.begin(2400); // begin serial connection with RF Link unit
Serial.begin(2400); // begin serial communication over USB to the computer
// blink LED on and then off just to let us know the setup routine is complete
digitalWrite(ledPin,HIGH); // turn on LED
delay(1000);
digitalWrite(ledPin,LOW); // turn off LED
delay(2000);
lcd.clear();
lcd.print(“Ready2Receive:”);
Serial.print(“Ready2Receive:”);
lcd.setCursor(0,1);
}

void loop(){
char someChar = ‘0’;
someChar = rfSerial.read(); // read whatever the RF Link has to offer
// print out the character:
if (someChar!=prevChar) { // only print out new data (don’t print 0 a billion times in a row)
// send data to computer
Serial.print(someChar);
lcd.print(someChar);
prevChar=someChar; // store what we just read
}
}[/code]

Hi Mate,

what you’re asking doesn’t really relate to the aformentioned library and isn’t really something I know all that much about. I’m surprised Serial is even working at all.

Can I suggest you move this post to the Arduino forums www.arduino.cc?

-Miles

Cheers,
sorry for the mixed up questions, a bit confused, as always! :slight_smile:

Some questions I did have though, I noticed on your page you posted about a wireless LCD screen, I’ve tried using the VirtualWire library to send information to another Arduino and print it out on the LCD. Just constantly sending a 255 to try get the two to connect… well I’m able to get the examples to work just fine, but I can’t seem to… well send my own information! Is there any way you could… newb-i-fy some uber psuedo code on how I would go about doing such a thing?:slight_smile:

Tried using vw_send to send, along with vw_get_message… completely confused and not sure what information to put in the ( ), reading the instructions I see stuff like int8_t stuff that’s just a bit over my head.

I’d like to, at a later time (obviously, first things first…) send information I input from my computer, just like “hellooooo” :slight_smile:

Thanks in advance.

Hi Captain,

There’s not much outside of the inital example that I can suggest for you. You simple state the characters you wish to send and the reciever, signal strength permitting, will output the string. You may need to cast the uint8_t object to a char but aside from that nothing complicated.

I’d suggest using the library I developed as that handles strings in an easier maner.

Thanks for the reply!

I’m sure I’m… overthinking this stuff, but I just… am so confused! lol :confused: I do understand a bunch of the commands (for the most part, at least what they do, not so much how they operate).

But in terms of the vw_send() and get messages, I don’t understand the terms they’re using to connect the two.

vw_send((uint8_t *)msg, strlen(msg));

In loop, there’s a const char *msg = “hello”; So I’m assuming that’s what’s being sent out of the transmitter. I don’t get the use of the *, but that’s for next time!
strlen(msg) Message length, I’m assuming. Not TOO confusing, but now, I don’t understand how the receiving end picks up just the message, without the noise. I figured it would be something along the lines if message == (“hello”) … (psuedocode)
But I don’t see a “hello” or anything of the sorts in receiving end.

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))

I just searched for uint8_t and I found (I think I read it right) that it’s equal to unsigned byte?

I understand that we’re buf and buflen integers, but I don’t get why VW_MAX_MESSAGE_LEN, and how that opens up the ability to communicate with the transmitter!

Oi, I’m sorry if this isn’t the right place… or I’m a hassle, not really sure where else to ask these kind of questions, I’ve been asking around Arduino forums some, everyone just points me to VirtualWire, just not understanding alot about how it works.

Sorry for the long post, and thanks again for taking time to even read these, probably lots of repeating myself. :smiley:

Ah now I’m starting to understand your troubles.

I’d STRONGLY suggest you read some C++ 101. Pointers will confuse the crap out of you otherwise.

For your own sanity:

vw_send((uint8_t *)msg, strlen(msg));

Let me break that down. Your message *msg = “hello” means hello is an array of CHAR. Without going into detail (I’m no teacher) * basically means, in this case, make “msg” point to the memory address of “hello”.

Internally lots of the Arduino stuff uses uint8_t instead of char. They are basically the same if you were to look at the memory which makes up that variable. What that line means “I want to look at msg as if it were an array of uint8_t”. uint8_t is just a standard whole number.

As you can probably guess strlne is the string length. The curve ball here is C++ doesn’t understand arrays. All it knows is memory addresses. What vw_send will do is take your msg, which is actually ponting to “h” in “hello” and then read each memory after ‘h’ and stop after “strlen(msg)”.

So basically:

It recives the pointer to ‘h’

‘h’ is now at memory address 10. You’ve told me the array (what’s known as a string) is 4 bytes long (a char is one byte, which is 8 bits). So it’ll read h then e… etc etc

The dangerous thing about c and c++ is vw_send doesn’t realy know what it’s reading from memory! You have to be careful to tell it what to read.

Okay, that’s a little c++ 101. The problem you’re having is char msg is what’s called a constant. That means it CANNOT change. It’s stuck. If you remove that keyword you can then change msg to say what you like.

The problem is, virtualwire gets a little funny when you fiddle with it (I ran into some problems). Without sounding like a broken record, I’d strongly suggest you use HyperCom as that handles all that confusing stuff.

rf.send(“your message”, false); << doesn’t get much more simple than that :wink:

Wow…
After, well… getting it… it all makes sense! Go figure right? :smiley: I was right though, I was over thinking it.

Well understanding it more, anyways:D
But you’re right, removing the const and trying to have a variable that I can send just doesn’t work! I’m able to send small messages that I’ve preset on the transmitter, which is kind of what I wanted to do in the first place.

But I seen over on Practicalarduino.com they used VirtualWire to send over information from a Lacrosse Weather Station(on their roof) to the receiver every 2 minutes. Just… so…sexy! I’m loving learning new things everyday.

Thanks again for all your help! Understanding for me… well, takes time, sometimes! :smiley: That’s what I get for diving in head-first.

But I did try to use the HyperCom library, it doesn’t include the LED.h file with it for the examples, which wasn’t too bad to work around, but after a little editing, I wasn’t able to get a connection. So I’ll just work with what I’ve got for now, it seems to work for other people fairly well, so it’s user error. :smiley: I’ve gotten some sent, now time to work in my LCD, and hopefully be able to send commands via Serial on the transmitter.

Only time will tell! Thanks again for all your help!!

Hi everybody,

I’m trying to get the grove 433Mhz work on my arduino uno without success for 2 weeks now…
My projet is to use attiny85 chips to receive a command from the rf link to make a led blink.
I’ve try to use manchester on it (see https://github.com/mchr3k/arduino-libs-manchester for more details).

So i have connected the rx and tx on my arduino just for the test, and i receive nothing!
Do you think it’s possible to get it work on the same board to be sure it can work?

Does someone even build something with an attiny85?

This is the code for testing on arduino uno:
#include <MANCHESTER.h>

#define TxPin 2 //the digital pin to use to transmit data

#define RxPin 12

unsigned int Tdata = 0; //the 16 bits to send

void setup()
{
MANCHESTER.SetTxPin(TxPin); // sets the digital pin as output default 4

MANCHESTER.SetRxPin(RxPin); //user sets rx pin default 4
MANCHESTER.SetTimeOut(1000); //user sets timeout default blocks
Serial.begin(9600); // Debugging only

}//end of setup

void loop()
{
Tdata +=1;
MANCHESTER.Transmit(Tdata);

unsigned int data = MANCHESTER.Receive();
Serial.println(data);

delay(100);
}//end of loop

Thanks!!

thanks for sharing information