https://github.com/pimoroni/pmw3901-python
Python library for the PWM3901 optical flow-rate sensor
https://github.com/pimoroni/pmw3901-python
pypi-package
Last synced: 6 months ago
JSON representation
Python library for the PWM3901 optical flow-rate sensor
- Host: GitHub
- URL: https://github.com/pimoroni/pmw3901-python
- Owner: pimoroni
- License: mit
- Created: 2019-04-16T15:25:00.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-10T09:54:39.000Z (over 1 year ago)
- Last Synced: 2025-05-01T00:45:55.493Z (6 months ago)
- Topics: pypi-package
- Language: Python
- Homepage: https://shop.pimoroni.com/products/pmw3901-optical-flow-sensor-breakout
- Size: 57.6 KB
- Stars: 35
- Watchers: 8
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PMW3901 / PAA5100JE 2-Dimensional Optical Flow Sensor
[](https://github.com/pimoroni/pmw3901-python/actions/workflows/test.yml)
[](https://coveralls.io/github/pimoroni/pmw3901-python?branch=main)
[](https://pypi.python.org/pypi/pmw3901)
[](https://pypi.python.org/pypi/pmw3901)
# Installing
### From PyPi:
* Just run `python3 -m pip install pmw3901`
### From GitHub:
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
```
# Usage
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.
# Alternate SPI Chip-Select
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:
```python
from pmw3901 import PAA5100
sensor = PAA5100(spi_cs_gpio=)
```