315 mhz pir sensors with 315 mhz reciever

Hello,

I am making a wireless pir alarm system. I have a wireless pir sensor (http://dx.com/p/wireless-infrared-sensor-detector-for-security-alarm-system-168307) which is 315mhz and a wireless reciever (https://www.sparkfun.com/products/10533) which also is 315 mhz.

Now I want the arduino to detect the wireless pir sensors when they send out a signal. I have tried the example codes but i can't "see" the signal the sensors give. Is this even possible?

If not, does someone have a good and cheap alternative to accomplish this?

Thanks in advance!

There are two different things going on.

(1) The PIR remote sensor supports 2262 decoding. That is a very common protocol. There is a library for it, called RCswitch. http://code.google.com/p/rc-switch/ In that library is an advanced example that will read the timing and so on. If you run that, it should be able to detect the PIR sensor.

(2) The library at the Sparkfun site is the VirtualWire. That is a very good software protocol library to communicate between two Arduinos. It uses a specific own protocol, and that protocol has nothing to do with your PIR sensor. http://www.airspayce.com/mikem/arduino/

thanks for the tip!

But I can't get it to work.. Maybe my receiver is broken or something.. Because if I test it with a 315mhz transmitter and the example codes with virtual wire I can't see what is send.

Is there a way to test my receiver another way?

Yes, with a piezo beeper on the receiver pin of the RX module.
Or blink a led when something is received.

If you use the VirtualWire code, it waits until it detects the VirtualWire protocol, which will never happen, since the PIR sensor transmits a different protocol.

pff i can’t figure out what i am doing wrong :s

I have a new 315 mhz receiver and 315mhz transmitter and still i can’t setup a connection. I am using the virtualwire library but there is no output…

Anybody any idea what i am doing wrong?

This is my code:

Send:

#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(2000);	 // Bits per sec
        vw_set_tx_pin(7); 
        

}

void loop()
{

  
  if(digitalRead(8) == LOW){
    char *msg = "1";
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    Serial.println("send");
    delay(2000);

  }
}

Receive:

 #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(2000);	 // Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       // Start the receiver PLL running

pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
  
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
  
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	    Serial.print(buf[i]);
	    Serial.print(" ");
	}
	Serial.println("");

   }
}

You might try this simple sketch. Put your data wire on pin 2. Trigger your sensor and see if you receive a “value” through the Serial Monitor. This works with my 433 mhz sensor:

/*
Simple example for receiving

Need help? http://forum.ardumote.com
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
}

void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();

if (value == 0) {
Serial.println(“Unknown encoding”);
}
Serial.print(value);

mySwitch.resetAvailable();
}

}

I think your code should work.

If you really want to know what is going on, you could use SDR (Software Defined Radio).

You need an usb stick of about 10 or 20 dollars/euros and free software. With that you can tune to 315MHz and see what is happening.

Perhaps you can attach photos, so we can see how it is connected.

Here are some pictures how I hooked it up.

I think it should be right.

Thanks in advance!

There is one thing I noticed. Is the receiver "RSSI" signal connected to the Arduino ? That is ment for signal strength. Use the "DATA OUT". Sometimes those two pins are the same, that depends on the receiver module.

If that didn't solve it, I have no idea what it could be. If you have a piezo element, you can connect it to the receiver and try to hear it when the transmitter is sending pulses or a tone.

Hello janverhoeckx,

Dit it work? I am trying to do the same, I am waiting for some parts, after that I will start with this project. Please let me know if you figured out how to hook up your PIR with arduino

Cheers!

Hello!,

no still not working... can't see what i am doing wrong. Replaced the receiver and everything but still nothing. I haven't looked at it for a while, I will make some time for it soon!

Can you let me know when you can get it to work? This is the last essential piece of my home security system. Maybe someone knows a cheap alternitive?

Thanks in advance!