aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgeremy@pubnub.com2014-12-29 09:56:27 -0800
committergeremy@pubnub.com2014-12-29 09:56:27 -0800
commitd75f4c9511bf40a5c07f7931ac3718288d908622 (patch)
tree94b09e2878f46b0e0238bffc71798fb04495344f
parent6b27f635e04bdb4f0b1226866cff5fa523227d0f (diff)
downloadpubnub-python-d75f4c9511bf40a5c07f7931ac3718288d908622.tar.bz2
added bpmtest
-rw-r--r--python/examples/bpmTest.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/python/examples/bpmTest.py b/python/examples/bpmTest.py
new file mode 100644
index 0000000..90a4c23
--- /dev/null
+++ b/python/examples/bpmTest.py
@@ -0,0 +1,51 @@
+#!/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.
+
+# Can enable debug output by uncommenting:
+#import logging
+#logging.basicConfig(level=logging.DEBUG)
+
+import Adafruit_BMP.BMP085 as BMP085
+
+# Default constructor will pick a default I2C bus.
+#
+# For the Raspberry Pi this means you should hook up to the only exposed I2C bus
+# from the main GPIO header and the library will figure out the bus number based
+# on the Pi's revision.
+#
+# For the Beaglebone Black the library will assume bus 1 by default, which is
+# exposed with SCL = P9_19 and SDA = P9_20.
+sensor = BMP085.BMP085()
+
+# Optionally you can override the bus number:
+#sensor = BMP085.BMP085(busnum=2)
+
+# You can also optionally change the BMP085 mode to one of BMP085_ULTRALOWPOWER,
+# BMP085_STANDARD, BMP085_HIGHRES, or BMP085_ULTRAHIGHRES. See the BMP085
+# datasheet for more details on the meanings of each mode (accuracy and power
+# consumption are primarily the differences). The default mode is STANDARD.
+#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
+
+print 'Temp = {0:0.2f} *C'.format(sensor.read_temperature())
+print 'Pressure = {0:0.2f} Pa'.format(sensor.read_pressure())
+print 'Altitude = {0:0.2f} m'.format(sensor.read_altitude())
+print 'Sealevel Pressure = {0:0.2f} Pa'.format(sensor.read_sealevel_pressure())