Javadoc link

 

A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors.

Arduino schéma ( you can also use an other compatible controler )

 

Result :

 

Example code (from branch develop):
#file : Pir.py (github)
#########################################
# Pir.py
# description: PIR - Passive Infrared Sensor
# categories: sensor
# more info @: http://myrobotlab.org/service/Pir
#########################################
 
# start the service
pir = runtime.start('pir','Pir')
 
# start optional virtual arduino service, used for test
if ('virtual' in globals() and virtual):
    virtualArduino = runtime.start("virtualArduino", "VirtualArduino")
    virtualArduino.connect("COM4")
 
# start the controler
arduino = runtime.start("arduino","Arduino")
 
# connect it
arduino.connect("COM4")
arduino.setBoardMega() # used for pin reference
pir.attach(arduino,2 ) # arduino is controler like i2c arduino ... / 2 is pin number
 
# pir start
pir.isVerbose=True
pir.enable(1) # 1 is how many time / second we poll the pir
 
# event listener
pir.addListener("publishSense",python.name,"publishSense")
 
def publishSense(event):
  if event:print "Human detected !!!"
Example configuration (from branch develop):
#file : Pir.py (github)
!!org.myrobotlab.service.config.PirConfig
controller: null
enable: false
peers: null
pin: null
rate: null
type: Pir