Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-mprls
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-mprls
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-mprls
Usage Example¶
import time
import board
import adafruit_mprls
i2c = board.I2C()
# Simplest use, connect to default over I2C
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)
while True:
print((mpr.pressure,))
time.sleep(1)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import board
import adafruit_mprls
i2c = board.I2C()
# Simplest use, connect to default over I2C
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)
# You can also specify both reset and eoc pins
"""
import digitalio
reset = digitalio.DigitalInOut(board.D5)
eoc = digitalio.DigitalInOut(board.D6)
mpr = adafruit_mprls.MPRLS(i2c, eoc_pin=eoc, reset_pin=reset,
psi_min=0, psi_max=25)
"""
while True:
print((mpr.pressure,))
time.sleep(1)
|
adafruit_mprls
¶
CircuitPython library to support Honeywell MPRLS digital pressure sensors
- Author(s): ladyada
Implementation Notes¶
Hardware:
- Adafruit Adafruit MPRLS Ported Pressure Sensor Breakout (Product ID: 3965)
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_mprls.
MPRLS
(i2c_bus, *, addr=24, reset_pin=None, eoc_pin=None, psi_min=0, psi_max=25)¶ Driver base for the MPRLS pressure sensor
Parameters: - i2c_bus (I2C) – The I2C bus the MPRLS is connected to
- addr (int) – The I2C device address. Defaults to
0x18
- reset_pin (Pin) – Optional
digitalio.pin
for hardware resetting - eoc_pin (Pin) – Optional
digitalio pin
for getting End Of Conversion signal - psi_min (float) – The minimum pressure in PSI, defaults to
0
- psi_max (float) – The maximum pressure in PSI, defaults to
25
Quickstart: Importing and using the MPRLS
Here is an example of using the
MPRLS
class. First you will need to import the libraries to use the sensorimport board import adafruit_mprls
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)
Now you have access to the
pressure
attributepressure = mpr.pressure
-
pressure
¶ The measured pressure, in hPa