WARNING for Tentacle Pi 1.0.0 release:
- Tentacle Pi will be released under the GPLv2
- Drivers are rewritten in pure python (new API)
Tentacle Pi is a growing collection of drivers for popular I2C devices.
I2C device | Address | Sensor type | Spec sheet |
---|---|---|---|
am2315 | 0x5c | Temperature/Humidity | Link |
am2321 | 0x5c | Temperature/Humidity | Link |
bmp180 | 0x77 | Barometric Pressure/Temperature/Altitude | Link |
tsl2561 | 0x29,0x39,0x49 | Luminosity/Lux/Light | Link |
mcp9808 | 0x18 | Temperature | Link |
mpl115a2 | 0x60 | Barometric Pressure/Temperature | Link |
lm75 | 0x48 | Temperature | Link |
Remarks:
- tsl2561: default address is 0x39
- am2315/am2321: you can use the am2315 driver for am2321 sensor
Any arm powered single-board computer that runs a debian operating system is more or less supported.
Tested platforms so far are:
- Raspberry Pi / Raspbian
- Raspberry Pi 2 / Raspbian
- Banana Pi / Raspbian
- Odroid C1 / Ubuntu
Install the following packages:
sudo apt-get install i2c-tools libi2c-dev python-dev build-essential
On the Adafruit learning platform you will find a great tutorial how to configure I2C. Besides that their products (AM2315, BMP180, TSL2561) are great 😸 .
Here is a great blog post that explains how I2C can be configured on the Odroid C1.
sudo pip install tentacle_pi
If you want to update:
sudo pip install tentacle_pi --upgrade
Clone this repository:
git clone --recursive https://github.com/lexruee/tentacle_pi
Install the python module:
sudo python setup.py install
If you have already a copy of this repository you can run this command to update your local copy:
git pull origin master
git submodule update --init --recursive
Raspberry Pi: add pi to the group i2c if you want to run your program without sudo.
sudo usermod -a -G i2c pi
Remark: You can also use the AM2315 driver for AM2321 sensor.
import time
from tentacle_pi.AM2315 import AM2315
am = AM2315(0x5c,"/dev/i2c-1")
for x in range(0,10):
temperature, humidity, crc_check = am.sense()
print "temperature: %0.1f" % temperature
print "humidity: %0.1f" % humidity
print "crc: %s" % crc_check
print
time.sleep(2)
from tentacle_pi.BMP180 import BMP180
import time
bmp = BMP180(0x77,"/dev/i2c-1")
for x in range(0,10):
print "temperature: %0.1f" % bmp.temperature()
print "pressure: %s" % bmp.pressure()
print "altitude: %0.1f" % bmp.altitude()
print
time.sleep(2)
from tentacle_pi.TSL2561 import TSL2561
import time
tsl = TSL2561(0x39,"/dev/i2c-1")
tsl.enable_autogain()
tsl.set_time(0x00)
for x in range(0,10):
print "lux %s" % tsl.lux()
print
time.sleep(3)
import time
from tentacle_pi.MCP9808 import MCP9808
mcp = MCP9808(0x18,"/dev/i2c-1")
for x in range(0,10):
temperature = mcp.temperature()
print "temperature: %0.2f" % temperature
time.sleep(2)
import time
from tentacle_pi.MPL115A2 import MPL115A2
mpl = MPL115A2(0x60,"/dev/i2c-1")
for x in range(0,10):
temperature, pressure = mpl.temperature(), mpl.pressure()
print "temperature: %0.1f" % temperature
print "pressure: %0.1f" % pressure
print
time.sleep(2)
import time
from tentacle_pi.LM75 import LM75
lm = LM75(0x48,"/dev/i2c-1")
for x in range(0,10):
temperature = lm.temperature()
print "temperature: %0.2f" % temperature
time.sleep(2)
from tentacle_pi.TSL2561 import TSL2561
from tentacle_pi.BMP180 import BMP180
from tentacle_pi.AM2315 import AM2315
import time
from datetime import datetime
# initialize some sensors :-)
bmp = BMP180(0x77, "/dev/i2c-1")
tsl = TSL2561(0x39, "/dev/i2c-1")
am = AM2315(0x5c, "/dev/i2c-1")
tsl.enable_autogain()
print("---------------------------------------------")
print("time: %s" % datetime.now())
print("")
print("bmp180:")
print("\ttemperature: %0.1f" % bmp.temperature())
print("\tpressure: %0.1f" % bmp.pressure())
print("\taltitude: %0.1f" % bmp.altitude())
print("tsl2561:")
print("\tlux: %s" % tsl.lux())
print("am2315:")
am_tmp, am_hum, _ = am.sense()
print("\ttemperature: %0.1f" % am_tmp)
print("\thumidity: %0.1f" % am_hum)
print("---------------------------------------------")
print("")
# use time.sleep(2) inside a loop because of the AM2315 sensor!
- i2c-tools
- build-essential
- libi2c-dev
- python-dev
- python 2.7
The MIT License (MIT)
Copyright (c) 2015 Alexander Rüedlinger <a.rueedlinger@gmail.com>
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.