From 0cf10e5bb8354458b6eac7d04d4aa6235bedcf73 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 7 Jun 2019 12:04:09 +0100 Subject: [PATCH] Added examples --- examples/gas.py | 19 +++++++++++++++++++ examples/light.py | 22 ++++++++++++++++++++++ examples/particles.py | 23 +++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100755 examples/gas.py create mode 100755 examples/light.py create mode 100755 examples/particles.py diff --git a/examples/gas.py b/examples/gas.py new file mode 100755 index 0000000..6da2a65 --- /dev/null +++ b/examples/gas.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import time +from envirophatplus import gas + + +print("""gas.py - Print readings from the MICS6812 Gas sensor. + +Press Ctrl+C to exit! + +""") + +try: + while True: + readings = gas.read_all() + print(readings) + time.sleep(1.0) +except KeyboardInterrupt: + pass diff --git a/examples/light.py b/examples/light.py new file mode 100755 index 0000000..aa895f1 --- /dev/null +++ b/examples/light.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import time +import ltr559 + + +print("""light.py - Print readings from the LTR559 Light & Proximity sensor. + +Press Ctrl+C to exit! + +""") + +try: + while True: + lux = ltr559.get_lux() + prox = ltr559.get_proximity() + print("""Light: {:05.02f} Lux +Proximity: {:05.02f} +""".format(lux, prox)) + time.sleep(1.0) +except KeyboardInterrupt: + pass diff --git a/examples/particles.py b/examples/particles.py new file mode 100755 index 0000000..f34e0d4 --- /dev/null +++ b/examples/particles.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import time +from pms5003 import PMS5003 + + +print("""particles.py - Print readings from the PM5003 Particle sensor. + +Press Ctrl+C to exit! + +""") + +pms5003 = PMS5003() +time.sleep(1.0) + + +try: + while True: + readings = pms5003.read() + print(readings) + time.sleep(1.0) +except KeyboardInterrupt: + pass -- 2.30.2