Receiving RF Signals in Arduino

Hi All, Hope this is the correct Forum for this.

I'm working on a small project with Picaxe, which sends small packages of data to the arduino. (In the end on button press but now at interval of 0.5 seconds).

I really was wondering if anyone has any guides how how to read this data. When I read the analog port connected to the Receiver I get so much data that it must be noise, and it makes it hard for me to understand what I should be filtering and how!.

For reading I've been looking at this, but it seems I receive 9 values when I'm sending 8 bits and they don't seem to match either if one was a duplicate.

My PicAxe code if it's interesting to anyone

main: 
serout C.2, n2400, ( 01010000 )	; Send the data packet 
pause 500	; Wait 0.5 second 
goto main ;

I'm willing to send a prefix to make sure the signal is the one I'm looking for but I'm kinda stuck here.
Any good directions or readings I should look into. Have been searching for hours and hours.

Let me know what kind of info you'd need of me! The sender and receiver is a set I got from the Picaxe store, as far as I can see it should work fine with arduino: RF Radio Receiver - Circuit Creator - PICAXE

And my Arduino is a Uno from Robotale got it from dealextreme and it worked fine in other projects.

Hi, welcome to the forum.

Those very cheap ASK (on/off modulation) modules will only work with a good library that uses a special protocol. The receiver has an automatic gain control, that means it receives noise all the time. A good library will retrieve the data from the noise.

The VirtualWire (now included in RadioHead) is by far the best protocol.
http://www.airspayce.com/mikem/arduino/VirtualWire/
The VirtualWire even allows (a very few) error spikes in the signal.

Most RF modules are transceivers, they have a chip that takes care of the modulation and demodulation. They are the Hope-RF RF22B, or Nordic NRF24L01+, or many others.
Here is a list of RF modules : Wireless Buying Guide - SparkFun Electronics

You can get by without using Virtualwire if you dont have suitable hardware at both ends, by simply using Manchester Coding and sending a flag sequence, followed by a unique sync byte followed by your data.
There is a Manchester Library for Arduino, for the picaxe you will have to write your own, but its pretty easy to do.

Hi, Yes I've looked into the Manchester encoding I thought picaxe would do that automatically if it doesn't that makes sense why I couldn't get it to work.

I'll look into the library first since I configured it to work with the arduino software yesteday.

I wonder what I would need to do to get a hello world out of there, but I guess the docs will tell me?

Hmm I've got the Receiver example code hooked up of VirtualReceiver.

Added vw_set_rx_pin(11);
before the vw_rx_start

Not receiving anything right now, shouldn't it even get messages from random other stuff, like when I press a button for a light (RF signal)?

If I cannot receive values from a different device (like the picaxe) can anyone confirm this by any chance? I'm getting nothing with the example code.

Post your transmit & receive code.

Virtualwire is smart enough to not pass on garbage characters.

Allright, but as stated I have a Picaxe to transmit so it's basic.

main: 
serout C.2, n2400, ( "PBST #" )	; Send the data packet 
pause 5000	; Wait 0.5 second 
goto main ;

really basic, I wanted to use the PBST as preamble.

and I slightly adjusted the VirtualWire example receiver code (It didn't say which pin it'd be using):

// 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@airspayce.com)
// 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(2400);	 // Bits per sec
    vw_set_rx_pin(11);
    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);
    }
}

Probably scary looking, but these are my current boards, I hooked the picaxe to the Arduino since it needs 5v and this is easier than putting a battery pack on it.

Got a schematic to help interpret that?
You wrote something up to show how you connected it all?

Read the virtualwire documentation - the receiver is expecting some data to sync up on, then a Manchester encoded message. Your transmit code does neither.

Does not use the Arduino UART. Messages are sent with a training preamble, message
length and checksum. Messages are sent with 4-to-6 bit encoding for good DC balance,
and a CRC checksum for message integrity.

Implementation Details
Messages of up to VW_MAX_PAYLOAD (27) bytes can be sent
Each message is transmitted as:
• 36 bit training preamble consisting of 0-1 bit pairs
• 12 bit start symbol 0xb38
• 1 byte of message length byte count (4 to 30), count includes byte count and FCS
bytes
• n message bytes, maximum n is VW_MAX_PAYLOAD (27)
• 2 bytes FCS, sent low byte-hi byte
Everything after the start symbol is encoded 4 to 6 bits, Therefore a byte in the message
is encoded as 2x6 bit symbols, sent hi nybble, low nybble. Each symbol is sent LSBit
first.
The Arduino Diecimila clock rate is 16MHz => 62.5ns/cycle.
For an RF bit rate of 2000 bps, need 500microsec bit period.
The ramp requires 8 samples per bit period, so need 62.5microsec per sample => interrupt
tick is 62.5microsec.
The maximum packet length consists of
(6 + 2 + VW_MAX_MESSAGE_LEN*2) * 6 = 408 bits = 0.204 secs (at 2000 bps).
where VW_MAX_MESSAGE_LEN is VW_MAX_PAYLOAD + 3 (= 30).
The code consists of an ISR interrupt handler. Most of the work is done in the interrupt
handler for both transmit and receive, but some is done from the user level. Expensive
functions like CRC computations are always done in the user level.
Caution: VirtualWire takes over Arduino Timer1, and this will affect the PWM capabilities
of the digital pins 9 and 10.

Here's and older rev of Virtual wire that had more info than later revs, when most of it went online instead.

VirtualWire.pdf (138 KB)

I think I have this exact PDF. But I didn't know what I was looking for but I guess I should look into sending a proper message I'll see if I can find out what it should be like, in reply to your previous question:

Not really, Honestly most of the spaghetti wires is the programming of the Picaxe.

Receiver goes into Pin 11 on arduino (one of the two data pins on the receiver).

For transmitting the C.2 Port on the picaxe goes to the Data port on the transmitter. The rest is a simple 5v tot VCC (for transmitter) and 5v to 5v for the receiver, and a cable to GND to arduino's GND.

I'll look into what I should send then instead. thanks for the heads up.

http://forum.arduino.cc/index.php?topic=93932.0

This has a lot of info about the message I'm gonna try this.

Sorry to ask, do you have an example what the raw message would look like.
I'm currently trying something like:

serout C.2, n2400, ( 0,1,0,1,0,1,0,1,   0,1,0,1,0,1,0,1,   0,1,0,1,0,1,0,1,   0,1,0,1,0,1,0,1,   0,1,0,1,   1,0,1,1,0,0,1,1,1,0,0,0,  1,1,1,1,1,1,1,1)

The first 5 sets are the 01 x 18 (36 bits). the next part should be the 12 bit identifier if google is correct. So I added the 8x 1 bit as message. but nothing is coming through just yet.

No idea. I've only used it as Tx/Rx pair between Arduinos, never looked at the raw data.

You could get an FTDI Basic, set up the Arduino to transmit (will be like having software serial on pins 11,12 if using the default pins), and use a serial program like Putty to receive the message to see what comes out.

Or I suppose use pins 0,1 to do the same.

Working on my last school assignment I still have open,
Hoping to deliver it tomorrow but I guess I'm not going to make it I guess that's another half a year of College fee :' (.

No but seriously I'll see if I can do the putty thing though I have no idea yet how.
Oh just noticed I have to buy a module for that. hmmmmm.

Oh is it ok to set the bytes per second to 2400? The Picaxe is sending at this rate.

To use VirtualWire it must be running at both ends, ie the Picaxe must also be running VirtualWire.
Im not aware of any picaxe code to do this , so you will have to write your own.
Hence my previous suggestion to simply use the Arduino Manchester library, and write your own Manchestercoder for the Picaxe.
The other alternative is to use better radios that sill simply accept a serial data format.