def __init__(self, logger):
     """
     Class responsible for cummunicating with the temperature sensor network for data acquisition.
     This expects a sensLog instance called logger to exist when runnig.
     """
     
     # For some reason we aren't inheriting this globally so instead we'll override it.
     self.__logger = logger
     
     self.__logger.log("Init thermalNetwork...")
     
     # Debug?
     self.__debugOn = False
     
     # Temperature sensor support
     self.__tempSens = ds18b20()
     
     # Temperature sensor registry
     self.__sensorSet = {}
     
     # Store readings and sensor data globally.
     self.__sensorReadings = {}
     
     # Running flag. Set to false when we should die.
     self.__keepRunning = True
Exemple #2
0
    def __init__(self):
        for key in hotpiConfig['devices'].keys():
            device = hotpiConfig['devices'][key]

            if device['type'] == 'ds18b20':
                device['handler'] = ds18b20(device)

            elif device['type'] == 'ct30':
                device['handler'] = ct30(device)

            elif device['type'] == 'relay':
                device['handler'] = relay(device)

            elif device['type'] == 'semaphore':
                device['handler'] = semafile(device)
Exemple #3
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Email: [email protected]

from ds18b20 import ds18b20
import time

brew = [{
    "heater": False,
    "heatctl": 1,
    "min": 20,
    "max": 21,
    "sensor": ds18b20("28-0517022710ff")
}, {
    "heater": False,
    "heatctl": 2,
    "min": 20,
    "max": 21,
    "sensor": ds18b20("28-041702ce85ff")
}]

try:

    while 1:
        # Iterate through sensors
        for s in range(len(brew)):
            temp = brew[s]["sensor"].temperature
            print("Brew {0}: Temperature {1}".format(s + 1, temp))
Exemple #4
0
	def temperatureRead(self):
		self.t=ds18b20(self.thermId)
 		self.temperature=self.t.getTemp()
		self.roundedTemp= '%05.1f' % round(self.temperature,1)
		return self.roundedTemp
import rrdtool
from time import sleep
from segmentDisplay import segmentDisplay
from ds18b20 import ds18b20


project_dir="/home/pi/virtualenvs/BrewPi"
log=False

temp=-999
s=segmentDisplay('0x38')
t=ds18b20('28-000004e4e579')
l='Office'

s.setupDisplay()
for i in range (1,5):
    s.clearDisplay(i)
while True:
    curtemp=t.getTemp()
    temp = '%05.1f' % round(curtemp,1)
    ret = rrdtool.update(project_dir + "/rrd/temps.rrd","N:" + str(temp));
    if ret:
        print rrdtool.error()
    if log==True: # Logging switch
        l = Log(temperature=curtemp,location=l,timestamp=timezone.now())
        l.save()
    if temp_HLT[0] != "0":
        s.writeDisplay(1,temp[0],0)
    else:
        s.clearDisplay(1)
        s.writeDisplay(2,temp[1],0)
Exemple #6
0
import rrdtool
from time import sleep
from segmentDisplay import segmentDisplay
from ds18b20 import ds18b20

project_dir = "/home/pi/virtualenvs/BrewPi"
log = False

temp = -999
s = segmentDisplay('0x38')
t = ds18b20('28-000004e4e579')
l = 'Office'

s.setupDisplay()
for i in range(1, 5):
    s.clearDisplay(i)
while True:
    curtemp = t.getTemp()
    temp = '%05.1f' % round(curtemp, 1)
    ret = rrdtool.update(project_dir + "/rrd/temps.rrd", "N:" + str(temp))
    if ret:
        print rrdtool.error()
    if log == True:  # Logging switch
        l = Log(temperature=curtemp, location=l, timestamp=timezone.now())
        l.save()
    if temp_HLT[0] != "0":
        s.writeDisplay(1, temp[0], 0)
    else:
        s.clearDisplay(1)
        s.writeDisplay(2, temp[1], 0)
        s.writeDisplay(3, temp[2], 1)
Exemple #7
0
# HARD CODE PINS FOR SENSORS
RELAY_PIN_1 = 16
RELAY_PIN_2 = 18
RELAY_PIN_3 = 22
TOUCH_PIN = 13
LIGHT_PIN = 11
TEMP_HUMID_PIN = 22  #This is the GPIO pin. Other pins set using BOARD
#################

lcd = LCD.LCD_Display(rs=37, e=35, data_pins=[33, 31, 29, 23])
light = light_sensor.READ_LIGHT_SENSOR(pin=LIGHT_PIN)
temp_humid = temp_humid.READ_DHT11(pin=TEMP_HUMID_PIN)
r1 = relay_switch.relay_switch(pin=RELAY_PIN_1)
r2 = relay_switch.relay_switch(pin=RELAY_PIN_2)
r3 = relay_switch.relay_switch(pin=RELAY_PIN_3)
temperature = ds18b20.ds18b20()


def change_display():
    global display_num
    global in_temp_f
    global in_humid
    global out_temp_f
    global condition
    if display_num == 1:
        display_num = 0
    else:
        display_num = 1


touch = touch_sensor.touch_sensor(change_display, pin=TOUCH_PIN)
Exemple #8
0
 def __init__(self):
     # Create our temperature sensor instance.
     self.tempSens = ds18b20()
Exemple #9
0
def main(saveData,now,scriptWD):

    bme = bme280.bme280()
    (temperature,pressure,humidity) = bme.readBME280All()
    print("Temperature : ", temperature, "C")
    print("Pressure : ", pressure, "hPa")
    print("Humidity : ", humidity, "%")
    del bme

    ds = ds18b20.ds18b20()
    temp_c = ds.readDS18b20All()
    for n in range(len(temp_c)):
        print("Senor # : ", n)
        print("Sensor ID : ", temp_c[n][1])
        print("Sensor name :", temp_c[n][2])
        print("Temperature : ", temp_c[n][3], "C")
        if temp_c[n][2] == 'Water bucket':
            tempInBucket = temp_c[n][3]
    del ds

    jsn = jsn_sr0t4_2.jsnsr0t4(tempInBucket)
    (currentDepth, currentH20Content) = jsn.readJSNSR0T4()
    print('current water level : ', currentDepth, ' cm')
    print('current water content : ', currentH20Content, ' l')
    del jsn

    time.sleep(1.) # wait a second for the read LED to switch off
    import tsl2591 # has to be imported here, otherwise jsn_sr0t4 script gives error
    tsl = tsl2591.tsl2591()
    (lux,infrared,visible,full_spectrum) = tsl.readTSL2591All()
    print("Total light : ", lux, "lux")
    print("Infrared light : ", infrared)
    print("Visible light : ", visible)
    print("Full spectrum (IR + visible) light : ", full_spectrum)
    del tsl

    minutes = int(now.strftime("%M"))
    rainfallScraped = False
    if (minutes > 19) and (minutes < 29): # scrape rainfall only once per hour at 20 min
        fullHour = now.strftime("%Hh00")
        rf = scrapeRainfall.scrapeRainfall(fullHour)
        (pluie, hour) = rf.getRainfallData()
        print("Measurement hour :", hour)
        print("Rainfall in mm   :", pluie)

        waterChange = rf.getDifferenceInWaterButtContent(now)
        print("Water in butt changed by : %s l between %02dh and %02dh" % (waterChange[0],waterChange[1],waterChange[2]))
        rainfallScraped = True


    if saveData:
        dFile = open("%s/data/terraceWeather_%s.data" % (scriptWD, now.strftime("%Y-%m")), "a")
        dFile.write("%s %s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (now.strftime("%Y-%m-%d"), now.strftime("%H:%M:%S"), temperature,np.round(pressure, 2),np.round(humidity, 2),temp_c[0][3],temp_c[1][3],np.round(currentDepth, 3), np.round(currentH20Content, 3),np.round(lux,4),infrared,visible,full_spectrum))
        dFile.close()
        print('data saved to file')

        # send data to initial state
        streamer = Streamer(bucket_name=ITA.BUCKET_NAME, bucket_key=ITA.BUCKET_KEY, access_key=ITA.ACCESS_KEY)
        #print(np.round(humidity, 2),np.round(pressure, 2),temperature,temp_c[0][3],temp_c[1][3],np.round(currentH20Content, 3),np.round(lux,4))
        streamer.log(SENSOR_LOCATION_NAME + " Humidity (%)", np.float(np.round(humidity, 2)))
        streamer.log(SENSOR_LOCATION_NAME + " Pressure (hPa)", np.round(pressure, 2))
        streamer.log(SENSOR_LOCATION_NAME + " Chip Temperature (C)", temperature)
        streamer.log(SENSOR_LOCATION_NAME + " Water Bucket Temperature (C)", temp_c[0][3])
        streamer.log(SENSOR_LOCATION_NAME + " Outside Temperature (C)", temp_c[1][3])
        streamer.log(SENSOR_LOCATION_NAME + " Water Content (l)", np.round(currentH20Content, 3))
        streamer.log(SENSOR_LOCATION_NAME + " Luminosity (lux)", np.round(lux,4))
        if rainfallScraped:
            if pluie is not None:
                streamer.log(SENSOR_LOCATION_NAME + " Rainfall (mm)", pluie)
            streamer.log(SENSOR_LOCATION_NAME + " Water Change (l)", np.round(waterChange[0],4))

            dFile = open("%s/data/rainfallWaterChange_%s.data" % (scriptWD,now.strftime("%Y-%m")),"a")
            dFile.write("%s %s\t%s\t%s\n" % (now.strftime("%Y-%m-%d"),now.strftime("%H:00"),pluie,np.round(waterChange[0],4)))
            dFile.close()
            print('rainfall and water change data saved to file')

        streamer.flush()
        print('Upload code finished')
Exemple #10
0
from ds18b20 import ds18b20
from bmp280 import bmp280
# Obtenemos la fecha y hora con el formato elegido
from datetime import datetime
now=datetime.now()
fecha=now.strftime('%Y-%m-%d')
hora=now.strftime('%H:%M')
fechahora=now.strftime('%Y%m%d%H%M')
#Cargados datos obtenidos por sensor dht22
dht22=dht22()
#Separamos la informacion de temperatura
temp1=(dht22[0])
#Separamos humedad
humedad=(dht22[1])
#Cargamos datos temperatura obtenidos por el sensor ds18b20
temp2=ds18b20()
#Cargados datos obtenidos por sensor bmp280
bmp280=bmp280()
#Separamos temperatura
temp3=(bmp280[0])
#Separamos presion
presion=(bmp280[1])
presion=round(presion /10,2)
#Obtenemos la direccion mac de la interfaz
with open('/sys/class/net/wlan0/address') as wlan:
mac=wlan.read()
mac=mac[:-1]
#Obtenemos media temperatura 3 sensores
temps=[temp1,temp2,temp3]
ltemp=len(temps)
tmedia=(round(sum(temps)*1.0/ltemp,2))
Exemple #11
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Email: [email protected]

import time
from ds18b20 import ds18b20
import ener
import mosquitto as mqtt

power = ener.Energenie()
is_connected = False
is_first = True
brew = [{"heater":False,"heatctl":1,"min":20,"max":21,"sensor":ds18b20("28-0517022710ff")},
        {"heater":False,"heatctl":2,"min":20,"max":21,"sensor":ds18b20("28-041702ce85ff")}]

def mqtt_connect(client, userdata, rc):
  global is_connected
  global is_first
  print("Connected with result code {}".format(rc))
  client.subscribe("beer/brew1/heater", 2)
  client.subscribe("beer/brew1/min_temp", 2)
  client.subscribe("beer/brew1/max_temp", 2)
  client.subscribe("beer/brew2/heater", 2)
  client.subscribe("beer/brew2/min_temp", 2)
  client.subscribe("beer/brew2/max_temp", 2)
  is_connected = True
  is_first = True