433 RF question.

Hello!

Please give some insight into following issue:

Got 1 Arduino UNO and some RF modules (http://dx.com/p/433mhz-rf-transmitter-module-receiver-module-link-kit-for-arduino-arm-mcu-wl-green-220194)

Hardware setup is:

Arduino +5V -> Transmitter Vcc Arduino GND -> Transmitter GND Arduino 3v3 -> Transmitter Data

Arduino +5V -> Receiver Vcc Arduino GND -> Receiver GND Arduino pin2 -> Receiver Data

Transmitter and receiver are on the same breadboard.

Sketch is:

int rfPin = 2; //digital 2

void setup(){
  Serial.begin(9600); 
  pinMode(rfPin, INPUT);
}


void loop(){
  int rfVal = digitalRead(rfPin);  
  Serial.print(rfVal); 
  delay(100); 
}

I expect to get a running series of '1's in serial port but instead i got some random sequnce of '1' and '0'. Am I missing something ?

Thanks in advance.

Take a look at the Virtual Wire library.

http://www.airspayce.com/mikem/arduino/index.html

Arduino 3v3 -> TX Data

Serial data consists of a series of start bits, data bits, and stop bits. A constant high will not result in start and stop bits. So, the fact that the stream is not interpreted "correctly" is hardly surprising.

Thanks for replys.

Erni: Take a look at the Virtual Wire library.

http://www.airspayce.com/mikem/arduino/index.html

Please correct me if I'm wrong but this library supposes use of 2 mcu while my scenario is simplier.

PaulS:

Arduino 3v3 -> TX Data

Serial data consists of a series of start bits, data bits, and stop bits. A constant high will not result in start and stop bits. So, the fact that the stream is not interpreted "correctly" is hardly surprising.

I don't really get your reply. Serial is only used to write a variable value. Variable holds HIGH or LOW which is read of a pin where receiver is connected to. And since transmitter is always transmitting (due to 3v3 permanently connected to tx data) I expect receiver data to be also HIGH always.

Regards.

Serial is only used to write a variable value.

The process that Serial uses, though, is to get the bits (0s or 1s) from the value, and send those bits AND some start and stop bits.

Since the receiver detects the start and stop bits to know where the data starts, it is confused by the complete lack of change. So, don't expect to get valid output with garbage input. A constant 3V3 input is NOT valid input. You might as well throw the radios away and simply connect the 3V3 signal on the "receiver" to whatever you expect TX to deliver to.

PaulS:

Serial is only used to write a variable value.

The process that Serial uses, though, is to get the bits (0s or 1s) from the value, and send those bits AND some start and stop bits.

Since the receiver detects the start and stop bits to know where the data starts, it is confused by the complete lack of change. So, don’t expect to get valid output with garbage input. A constant 3V3 input is NOT valid input. You might as well throw the radios away and simply connect the 3V3 signal on the “receiver” to whatever you expect TX to deliver to.

Ok, let’s put in another way:

int rfPin = 2;
int ledPin = 13;

void setup(){

pinMode(rfPin, INPUT);
pinMode(ledPin, OUTPUT);
}

void loop(){

int rfVal = digitalRead(rfPin);
if(rfVal == HIGH) digitalWrite(ledPin, HIGH);
else
digitalWrite(ledPin, LOW);
}

Would this one light led 13 on when 3v3 applied to data out of transmitter and led 13 off when there is no 3v3 on data out of transmitter ?

Those cheap 433 Mhz radio modules wont simulate a hard wired connection, so you cant easily send serial data thru them without some kind
of data processing, which is what The Virtualwire library does.

mauried: Those cheap 433 Mhz radio modules wont simulate a hard wired connection, so you cant easily send serial data thru them without some kind of data processing, which is what The Virtualwire library does.

I'm not going to use 2 mcu. I'm willing to connect a simple PIR signal out to tranceiver data out and connect receiver data out to some Arduino pin to monitor it. So I'm willing to know if it's ever possible using aforementioned hardware.

Thanks.

Virtualwire cannot send and receive to itself on the same microcontroller - I have never seen anybody get that to work in nearly 3 years here. It is intended to have Tx on one uC and Rx on another uC.

user2013: I'm not going to use 2 mcu. I'm willing to connect a simple PIR signal out to tranceiver data out and connect receiver data out to some Arduino pin to monitor it. So I'm willing to know if it's ever possible using aforementioned hardware.

This has little chance of working. The data that the PIR sensor sends to the RF Tx unit must be encoded into a pulse train of binary data. A simple ON or OFF is not going to result in anything useful happening over at the Rx module connected to the Arduino.

If you really don't want a microcontroller at your PIR sensor, a 555 chip may be able to create the necessary pulse train.

I'm not going to use 2 mcu.

What are the radios for, then?

If you dont want to use 2 mcus, its possible to use dedicated hardware such as SC2262,SC2272 encoder / decoder chips with those radios to send simple 4 bit logic states from one location to another. This method is designed for applications where a simple button press is all thats needed, and the decoding process is slow. Can take a few 100 ms to decode the data.

In my blog you have a complete tutorial about using virtualwire and also how to send varaibles( one or more ) using this library.

controlrobotics.rodrigomompo.com please leave some comments