Sparkfun PIR motion sensor - Project Showcase - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Sparkfun PIR motion sensor


  • Please log in to reply
28 replies to this topic

#1 VincentA

VincentA

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationIndia

Posted 03 January 2011 - 02:55 PM

I just got PIR motion sensor from sparkfun and decided to give it a try right away. so heres result


Connection diagram by Jorge-EE :

Posted Image

RingTonePlayer by Hari + OZ-Solutions

And heres complete code Attached File  Motion_Sensor.zip   69.98KB   209 downloads

Enjoy!
Vincent

#2 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 11 September 2012 - 11:06 PM

I just got PIR motion sensor from sparkfun and decided to give it a try right away. so heres result


Connection diagram by Jorge-EE :

Posted Image

RingTonePlayer by Hari + OZ-Solutions

And heres complete code Attached File  Motion_Sensor.zip   69.98KB   209 downloads

Enjoy!
Vincent


Good day,

I see VincentA is using a resistor, same as the arduino example below:

http://bildr.org/2011/06/pir_arduino/

But I can't get it to work with my N+, can someone please tell me how to wire it correcly? Can I use any of the 14 digital inputs?

Thanks in advance

#3 Christopher Clark

Christopher Clark

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationNorth Carolina, USA

Posted 12 September 2012 - 01:26 AM

how are you wiring it? what does your program look like?

#4 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 12 September 2012 - 02:05 AM

If you take the time to look at the Code in the ZIP file that VincentA so nicely attached you will see he is using GPIO_PIN_A0.

#5 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 12 September 2012 - 05:28 AM

If you take the time to look at the Code in the ZIP file that VincentA so nicely attached you will see he is using GPIO_PIN_A0.



My wiring is the same as VincentA is suggesting and I am using the code provided in the zip file but I just realized I am using a 10 ohms resistor instead of a 10,000 (10K) ohms resistor, so that pretty much is the problem but still I got a question, VincentA is using an analog port wether the Arduino example provided above uses digital por # 2, why is that? And one last question. Can I use any of the 3 GND pins for the brown wire (1 from the digital side and 2 from the Analog side) ?

#6 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 12 September 2012 - 08:42 AM

It doesn't matter what pin you use for the input as long as the code is appropriate for polling it. The simplest would be to use a Digital I/O because with the Pullup resistor a digital pin will always show a 1 (on) until triggered when it goes low 0 (off). As far as the ground, ground is ground. Anyone will work fine.

I use a different sensor, but have an event driven class I use. Should work the same.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace MyApp.HardwareUtility
{
	public delegate void PIRTriggeredEventHandler(bool triggered, DateTime time);

	public class PIRSensor
	{
    	private InterruptPort _sensor;

    	public event PIRTriggeredEventHandler SensorTriggered;

    	/// <summary>
    	/// Initializes a new instance of the <see cref="PIRSensor"/> class.
    	/// </summary>
    	/// <param name="portId">The port id.</param>
    	public PIRSensor(Cpu.Pin portId)
    	{
        	_sensor =
            	new InterruptPort(
                	portId,
                	false,
                	Port.ResistorMode.Disabled,
                	Port.InterruptMode.InterruptEdgeBoth);

        	_sensor.OnInterrupt +=
            	new NativeEventHandler(
                	(data1, data2, time) =>
                	{
                    	OnSensorTriggered(data1, data2, time);
                	}
        	);

    	}

    	/// <summary>
    	/// Called when [PIR triggered].
    	/// </summary>
    	/// <param name="data1">The data1.</param>
    	/// <param name="data2">The data2.</param>
    	/// <param name="time">The time.</param>
    	protected void OnSensorTriggered(uint data1, uint data2, DateTime time)
    	{
        	var evt = SensorTriggered;
        	if (evt != null)
            	evt.Invoke(data2 == 1, time);
    	}
	}
}

Then I use this code in my program:

    	PIRSensor pir = new PIRSensor(Pins.GPIO_PIN_D4);
    	Thread.Sleep(2000); //Warmup Time
    	pir.SensorTriggered += new PIRTriggeredEventHandler(pir_TriggeredEvent);

    	static void pir_TriggeredEvent(bool triggered, DateTime time)
    	{

        	Debug.Print("PIR: Triggered");
        	
    	}


#7 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 12 September 2012 - 02:49 PM

Hi Dave,

Thanks for your response. I am going to try out your code but one question though, are you using the 10K Ohms resistor as suggested in the example? I was using a 10 Ohms instead of a 10K Ohms, I am going to get a 10K today to try it out but the question is, do you think I burned my sensor using the wrong resistor?

This is the hardware I got:

https://www.sparkfun.com/products/8630

#8 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 12 September 2012 - 04:47 PM

Hi Dave,

Thanks for your response. I am going to try out your code but one question though, are you using the 10K Ohms resistor as suggested in the example? I was using a 10 Ohms instead of a 10K Ohms, I am going to get a 10K today to try it out but the question is, do you think I burned my sensor using the wrong resistor?

This is the hardware I got:

https://www.sparkfun.com/products/8630



I am not as it is built in to the sensor I am using. It depends on the sensor you are using. The sparkfun one does need the pullup resistor or the levels won't change.

#9 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 12 September 2012 - 07:27 PM

I am not as it is built in to the sensor I am using. It depends on the sensor you are using. The sparkfun one does need the pullup resistor or the levels won't change.



Got it, I'll keep you posted of my findings.

#10 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 13 September 2012 - 06:23 PM

Got it, I'll keep you posted of my findings.


Hi Dave,

I tried the Sparkfun PIR Motion Sensor - SEN-08630 with a 10K Ohms resistor but I am not getting any readings. Do you think I have fried the sensor somehow when mistakenly I was using the 10 Ohms resistor instead? By the way, the resistor goes from 5V+ (Pin 1) to Alarm (Pin 3).

https://www.sparkfun.com/products/8630
http://www.sparkfun....imity/SE-10.pdf
http://bildr.org/2011/06/pir_arduino/

#11 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 13 September 2012 - 07:01 PM

Hi Dave,

I tried the Sparkfun PIR Motion Sensor - SEN-08630 with a 10K Ohms resistor but I am not getting any readings. Do you think I have fried the sensor somehow when mistakenly I was using the 10 Ohms resistor instead? By the way, the resistor goes from 5V+ (Pin 1) to Alarm (Pin 3).

https://www.sparkfun.com/products/8630
http://www.sparkfun....imity/SE-10.pdf
http://bildr.org/2011/06/pir_arduino/


Do you have a multi-meter to measure the voltage? You should be able to simply test from GND to the ALARM wire. You should see it switching between 5 and 0 volts when triggered.

#12 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 13 September 2012 - 11:48 PM

Do you have a multi-meter to measure the voltage? You should be able to simply test from GND to the ALARM wire. You should see it switching between 5 and 0 volts when triggered.


Thanks for the suggestion Dave, I will try that tonight. So I guess if I don't see any fluctuation, then the sensor is either bad or fried, right? :D

#13 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 14 September 2012 - 04:59 AM

Hi Dave, Here are my findings: From GND to ALARMS there are 2.8v constantly From GND to 5V+, there are 2.1v constantly Coincidentaly 2.8v+2.1v = 5volts So, I guess the sensor is broken, right? Also I was curious and measure from 3.3V pin to GND and I got what I was expecting which is 3.3v but when measuring from the 5V pin to GND I got .0L which I guess is infinite, why is that? Is there something wrong my my N+ board?

#14 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 14 September 2012 - 07:15 AM

Try to disconnect the sensor from the 5v and measure the 5v --> GND Again on the Netduino+ just to be sure the board is ok.

#15 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 14 September 2012 - 07:40 PM

Try to disconnect the sensor from the 5v and measure the 5v --> GND Again on the Netduino+ just to be sure the board is ok.


That's what I did. I unplugged the sensor and I read no power at all, well .0L which I think means open or infinite.

I think it is giving some power because I can read From GND to ALARMS there are 2.8v constantly. From GND to 5V+, there are 2.1v constantly. Coincidentaly 2.8v+2.1v = 5volts. There is gotta be something in the board that triggers the power to go on or off, very strange huh?

#16 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 14 September 2012 - 11:51 PM

That's what I did. I unplugged the sensor and I read no power at all, well .0L which I think means open or infinite.


Giuliano,

Most multi meters that I have use 0L would mean overload or over ranged, does your meter have auto scaling? If not check that the meter is not in a milli volt range.

Most meters would indicate a voltage (in milli volt range) when not connected just from RF radiation.

Check your meter against a none source such as a AA battery, make sure you use a DC scale not AC. It should read about 1.5 vdc.

As far as the netduino you can hook a wire from the 3.3 volt header to the input pin that would be connected to the alarm. Then move the wire from the 3.3 volt header to ground. If program senses the change the netduino should be good.

Good luck,
Chuck

#17 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 15 September 2012 - 01:31 AM

Giuliano,

Most multi meters that I have use 0L would mean overload or over ranged, does your meter have auto scaling? If not check that the meter is not in a milli volt range.

Most meters would indicate a voltage (in milli volt range) when not connected just from RF radiation.

Check your meter against a none source such as a AA battery, make sure you use a DC scale not AC. It should read about 1.5 vdc.

As far as the netduino you can hook a wire from the 3.3 volt header to the input pin that would be connected to the alarm. Then move the wire from the 3.3 volt header to ground. If program senses the change the netduino should be good.

Good luck,
Chuck


Hi Chuck,

You're a genius.

I got a Craftsman professional multimeter but I does't automatically auto scale. I change the scale manually and now it reads 4.8V in the 5V pin and 3.3 in the 3.3 pin. That said, seems like my sensor is not good anymore. Placing another order in sparkfun.com

Thanks.

#18 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 18 September 2012 - 03:18 AM

Hi VinventA,

Question, does this PIR sensor works even in low light conditions?

https://www.sparkfun.com/products/8630

#19 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 18 September 2012 - 07:51 AM

PIR stands for Passive Infrared (sensor). All people, animals, or other objects above the temperature of absolute zero emit heat as energy seen as infrared light. The reason it's called a "Passive" Infrared sensor is because it does not emit any energy (infrared light) to be used in the detection. It relies solely on the Infrared emitted by the people, animals, or other objects.

#20 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 27 September 2012 - 02:15 AM

Ok, so I got another PIR Motion Sensor (SEN-08630) from Sparkfun and same results. I cannot get it to work. I'll post pictures of my wiring later today.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.