send-receive RF433

Hi, I'm trying to send and receive using only an Arduino, but he is listening not sent and vice versa. I need to send a code of 4 digits when a PIR sensor detects presence and can also receive 4-digit codes at the same time, is it possible?

The code that I have to detect presence and send it:

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

int calibrationTime = 30;        

//the time when the sensor outputs a low impulse
long unsigned int lowIn;         


long unsigned int pause = 5000;  

boolean lockLow = true;
boolean takeLowTime;  

int pirPin = 7;    //the digital pin connected to the PIR sensor's output
int ledPin = 8;
int rele = 0;


void setup()
{
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(rele, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++)
    {
      Serial.print(".");
      delay(1000);
    }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
    
    mySwitch.enableTransmit(10);
    
}



void loop(){

     if(digitalRead(pirPin) == HIGH)
     {
       mySwitch.send(5393, 24);
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       digitalWrite(rele, HIGH);
       if(lockLow)
       {  
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
         Serial.println("---");
         Serial.print("motion detected at ");
         Serial.print(millis()/1000);
         Serial.println(" sec"); 
         delay(50);
        }         
         takeLowTime = true;
      }

     if(digitalRead(pirPin) == LOW)
     {  
       mySwitch.send(5396, 24);     
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state
       digitalWrite(rele, LOW);
       if(takeLowTime)
       {
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
       }
       //if the sensor is low for more than the given pause, 
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause)
       {  
           //makes sure this block of code is only executed again after 
           //a new motion sequence has been detected
           lockLow = true;                        
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");
           delay(50);
       }
    }
    
    
}

Thank you.

is it possible?

If you have transceivers, yes. All that you have told us, in the thread title, is the frequency that your radios operate on.

Using millis() and delay() in the same code is pointless. Use ONE method of ensuring that everything doesn't happen every time through loop().

Sorry, I'm new to Arduino and do not really know how to work with signals.

I'm using esta RF: http://www.dx.com/p/433mhz-rf-transmitter-receiver-link-kit-green-221225
I'm using Arduino Nano: http://www.dx.com/p/new-nano-v3-0-module-atmega328p-au-improved-version-for-arduino-yellow-369070

By using these two modules, you connect both the Arduino, can I send and receive simultaneously with these?

PaulS:
Using millis() and delay() in the same code is pointless. Use ONE method of ensuring that everything doesn't happen every time through loop().

How I can make sure that everything happens once unused status check every iteration of the loop in a presence sensor? Sorry, but this is all very new to me and I am still very lost.

By using these two modules, you connect both the Arduino, can I send and receive simultaneously with these?

That would be silly, wouldn't it? If the Arduino knows that it needs to do something, it would be pointless to transmit the data from one end of the Arduino to the other, over the air, and have to receive the data to figure out what to do.

You can not transmit and listen at the same time, even if you had two pairs. Those devices can NOT be used for two-way communication.

How I can make sure that everything happens once unused status check every iteration of the loop in a presence sensor? Sorry, but this is all very new to me and I am still very lost.

You can't begin to write code to do something until you can document how YOU would do it. So, how would YOU do that? Whatever that is?

With those modules (i refer to them as "cheapo rf"), you can't have more than 1 transmitter transmitting at once, or the receivers will see garbage. So if it's receiving an RF signal, t

Furthermore, even if you could (for example, if you were receiving with a 315mhz reciever, but transmitting at 433), the Arduino cannot multitask send and receive like that on cheapoRF - since there's no hardware dedicated to translating the bytes to the signal sent to the transmitter (which is a series of long and short pulses encoding 1's and 0's), the Arduino needs to dedicate it's attention to bitbanging* that out. Likewise, on receiving, your Arduino is probably fully occupied with the task (or is getting very frequent interrupts).

So yeah, you can't transmit and receive simulaneously.

You can, of course, receive, and then after you're done, and the signal you were receiving has stopped, then transmit something of your own. I've done that a bunch of times - the receivers don't seem to mind being right next to a transmitting transmitter, and then then 3 seconds later receiving a reply from a transmitter across the room

Finally, those receiver modules SUCK. Under intermittent conditions that I don't understand, but which others have seen too, they sometimes have uselessly short range (like, 10cm ). The narrow yellow ones with the SOIC-16 chip on them, like these, work with the same transmitter, and are far more reliable and get better range:
http://www.ebay.com/itm/280932610576 (I do not endorse that seller, the price is crazy - you can find them for like $1.50-2 counting shipping. I remember paying like 7-8 for 5 of them).

*"bitbanging" refers to code that individually handles outputting bits, which you rarely have to do - contrasted with something like UART or I2C, where there's a dedicated piece of hardware on the chip that you had the byte to, and it sends it in the background and raises an interrupt when it's done.

PaulS:
That would be silly, wouldn't it? If the Arduino knows that it needs to do something, it would be pointless to transmit the data from one end of the Arduino to the other, over the air, and have to receive the data to figure out what to do.

I want two-way communication so that if Arduino detects presence activates a relay and tell a Raspberry, Raspberry and from the ability to disable the relay connected to the Arduino. So I want two-way communication.

DrAzzy:
You can, of course, receive, and then after you're done, and the signal you were receiving has stopped, then transmit something of your own. I've done that a bunch of times - the receivers don't seem to mind being right next to a transmitting transmitter, and then then 3 seconds later receiving a reply from a transmitter across the room

Although not simultaneously, if I can still send and receive it at different times there would be no problem, stored in a buffer to send the message and then send / receive buffer when I can. But, how you do you that?

But, how you do you that?

With transceivers.

DrAzzy:
The narrow yellow ones with the SOIC-16 chip on them, like these, work with the same transmitter, and are far more reliable and get better range:
http://www.ebay.com/itm/280932610576

What range do you get with those?