Driver for the Anyleaf pH sensor
Project description
Anyleaf
For use with the AnyLeaf pH sensor in Python
Quickstart
To get started as quickly as possible, run these commands from a terminal:
pip3 install anyleaf
git clone https://github.com/anyleaf/ph-python.git
cd ph-python/examples
python3 ex.py
pH readings will display in your terminal.
To install the anyleaf
Python package, run pip3 install anyleaf
, or
pip install anyleaf
, depending on how pip
is set up on your operating system.
Example use, for Raspberry Pi, and CircuitPython boards:
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
anyleaf-0.1.6.1.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for anyleaf-0.1.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87a8ab0fd4ada660985121cca092b1254656521a9d9791fc8c219b06611e396e |
|
MD5 | 9a376a08fa8a5e8a9956d2c3b38f95ff |
|
BLAKE2b-256 | 7a031b4db2920f38d6da47fe06d0ccd21e7dda267d8d45d3af98ebde86522694 |