Commit 5dd1283c authored by Piotr "PHT" Jasiek's avatar Piotr "PHT" Jasiek

Adding inside dht11

parent d6047e7f
......@@ -8,6 +8,7 @@ import datetime
from modules.temp import *
from modules.database import *
from modules.bmp280 import *
from modules.dht11 import *
####Adding kernel modules
os.system('modprobe i2c-dev')
os.system('modprobe w1-gpio')
......@@ -17,7 +18,7 @@ os.system('modprobe w1-therm')
####Constant
outside_sensor = BME280(t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8, address=0x76)
greenhouse_sensor = BME280(t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8, address=0x77)
inside_sensor = 17
#outside_sensor = '/sys/bus/w1/devices/28-0000074e18a7/w1_slave'
#inside_sensor = '/sys/bus/w1/devices/28-0000074e7326/w1_slave'
#desktop_temp_sensor = '/sys/bus/w1/devices/10-00080229a477/w1_slave'
......@@ -32,10 +33,14 @@ request_time = datetime.datetime.now().strftime("%s")
outside_temp = round(outside_sensor.read_temperature(), 2)
outside_humidity = round(outside_sensor.read_humidity(), 0)
outside_pressure = round(outside_sensor.read_pressure()/100, 1)
greenhouse_temp = round(greenhouse_sensor.read_temperature(), 2)
greenhouse_humidity = round(greenhouse_sensor.read_humidity(), 0)
greenhouse_pressure = round(greenhouse_sensor.read_pressure()/100, 1)
inside_temp = get_from_dht11(inside_sensor, "temp")
inside_hum = get_from_dht11(inside_sensor, "hum")
temp_station_controller = get_temp_rpi()
......@@ -46,11 +51,15 @@ try:
add_record(request_time, 'outside_temp', outside_temp)
add_record(request_time, 'outside_hum' , outside_humidity)
add_record(request_time, 'outside_pressure' , outside_pressure)
# add_record(request_time, 'inside_temp', temp_inside)
add_record(request_time, 'inside_temp', inside_temp)
add_record(request_time, 'inside_hum', inside_hum)
# add_record(request_time, 'desktop_temp', temp_desktop)
add_record(request_time, 'greenhouse_temp', greenhouse_temp)
add_record(request_time, 'greenhouse_hum', greenhouse_humidity)
add_record(request_time, 'greenhouse_pressure' , greenhouse_pressure)
add_record(request_time, 'device_proc_temp', temp_station_controller)
except:
......
......@@ -128,7 +128,7 @@ class BME280(object):
i2c = I2C
# Create device, catch permission errors
try:
self._device = i2c.get_i2c_device(address, busnum=10, **kwargs)
self._device = i2c.get_i2c_device(address, busnum=1, **kwargs)
except IOError:
print("Unable to communicate with sensor, check permissions.")
exit()
......
import Adafruit_DHT
def get_from_dht11(pin, type):
sensor = Adafruit_DHT.DHT11
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if type == "hum":
return humidity
elif type == "temp":
return temperature
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment