The friendly Operating System for the Internet of Things
PIR Motion Sensor

Device driver interface for the PIR motion sensor. More...

Detailed Description

Files

file  pir.h
 Device driver interface for the PIR motion sensor.
 

Data Structures

struct  pir_t
 device descriptor for a PIR sensor More...
 

Macros

#define PIR_MSG_T_STATUS_START   150
 value to configure sensitivity of sensore
 

Enumerations

enum  pir_event_t { PIR_STATUS_HI = PIR_MSG_T_STATUS_START, PIR_STATUS_LO }
 event type for a PIR sensor More...
 

Functions

int pir_init (pir_t *dev, gpio_t gpio)
 Initialize a PIR motion sensor. More...
 
pir_event_t pir_get_status (pir_t *dev)
 Read the current status of the motion sensor. More...
 
int pir_register_thread (pir_t *dev)
 Register a thread for notification whan state changes on the motion sensor. More...
 

Enumeration Type Documentation

Enumerator
PIR_STATUS_HI 

motion was detected

PIR_STATUS_LO 

no motion is detected

Definition at line 49 of file pir.h.

Function Documentation

pir_event_t pir_get_status ( pir_t dev)
Parameters
[in]devdevice descriptor of the PIR motion sensor to read from
Returns
1 if motion is detected, 0 otherwise
int pir_init ( pir_t dev,
gpio_t  gpio 
)

The PIR motion sensor is interfaced by a single GPIO pin, specified by gpio.

Note
The sensor needs up to a minute to settle down before meaningful measurements can be made.
Parameters
[out]devdevice descriptor of an PIR sensor
[in]gpiothe GPIO device the sensor is connected to
Returns
0 on success
-1 on error
int pir_register_thread ( pir_t dev)
Note
This configures the gpio device for interrupt driven operation.
Parameters
[in]devdevice descriptor of the PIR motion sensor to register for
Returns
0 on succuess,
-1 on internal errors,
-2 if another thread is registered already