Skip to main content

image

Anyleaf

For use with the AnyLeaf pH and RTD sensors in Python

Homepage

Quickstart

To get started as quickly as possible on Raspberry Pi:

  • Activate I2C (pH and ORP module): Run sudo raspi-config. Select Interfacing Options → I2C → Yes.
  • Activate SPI (RTD temp module): Same as above, but select SPI instead of I2C.
  • Reboot

Then run these commands from a terminal:

  • sudo apt install python3-scipy
  • pip3 install anyleaf
  • git clone https://github.com/anyleaf/anyleaf-python.git
  • cd anyleaf-python/examples
  • python3 ph_orp.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()

Metadata

Release files for anyleaf 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyleaf 0.1.9
File Size Uploaded
anyleaf-0.1.9.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyleaf 0.1.9
File Interpreter ABI Platform
anyleaf-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 19.6 kB

Release files / anyleaf-0.1.9.tar.gz

Download URL anyleaf-0.1.9.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b63771129433ed25f7aeec571902edec2e1c27d6fc6089b6a4bb4533a7ed9677
BLAKE2b-256 checksum
How to use checksums
0b743cac21c05018fadceb83585de6e7624494d1af72135f2dcf3e2f68955d2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

Release files / anyleaf-0.1.9-py3-none-any.whl

Download URL anyleaf-0.1.9-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
549e91ba1dc3e9887f3a2bf198207978a88832ee9ab5680d38a49edc01644b80
BLAKE2b-256 checksum
How to use checksums
f6af9e0ea02a5736065fa4dad424a432d251f10e57c4861f172942a8e9d616b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page