- Just run
python3 -m pip install pmw3901
Stable library from GitHub:
git clone https://github.com/pimoroni/pmw3901-python
cd pmw3901-python
./install.sh
Latest/development library from GitHub:
git clone https://github.com/pimoroni/pmw3901-python
cd pmw3901-python
./install.sh --unstable
Note Libraries will be installed in the "pimoroni" virtual environment, you will need to activate it to run examples:
source ~/.virtualenvs/pimoroni/bin/activate
The PAA5100JE has a slightly different init routine to the PMW3901, you should use the class provided to ensure it's set up correctly:
from pmw3901 import PAA5100
And for the PMW3901, continue using the old class:
from pmw3901 import PMW3901
The example motion.py
demonstrates setting up either sensor, and accepts
a --board
argument to specify which you'd like to use.
This library supports specifying a GPIO pin for chip select, you might want
to first first disable SPI chip select support by adding the following
to /boot/firmware/config.txt
:
dtoverlay=spi0-0cs
Then use the library with:
from pmw3901 import PAA5100
sensor = PAA5100(spi_cs_gpio=<gpio_pin>)