def temp(temp_file, delay, queue, arr, mArr): while True: ctemp = read_temp(temp_file) print ctemp if arr[0] == 0: if (mArr[0] = 0 and ctemp >= 26.0) or mArr[0] == 1: queue.put(Mode('Fan', 'on', 1), 1) elif arr[0] == 1: if (mArr[0] = 0 and ctemp < 25.7) or mArr[0] == -1: queue.put(Mode('Fan', 'off', 11), 1)
def serviraj(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((host, port)) s.listen(1) counter = 0 ADC8032.init() while True: client_sock, client_addr = s.accept() print(client_sock) print(client_addr) #request = normalize_line_endings(recv_all(client_sock)) # hack again #request = recv_all(client_sock) #print (request) temp = read_temp() lux = ADC8032.getADC(0) lw, hi = NE555P.freq() freq = (1e+6 / (lw + hi)) client_sock.settimeout(None) response_body = '{"temp":' + str(temp) + ',"hum":' + str( freq) + ',"lum":' + str(lux) + '}' #response_body_raw = ''.join(response_body) # Clearly state that connection will be closed after this response, # and specify length of response body response_headers = { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'text/html; encoding=utf8', 'Content-Length': len(response_body), 'Connection': 'close', } response_headers_raw = ''.join('%s: %s\r\n' % (k, v) for k, v in response_headers.items()) # Reply as HTTP/1.1 server, saying "HTTP OK" (code 200). response_proto = 'HTTP/1.1' response_status = '200' response_status_text = 'OK' # this can be random # sending all this stuff client_sock.send( b'%s %s %s\r\n' % (str.encode(response_proto), str.encode(response_status), str.encode(response_status_text))) client_sock.send(str.encode(response_headers_raw)) client_sock.send(str.encode('\r\n')) # to separate headers from body client_sock.send(str.encode(response_body)) print("Sent!") # and closing connection, as we stated before time.sleep(0.5) client_sock.close()
from LCD import LCDupdate from CloudLog import textLogInit, textLog from DS18B20 import read_temp, OneW_init THINGSPEAKKEY = '34LFZZ49UNKUFHNV' THINGSPEAKURL = 'https://api.thingspeak.com/update' FURL1 = 'https://api.thingspeak.com/update?key=34LFZZ49UNKUFHNV&field1=' FURL2 = '&field2=' FURL3 = '&field3=' print('starting...') #printing in prompt df1, df2, df3 = OneW_init() print("T1: ", read_temp(df1)) print("T2: ", read_temp(df2)) print("T3: ", read_temp(df3)) var=0 #Starting Loop try: while True: TempRead1 = read_temp(df1) #print("current temperature 1 is ", TempRead1, "degree Celsius" ) TempRead2 = read_temp(df2) #print("current temperature 2 is ", TempRead2, "degree Celsius" )
logging.info("Program started ") print("1") LCD_clear() print("2") LCD_write("abcd1234",1) print("3") LCD_write("date "+str(Time[2])+"/"+str(Time[1]) + " at " + str(Time[3]) + ":" + str(Time[3]),2 ) print("4") interval = 10 # initialize interval to 10 seconds while True: try: t = datetime.datetime.now() values = BME280read() TC_device2 = read_temp(deviceFile2) TC_device3 = read_temp(deviceFile3) # print(count, "On", t.day, "at", t.hour,':', t.minute, "measure ", float(values[2]), # "temp ds18b20 ", "#3", TC_device3, ", #2", TC_device2 ) LCD_clear() LCD_write("date "+str(t.day)+"/"+str(t.month) + " at " + str(t.hour) + ":" + str(t.minute),1 ) LCD_write("hP:" + str(int(float(values[0]))) + " rH:" + str(int(float(values[1]))) + " tC:" + str(int(float(values[2]))),2 ) # interval = 900 # GLog( t, float(values[0]), float(values[1]), float(values[2]), TC_device3, TC_device2 ) # IFTTTGLog( t, float(values[0]), float(values[1]), float(values[2]), TC_device3, TC_device2 ) old_interval = interval interval = UBILog(t, float(values[0]), float(values[1]), float(values[2]), TC_device3, TC_device2)