Added examples
authorPhil Howard <phil@gadgetoid.com>
Fri, 7 Jun 2019 11:04:09 +0000 (12:04 +0100)
committerPhil Howard <phil@gadgetoid.com>
Fri, 7 Jun 2019 11:04:09 +0000 (12:04 +0100)
examples/gas.py [new file with mode: 0755]
examples/light.py [new file with mode: 0755]
examples/particles.py [new file with mode: 0755]

diff --git a/examples/gas.py b/examples/gas.py
new file mode 100755 (executable)
index 0000000..6da2a65
--- /dev/null
@@ -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 (executable)
index 0000000..aa895f1
--- /dev/null
@@ -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 (executable)
index 0000000..f34e0d4
--- /dev/null
@@ -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