Python module for the SparkFun Qwiic PIR - 1 uA (EKMB1107112) and SparkFun Qwiic PIR - 170 uA (EKMC4607112K).
This python package is a port of the existing SparkFun Qwiic PIR Arduino Library
This package can be used in conjunction with the overall SparkFun qwiic Python Package
New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.
The Qwiic Button Python package current supports the following platforms:
This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py
The SparkFun Qwiic PIR module documentation is hosted at ReadTheDocs
This repository is hosted on PyPi as the sparkfun-qwiic-pir package. On systems that support PyPi installation via pip, this library is installed using the following commands
For all users (note: the user must have sudo privileges):
sudo pip install sparkfun-qwiic-pir
For the current user:
pip install sparkfun-qwiic-pir
To install, make sure the setuptools package is installed on the system.
Direct installation at the command line:
python setup.py install
To build a package for use with pip:
python setup.py sdist
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
cd dist
pip install sparkfun-qwiic-pir-<version>.tar.gz
See the examples directory for more detailed use examples.
from __future__ import print_function
import qwiic_pir
import time
import sys
debounce_time = .20
def run_example():
print("\nSparkFun Qwiic PIR Example 1\n")
my_PIR = qwiic_pir.QwiicPIR()
if my_PIR.begin() == False:
print("The Qwiic PIR isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
print ("Waiting 30 seconds for PIR to stabilize")
for i in range(0, 30):
print(i)
time.sleep(1)
print("Device Stable")
while True:
if my_PIR.raw_reading() is True:
print("Object Detected")
else:
print("Object Removed")
time.sleep(debounce_time)
if __name__ == '__main__':
try:
run_example()
except (KeyboardInterrupt, SystemExit) as exErr:
print("\nEnding Example 1")
sys.exit(0)