sparkfun wireless reciever and transmitter problem

i just purchased and recieved:

i hooked up my arduino to work standalone and hooked up the transmitter to send out the number 10 every second.

i'd post the code, but it's gone, but it's very simply turns serial on 4800 and then uses serial.print to send out 10 every second, and the reciever ( used the code off of sparkfun's site, klp walktrhough... )

/*
* Simple Receiver Code
* (TX out of Arduino is Digital Pin 1)
* (RX into Arduino is Digital Pin 0)
*/
int incomingByte = 0;
void setup(){
//2400 baud for the 434 model
Serial.begin(2400);
}
void loop(){
// read in values, debug to computer
if (Serial.available() > 0) {
incomingByte = Serial.read();
Serial.println(incomingByte, DEC);
}
incomingByte = 0;
}

so i have all the wires hooked up, from what i can see correctly, and the reciever hooked up to the computer is recieving nothing.

i uploaded the code, go to the serial port, turn on the transmitter, and nothing occurs. i have an led on the standalone which shows that there is power, and i even hooked up an led from the tx of the ardouino to the output of the transmitter, and the led flickers, which im guessing means it is sending info.

anybody have any experience with these? or know what i might be doing wrong?

You should try a library for these, makes communicating much easier.

SoftWareSerial (comes with the IDE) works pretty good, VirtualWire has extra data in the code, so it filters out the RF noise, I believe LadyAda has a library as well.

You should try refrain from using 0 and 1 anytime you can, and with SoftWareSerial (or other libraries) you can turn other pins into TX and RX pins, only up to I believe 9600bps(due to software limitations?).

Here's the link for VirtualWire, has a long PDF Write-out of all the commands it uses, still a bit confusing.
Library:http://www.open.com.au/mikem/arduino/VirtualWire-1.3.zip
Instructions for libraryhttp://www.open.com.au/mikem/arduino/VirtualWire.pdf

Hope this helps!

Try using these, these are some examples I found... not sure where. They use the Library included with Arduino, it just reads a button, and sends if the state changes to the receiver.
(When the transmitter is not hooked up, the receiver will just read random crap from anything.. and print out garbage)
Hook up 2 to the RX (receiver)
Hook up 3 to the TX (transmitter)

Transmitter:

#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

// 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 val = 0;
byte onState = 99;
byte offState = 98;

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);
  if ( val == HIGH ) {         // check if the input is HIGH (button pressed)
    rfSerial.print(onState, BYTE); // OK send it to the RF transmitter
  } else {
    rfSerial.print(offState, BYTE);  // send a 0 through the transmitter
  }
}

Receiver:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
#define ledPin 13

// 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() {
  // 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
}

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)
    Serial.print(someChar, BYTE); // send data to computer
    prevChar=someChar; // store what we just read
  }
}

thanks! i contacted a sparkfun support member, and the told me i can't just get these to work because a start and stop bit is needed to send the message. since i'm a begginer with this stuff, i had no idea what the hell to do lol, so from what you said, i'm guessing this library will know to send the stop and start bits.

thank's alot for the info, let's hope it's not too confusing lol, i'm sure i'll manage tho!

and i'll definitly write back if i was able to get it working

just out of curiosity, does the software serial library give the transmitter the start bit to make it send a message? i'd like to try and not have to learn the virtual wire library since i read the complete pdf, and i don't understand how to use the functions, and how to change them to do what i want.

edit:

so i tried the software serial library, and it kinda worked..... kinda....

when something is not connected, then like you said, it spits out garbage, that i don't mind, but i know it connects since it stops spittng out garbage when i have everything connected. but what it does print out is still garbage. it's indiciferable. but i definitly know it can see it! that's a big leap, it means it's really close to working!

i altered the code just for the transmitter to send numbers instead of read the switchs, so that may have screwed up the reciever's stuff...

edit edit:

still not working, so i'll post my transmit code and reciever code to see if the code is the problem... just as before, when the two devices are connected, the reciever stops getting tons of garbage, and get's characters of garbage, so i know they recognize one another. now that i changed it to DEC i just get zeros most of the time instead of data... and i did debug my transmit data, it sends out a new number every second...

Transmit code:

#include <SoftwareSerial.h>

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

// 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 onState = 99;

void setup() {
  pinMode(ledPin, OUTPUT);    // declare led as output
  rfSerial.begin(4800); // our RF Link is a 2400 baud model (make sure you check this!)
  Serial.begin(4800);
  // 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(){
  onState++;         // check if the input is HIGH (button pressed)
    rfSerial.print(onState, DEC);
    delay(1000);
}

receive code:

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define ledPin 13
SoftwareSerial rfSerial =  SoftwareSerial(rxPin, txPin);


int someChar = 0;
void setup()
{
  pinMode(rxPin, INPUT); // set up pins for serial comm. with RF receiver
  pinMode(ledPin, OUTPUT);

  rfSerial.begin(4800); // begin serial connection with RF Link unit
  Serial.begin(4800);
 digitalWrite(ledPin,HIGH); // turn on LED
  delay(1000);
  digitalWrite(ledPin,LOW); // turn off LED
 
}
void loop()
{






someChar = rfSerial.read();
Serial.print(someChar, DEC);
delay(1000);
Serial.println("-----");
}

and that gives me in the serial port something like this:

"
0------
0------
255------
0------
0------
0------
246------
0------
0------
72------
0------
0------
0------
0------
0------
0------

"

and when i disconnect the transmitter, it just sends random values, almost none of which are zeroes...

ok, sorry to bump this but i'm trying everything and it's just not working!

so the software serial library shows me it's connected, bu won't give me data, just zeroes. and now the virtual wire library isin't working! it's giving me me this error with every example:

In file included from C:\Documents and Settings\ari\Desktop\A folder with stuff in it\arduino-0016\hardware\cores\arduino/WProgram.h:6,


c:/documents and settings/ari/desktop/a folder with stuff in it/arduino-0016/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected unqualified-id before 'double'


c:/documents and settings/ari/desktop/a folder with stuff in it/arduino-0016/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected `)' before 'double'


c:/documents and settings/ari/desktop/a folder with stuff in it/arduino-0016/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected `)' before 'double'

i updated arduino to the current one, and i don't know why it wouldent work

I wish I knew! I'm kind of in the same boat as you!
Well when I tried again, I was able to get.. something when they were connected, stopped receiving garbage, but it wouldn't receive anything else, even when the transmitter sent something else.

Then resetting the transmitter (or unplugging), will send the receiver to just read random numbers, until it's done resetting or plugged back in.
That was just trying to edit the SoftwareSerial, the transmitter counting from 0 to 255, and back down, sending out as a BYTE.

The code works fine when I'm using the button.. receiver prints bcbcbc (99 and 98 in hex? onState and offState on transmitter side) only printing the c while the button is pushed, goes back to b when you release. Receiving no garbage.. I tried to figure the code out to fit it in my own sketches, but no luck!

Ugh, I posted in Seeedstudios forum about the VirtualWire setup, hopefully getting some help on how to use it. I've gotten the examples to work.. but don't understand the code enough to change it to what I want.

But anyway, best of luck, lots of ranting, my apologies

Do keep us updated though, I've been trying for some time now. :slight_smile:

PS (Just read your post.. posted at the same time)
Delete all your VirtualWire files, and redownload the most recent version. Took a few tries, then it worked fine for me. Had the same problem!

ugh thank you so much!!!! glad to see somebody knows what i'm going through. I will try to see if i can get the button example working using software serial library, and try to modify it accordingly...

as you would guess, your b c theory is correct! cheack this out:
http://www.unitechnical.info/Products/ASCII-Chart.jpg

dec to char 98 and 99 is b and c!

so that's something to go on.

if i get anywhere i'll let you know, see if i can return the help haha!

Hi,
I wrote up this tutorial a while back. Might help you out.
http://narobo.com/articles/rfmodules.html

Thanks for that link, did help a bit, but opened up some more questions!

I kind of understand the idea of sending the bits,

Sending Packets
SendByte(start); // Send start byte
SendByte(data); // Send data byte
SendByte(addr); // Send address byte
SendByte(chksum); // Send checksum byte
delay_ms(2); // delay for 2 milliseconds

As of now, I'm able to.. well get an LED blinking when it receives, but changing that code, with no luck.
I don't even know where to start, hopefully this is the right place.. haha

How would one specify all these bytes in the Arduino IDE? Sending of the "password" if you will, so the receiver will only print the data incoming if it receives the "password"? And maybe having 2 "passwords" so if it receives one command, it will print to an LCD, if it receives another, it'll control something else. Or maybe the same sending would work, just need to change receiving side.

Can you post your code please?

It's the same code as posted above (my post, 4 or 5 posts above)

Except I added a potentiometer, and set it's value to onState, reading and sending every 1 second.

Any modification I've done so far, other than using if sensorval > 120, send onState. (sensor being a potentiometer, instead of a switch, to send) I was able to.. well.. send onState anytime the value changed above 120.
I deleted my previous code because it was just something I wrote from the softwareserial examples above.

Literally only changing the onState value to my potentiometer reading, but once I did that, receiver didn't receive anything. I'm assuming I need to add a few bytes more code, but not exactly sure what.

If it'll help to re-write it, let me know, only take 5-10 to jimmy another!

HA! i just found a hilarious ironic thing. When using the software serial library, i got garbage in the arduino ide until i hooked up the transmitter, then it would give me nothing, or zeroes.

I just got virtual wire library working, and put it into the transmitter, and it does the EXACT OPPOSITE! the library filters out noise, so when the transmitter is disconnected, it reads nothing, but when i connect the transmitter, i receive tons of garbage because apparently the data is indecipherable to the receiver.

still no data being passed, but the connection is atleast established... i'll try the regular software serial library example with a button, and if i can atleast get as far as captain, then maybe i can re work the code... hopefully... i'll also try the new tutorial that was posted, maybe i'll have better luck... it's starting to seem like im looking at that reciept more and more "Refund policy" lol!

edit:

forgot to change all the bps to 4800... changed it, now it's just spitting out this:
"68 65 6c 6c 6f"

which in charecters ( which i believe it was sapposed to spit it out as ) comes out to:
( i converted to char from hex, i looked it up on a chart, this was not given on the ide... )

"hello"

SO THERE IT IS!!! a form of data finally transmitted!

We're actually having a smiliar problem with the VirtualWire library, any chance you could post up your source code?
Thanks!

if you were talking to me, then i simply used the example code for send and recieve from the virtualwire samples...

the only thing is that the virtualwire library is so confusing, i have no idea how to modify it to do what i want it to do! the commands are so complicated that i don't know what to do! i just want to send one changing variable! if anybody knows the library well, please help...

were you able to get any success CaptainObvious?

as for me, i tried changing the virtual wire code to send data i want it to, but any changes i make to it in the commands, it just comes up as an error every time, because i put the command in worng, or it's an int to char error, or others...

I managed to get the Sparkfun 315MHz RF modules working using the VirtualWire library and adding the following line of code to fix the compile problem: #undef round

I hooked up an oscilloscope to both modules so I could observe both signals - works great.

Transmit 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>
#undef round 

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

    // Initialise the IO and ISR
    vw_set_tx_pin(3);
    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>
#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_set_rx_pin(2);

    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.print(buf[i],BYTE);
      }
      Serial.println("");
        digitalWrite(13, false);
    }
}