aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgeremy@pubnub.com2014-12-28 22:35:18 -0800
committergeremy@pubnub.com2014-12-28 22:35:18 -0800
commit9b525ef52e6d73bb6ed203e3889123502a61ebfd (patch)
tree8e36c4ab6aad775ee32f63c6dada4037f0b8168c
parent0b7db06db124ccffb6d87e97599938b377ee1368 (diff)
downloadpubnub-python-9b525ef52e6d73bb6ed203e3889123502a61ebfd.tar.bz2
adding some supporting files, temp getter file
-rw-r--r--python/examples/Adafruit_Python_DHT/Adafruit_DHT_Driver.zipbin0 -> 15781 bytes
-rw-r--r--python/examples/Adafruit_Python_DHT/bcm2835-1.38.tar.gzbin0 -> 248520 bytes
-rwxr-xr-xpython/examples/getTemp_11_4.py50
3 files changed, 50 insertions, 0 deletions
diff --git a/python/examples/Adafruit_Python_DHT/Adafruit_DHT_Driver.zip b/python/examples/Adafruit_Python_DHT/Adafruit_DHT_Driver.zip
new file mode 100644
index 0000000..b681060
--- /dev/null
+++ b/python/examples/Adafruit_Python_DHT/Adafruit_DHT_Driver.zip
Binary files differ
diff --git a/python/examples/Adafruit_Python_DHT/bcm2835-1.38.tar.gz b/python/examples/Adafruit_Python_DHT/bcm2835-1.38.tar.gz
new file mode 100644
index 0000000..1307bcf
--- /dev/null
+++ b/python/examples/Adafruit_Python_DHT/bcm2835-1.38.tar.gz
Binary files differ
diff --git a/python/examples/getTemp_11_4.py b/python/examples/getTemp_11_4.py
new file mode 100755
index 0000000..daa9770
--- /dev/null
+++ b/python/examples/getTemp_11_4.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+# Copyright (c) 2014 Adafruit Industries
+# Author: Tony DiCola
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+import sys
+
+import Adafruit_DHT
+
+
+# Parse command line parameters.
+sensor_args = { '11': Adafruit_DHT.DHT11,
+ '22': Adafruit_DHT.DHT22,
+ '2302': Adafruit_DHT.AM2302 }
+if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
+ sensor = sensor_args[sys.argv[1]]
+ pin = sys.argv[2]
+else:
+ print 'usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#'
+ print 'example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO #4'
+ sys.exit(1)
+
+# Try to grab a sensor reading. Use the read_retry method which will retry up
+# to 15 times to get a sensor reading (waiting 2 seconds between each retry).
+humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
+
+# Note that sometimes you won't get a reading and
+# the results will be null (because Linux can't
+# guarantee the timing of calls to read the sensor).
+# If this happens try again!
+if humidity is not None and temperature is not None:
+ print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)
+else:
+ print 'Failed to get reading. Try again!'