Anyleaf pH 传感器的驱动程序
项目描述
任意叶
用于 Python 中的 AnyLeaf pH 和 RTD 传感器
快速开始
要尽快开始使用 Raspberry Pi:
- 激活 I2C(pH 和 ORP 模块):运行
sudo raspi-config。选择Interfacing Options→→→ 。I2C_Yes - 激活 SPI(RTD 临时模块):同上,但选择
SPI而不是I2C. - 重启
然后从终端运行这些命令:
sudo apt install python3-scipypip3 install anyleafgit clone https://github.com/anyleaf/anyleaf-python.gitcd anyleaf-python/examplespython3 ph_orp.py
pH 读数将显示在您的终端中。
要安装anyleafPython 包,请运行pip3 install anyleaf或
pip install anyleaf,具体取决于pip您的操作系统上的设置方式。
使用示例,用于 Raspberry Pi 和 CircuitPython 板:
import time
import board
import busio
from anyleaf import PhSensor, CalPt, CalSlot, OnBoard, OffBoard
def main():
i2c = busio.I2C(board.SCL, board.SDA)
delay = 1 # Time between measurements, in seconds
ph_sensor = PhSensor(i2c, delay)
# 2 or 3 pt calibration both give acceptable results.
# Calibrate with known values. (voltage, pH, temp in °C).
# You can find voltage and temperature with `ph_sensor.read_voltage()` and
# `ph_sensor.read_temp()` respectively.
# For 3 pt calibration, pass a third argument to `calibrate_all`.
ph_sensor.calibrate_all(
CalPt(0., 7., 25.), CalPt(0.17, 4., 25.)
)
# Or, call these with the sensor in the appropriate buffer solution.
# This will automatically use voltage and temperature.
# Voltage and Temp are returned, but calibration occurs
# without using the return values.
# V, T = ph_sensor.calibrate(CalSlot.ONE, 7., Offboard(40.))
# ph_sensor.calibrate(CalSlot.TWO, 4., OnBoard())
# Store the calibration parameters somewhere, so they persist
# between program runs.
while True:
pH = ph_sensor.read(OnBoard())
# To use an offboard temperature measurement: `ph_sensor.read(OffBoard(30.))`
print(f"pH: {pH}")
time.sleep(delay)
if __name__ == "__main__":
main()
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
anyleaf-0.1.9.tar.gz
(10.0 kB
查看哈希)
内置分布
anyleaf-0.1.9-py3-none-any.whl
(9.6 kB
查看哈希)