Esempio n. 1
0
import time
from tentacle_pi.AM2315 import AM2315

am = AM2315(0x5c, "/dev/i2c-3")

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.0)
Esempio n. 2
0
#!/usr/bin/env python
import os
os.chdir("/usr/lib/cgi-bin")

import time
import sys
import urllib2
import Adafruit_DHT
import Adafruit_BMP.BMP085 as BMP085
sys.path.append('./Adafruit_ADS1x15')
import SDL_Pi_Weather_80422 as SDL_Pi_Weather_80422
from tentacle_pi.AM2315 import AM2315
am = AM2315(0x5c, "/dev/i2c-1")
import SI1145.SI1145 as SI1145

# PRINT TO FILE
#sys.stdout = open('temperature.php', 'w')

# BMP180
sensorbmp = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
# AM2315
temperature, humidity, crc_check = am.sense()
Fahrenheit = 9.0 / 5.0 * temperature + 32
# SI1145 # not working?
# sensorsi = SI1145.SI1145()

# CONVERSIONS ETC
inttemperature = sensorbmp.read_temperature()  #internal temperature
pressure = sensorbmp.read_pressure()  #station pressure
mb = sensorbmp.read_sealevel_pressure() * 0.01  #sea level pressure mb
inhg = sensorbmp.read_sealevel_pressure(
import os
import sys
import time

from tentacle_pi.AM2315 import AM2315

if not os.geteuid() == 0:
    print("Error: Script must be executed as root.\n")
    sys.exit(1)

if GPIO.RPI_REVISION in [2, 3]:
    I2C_device = "/dev/i2c-1"
else:
    I2C_device = "/dev/i2c-0"

am = AM2315(0x5c, I2C_device)

now = time.time()
fault = None
faultreset = True
count = 0

date_format = '%Y-%m-%d %H:%M:%S'

while 1:
    temperature, humidity, crc_check = am.sense()
    print("Temperature: {}, Humidity: {}, CRC: {}".format(
        temperature, humidity, crc_check))

    if count:
        date_now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now))
Esempio n. 4
0
def on_connect(client, userdata, flags, rc):
    print("Connected with result code " + str(rc))
    am = AM2315(0x5c, "/dev/i2c-1")
    temperature, humidity, crc_check = am.sense()
    message = str(temperature) + ' ' + str(humidity)
    client.publish("home/pi/sensor/am2315", message)
Esempio n. 5
0
def on_message(client, userdata, msg):
    am = AM2315(0x5c, "/dev/i2c-1")
    temperature, humidity, crc_check = am.sense()
    message = str(temperature) + ' ' + str(humidity)
    client.publish("home/sensor/am2315", message)
Esempio n. 6
0
from tentacle_pi.TSL2561 import TSL2561
from tentacle_pi.MCP9808 import MCP9808
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, I2C_DEVICE)
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)

print "test BMP180"
bmp = BMP180(0x77, I2C_DEVICE)
print "temperature: %0.1f" % bmp.temperature()
print "pressure: %s" % bmp.pressure()
print "altitude: %0.1f" % bmp.altitude()
print
time.sleep(2)
Esempio n. 7
0
VWC = {}
GAIN = 1
maxT_Cpu = 80
minT_Cpu = 0
okT_Cpu = 45
tank_empty = 0
tank_full = 125

#Rockwool temperature setup (SENSOR DS18B20)
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folders = glob.glob(base_dir + '28*')

# AIR TEMPERATURE AND HUMIDITY 2X AM2315
am_in = AM2315(0x5c, "/dev/i2c-1")  # default I2C bus
am_out = AM2315(
    0x5c,
    "/dev/i2c-3")  # new I2C bus created on pins GPIO23 (SDA) and GPIO24 (SCL)

# END OF GLOBAL VARIABLES
""" LIST THAT WILL STORE TEMPERATURES - DS18B20 """
temperatures = []
""" *** SAYS GOOD BYE WHEN PROGRAM STOPS *** """


def exit_handler():
    print 'LivingSense stopped TRANSMITTING DATA. See you soon!'
    GPIO.cleanup()
    return