Go Down

Topic: RF transmitter and reciver (Read 498 times) previous topic - next topic

luke1947

I am creating something like a key finder on my arduino. I plan to push a button turning on the transmitter. The receiver will connect to a second arduino which will have a if x >y statement. When the transmitter is on this statement should turn on a buzzer. I feel as though this code makes logical sense however all the research I've done on RF transmitting with arduinos always are very complex and include the TX and RX slots. I am new to this and only roughly understand their function so would prefer to stay away from them. Can anyone tell me if a normal analog imput will work for just telling an arduino if the transmitter is on? And if so does the rest of the code sound alright?

TRANSMITTER
const int switchPin = 2
const int rftransPin = 8

int switchState = 0

void setup() {
  // put your setup code here, to run once:
  pinMode(switchPin, INPUT);
  pinMode(rftransPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  switchState = digitalRead(SwitchPin);
  if (switchState == HIGH) {
    digitalWrite(rftransPin, HIGH);
  }
  else {
    digitalWrite(rftransPin, LOW);



Reciver
const int buzzerPin = 2
const int rfrecPin = A1

int rfrecState = 0

void setup() {
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  rfrecValue = analogRead(rfrecPin);
 
  if(rfrecValue > 150)
    digitalWrite(buzzerPin, HIGH);
  if(rfrecValue < 150)
    digitalWrite(buzzerPin, LOW);

oric_dan

There are probably 100 different RF devices around, so it would help to know
what you're using.

Erdin

#2
Mar 20, 2013, 07:56 pm Last Edit: Mar 20, 2013, 08:32 pm by Erdin Reason: 1
RF modules with RX and TX have a chip that handles the protocol.
The very cheap RF transmitters modules can only switch the transmitter on and off.

I guess you have a very cheap 433MHz RF module.
http://www.ebay.com/sch/i.html?_odkw=433mhz&LH_BIN=1&_sop=15&_osacat=0&_from=R40&LH_PrefLoc=2&_nkw=433mhz+-antenna&_sacat=0
The output pin of the receiver module does not reflect the signal strength. You have to hack the circuit to find the signal strength (find the capacitor for the automatic gain control).

For these cheap modules, switching it on and off can not be detected by the receiver, due to the agc (automatic gain control). You have to use a software protocol. The VirtualWire is (the only) good library for that, http://www.open.com.au/mikem/arduino/VirtualWire/



mixania

Or these:
https://www.sparkfun.com/products/10532
https://www.sparkfun.com/products/10534
Arduino Uno R3
Mac OSX Lion

Go Up