wireless communication with arduino boards

hi,

i'm trying to send an on/off signal from one arduino board to another using cheap sender and receiver modules that are operating with 868mhz...problem is i don't know how to program them..actually it's just sending a simple byte 0 or 1, so do i need a library such as VirtualWire for the transmission or is there an easier way cuz i can't really get the hang out of it, a better documentation(for total noobs) to the VirtualWire would be of great help too!

thx! akira

hi again,

here is the link to the radio transmitter/reciever module

http://shop.conrad.at/ce/de/product/190939/SENDE-EMPFAeNGERMODULSET868MHZ

hope it helps even it's in german!

thx akira

I'm pretty certain those RF modules are very simple and the receiver will simply pick up whatever is transmitted from the transmitter. i.e. wire them up and it is no different than having a wire between the two digital pins. Just try it and see what happens.

hi,

thx for the answer, but i already tried this with the script below and all i’m getting is a zero on the side of the receiver…any idea?

transmitter code------------------------------------------

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3

int val = 0;       // variable to store the value coming from the sensor

//using softwareserial
SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);   

void setup() {
   
 rfSerial.begin(4800);       //initialize softwareserial
 Serial.begin(9600);         // serial communication to the computer
}

void loop(){

     val = 1;

     Serial.print(val);               // send data to computer
     rfSerial.print(val, DEC);    // send data out tx

     delay(1000);

}

receiver code-------------------------------------------------------

#include <SoftwareSerial.h>                    
#define rxPin 2
#define txPin 3
SoftwareSerial rfSerial =  SoftwareSerial(rxPin, txPin);
int val = 0;

void setup() {

 pinMode(rxPin, INPUT);                // set receive as an input
 pinMode(txPin, OUTPUT);               //set transmit as an output
 rfSerial.begin(4800);                 // begin serial connection with RF 
 Serial.begin(9600);   // begin serial communication to the computer
  
}

void loop(){
 
               val = rfSerial.read();           //Read a Byte?? from the RX
               //if (val == 1){
               Serial.print(val, DEC);         // send data to computer      

               delay(1000);
               //}
}

I’ve never used the SoftwareSerial library before, but do you have to declare rxPin and txPin as INPUT and OUTPUT in the first (sending) sketch? You do declare them in the receiver code but not in the transmitter code.

hi, i'm a noob with this stuff, but in my op, when u don't declare it in the sending sketch how does the lib know which pin to use for serial.print ??

In my experience with NewSoftSerial (not sure with SoftSerial, but I don't see any reason it would be different), you don't mess with the pin assignment, the library does that work under the hood (which is the point of a library). The tx/rx pins are set by passing them into the constructor.

don't quite get that....what u mean by pasing them into the constructor??? and if u don't define the pins how does the lib know which one to use and which ones have a different purpose??? thx akira

You still have to define the pins (or pass them in), but you don’t have to set them to output / input, the library does that.

what u mean by pasing them into the constructor

When creating a new instance of a class (In this case you are creating an instance of SoftwareSerial called rfSerial) the class runs a constructor that does any setup work it needs. In the case of SoftwareSerial it allows you to pass the pins into the constructor as parameters.

SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin); <<The red area represents the call to the constructor.

you could also call it like such:

SoftwareSerial rfSerial = SoftwareSerial(2, 3);

HTH,
Rob

okay, now i'm on your channel...already tried it without defining the input/output stuff...but changed nothing....here is my actual progress: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1243465110/30

THX akira

How do you have them wired up?

The data sheet shows the hookup as follows:

power–>5v power pin on the arduino
ground–>ground on the arduino
signal–>digital pin 2 on the arduino <digital pin 3 on the arduino <<

your post on the other forum shows this:

the receiver just has 3 outputs that are connected as follows:
power–>5v power pin on the arduino
ground–>ground on the arduino
signal–>digital pin 2 on the arduino

It shows the input being the same way on the transmitter, ground to the unused pin on the serial.

So I think it should be tx=ground on the receiver (since it isn’t transmitting), and rx=ground on the transmitter (since it isn’t receiving), but you may have to switch them around.

sooo, i grounded them but now the receiver just gets high and low values without any input, again by touching the antenna of the transmitter there seems to be an interaction(led blinks different)...what u mean by: they may need to be switched??? thx akira

what u mean by: they may need to be switched???

I didn't go back to your original code to see which pin was rx vs tx, just copied your post from the other forum.

I think that this is what the instructions are showing, but I could be wrong:

Based on the code posted above: On the transmitter you will want the tx (3) to go to signal and rx (2) to ground On the receiver you will want the rx(2) to go to signal and tx(3) to ground.

Then use the softserial to communicate with them.

Again, I am basing this on the data sheet: http://www2.produktinfo.conrad.com/datenblaetter/175000-199999/190939-an-01-ml-Sende_Empfaenger_ModulSet_868MHz_de-en.pdf

It states "serial input" in the "intended use" section, but I'm not sure what they mean by the output line below :

Input /output signal Transmitter Right-angle signal (Manchester coding, amplitude dependent on the volume of the operating voltage of the transmitter) e.g. 3 to 15 Vss at 12 VDC

Receiver Hi +0.8 V; Lo 0 V

Is this what the serial library is expecting from the pins?? That's what I can't answer.

NOW IT WORKS!!!!!! don't know why, cuz the script is the same as before, one of my profs helped me and he had a more analytic approach maybe that's why....however here is the script for the transmitter and receiver, the trans gettin one value from a analog pressure sensor sending a on/off signal(0 or 1) to the receiver triggering the onboard led.....

transmitter code:

int digitalValue5, value;

void setup() {
// Serial port enable
Serial.begin(600);
pinMode(5, INPUT);
}

void loop() {
// read analog pin 5
digitalValue5 = analogRead(4);

// declare if on or off
if(digitalValue5 >= 512){
  value = 1;
}else{
  value = 0;
}

// send the value to the serial port
Serial.print(value, BYTE);
}

receiver code:

int val = 0;
void setup() {
// Serial port enable
Serial.begin(600);

// declare pin 13 as output, this is the LED
pinMode (13, OUTPUT);
}

void loop() {

// if there is bytes available coming from the serial port
if (Serial.available()) {

// set the values to the 'val' variable
val = Serial.read();

// write the value to the pin 13
digitalWrite(13, val);
}
}

again MUCHO THANKS TO ALL, who helped me with my problem!!! AkirA