Skip to content
This repository has been archived by the owner on Dec 28, 2018. It is now read-only.

Commit

Permalink
update test: test_load_sensors.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lexruee committed Jun 12, 2015
1 parent b403209 commit 39fea72
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test/test_load_sensors.py
Expand Up @@ -7,9 +7,19 @@
from tentacle_pi.MPL115A2 import MPL115A2
from tentacle_pi.LM75 import LM75

"""
Simple test to check if all supported sensors are working.
- Runs on a Odroid C1 (Ubuntu) and Raspberry Pi 1 / 2 (Raspbian).
- For the Banana Pi (Raspbian) change the variable I2C_DEVICE to '/dev/i2c-2'
"""

I2C_DEVICE = '/dev/i2c-1'


print "test AM2315"
am = AM2315(0x5c,"/dev/i2c-1")
am = AM2315(0x5c, I2C_DEVICE)
temperature, humidity, crc_check = am.sense()
print "temperature: %0.1f" % temperature
print "humidity: %0.1f" % humidity
Expand All @@ -19,7 +29,7 @@


print "test BMP180"
bmp = BMP180(0x77,"/dev/i2c-1")
bmp = BMP180(0x77, I2C_DEVICE)
print "temperature: %0.1f" % bmp.temperature()
print "pressure: %s" % bmp.pressure()
print "altitude: %0.1f" % bmp.altitude()
Expand All @@ -28,7 +38,7 @@


print "test TSL2561"
tsl = TSL2561(0x39,"/dev/i2c-1")
tsl = TSL2561(0x39, I2C_DEVICE)
tsl.enable_autogain()
tsl.set_time(0x00)
print "lux %s" % tsl.lux()
Expand All @@ -37,15 +47,15 @@


print "test MCP9808"
mcp = MCP9808(0x18,"/dev/i2c-1")
mcp = MCP9808(0x18, I2C_DEVICE)
temperature = mcp.temperature()
print "temperature: %0.2f" % temperature
print
time.sleep(2)


print "test MPL115A2"
mpl = MPL115A2(0x60,"/dev/i2c-1")
mpl = MPL115A2(0x60, I2C_DEVICE)
temperature, pressure = mpl.temperature(), mpl.pressure()
print "temperature: %0.1f" % temperature
print "pressure: %0.1f" % pressure
Expand All @@ -54,7 +64,7 @@


print "test LM75"
lm = LM75(0x48,"/dev/i2c-1")
lm = LM75(0x48, I2C_DEVICE)
temperature = lm.temperature()
print "temperature: %0.2f" % temperature
time.sleep(2)

0 comments on commit 39fea72

Please sign in to comment.