GY-63_MS5611/libraries/PIR
rob tillaart c907460ea5 0.1.2 PIR
2023-02-03 18:56:26 +01:00
..
.github 0.1.2 PIR 2023-02-03 18:56:26 +01:00
examples 0.1.2 PIR 2022-12-16 17:17:36 +01:00
test 0.1.2 PIR 2022-12-16 17:17:36 +01:00
.arduino-ci.yml 0.1.0 PIR 2022-12-14 19:17:10 +01:00
CHANGELOG.md 0.1.2 PIR 2022-12-16 17:17:36 +01:00
keywords.txt 0.1.2 PIR 2022-12-16 17:17:36 +01:00
library.json 0.1.2 PIR 2022-12-16 17:17:36 +01:00
library.properties 0.1.2 PIR 2022-12-16 17:17:36 +01:00
LICENSE 0.1.2 PIR 2023-02-03 18:56:26 +01:00
PIR.cpp 0.1.2 PIR 2022-12-16 17:17:36 +01:00
PIR.h 0.1.2 PIR 2022-12-16 17:17:36 +01:00
README.md 0.1.2 PIR 2023-02-03 18:56:26 +01:00

Arduino CI Arduino-lint JSON check License: MIT GitHub release

PIR

PIR library for Arduino. Supports up to 8 PIR sensors.

Description

The PIR library implements a class to monitor 1 or more PIR sensors. The library supports up to 8 PIR sensors per object, which typically are added in setup(). It is possible to add a sensor (pin) multiple times. The library accepts duplicates.

The library has two read() functions, one to read a specific sensor, and one to read all of them. The latter will return a mask indicating HIGH and LOW. The first added PIR will have the LSB.

Instead of PIR sensors one can add other DigitalOut sensors or even switches.

Interface

Base

  • PIR() constructor. Allocated room for 8 PIRs.
  • uint8_t add(uint8_t pin) adds a PIR pin to the set of pins. Returns the index or PIR_ARRAY_FULL (0xFE)
  • uint8_t count returns number of PIR sensors added.

Read

  • uint8_t read() read all PIR sensors in the set. Returns a bit mask of HIGH / LOW values. Not used slots will return 0.
  • uint8_t read(uint8_t index) read a specific PIR sensor. Faster than read() above.
  • uint8_t lastValue() returns last values read (bit mask) with read().
  • uint8_t changed() returns bit mask of pins that changed since last read(). This can improve processing in some cases.

Future

Must

  • update documentation

Should

  • add examples
    • interrupts?

Could

  • investigate PIR16 PIR32 class that can hold more
    • think MEGA2560.
    • or dynamic allocation? 0.2.0
  • one lastRead for all?
  • uint8_t pin(uint8_t index) to get back configuration
  • bool add(uint8_t array, length) faster configuration. Return true if there was enough room.
  • clear() to reset whole object?

Wont

  • PIR class based upon a PCF8574?
    • separate class
  • timestamp per PIR
    • lastRead, lastTriggered?
    • taking "a lot of RAM" for every pin
  • add statistics?
    • nr of calls - high% - low%
    • duration
  • investigate noise (what noise)
  • remove(pin)
    • difficult, more admin, expectations...