def interrupt_fired(channel): print("interrupt Fired") a = 5 data = [{ 'measurement': 'pir', 'tags': { 'VisionUni': '2410', }, 'fields': { 'pir': a, } }] client = None try: client = influxdb('localhost', 8086, 'root', 'root', 'pir') except Exception as e: print "Exception" + str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write" + str(e) finally: client.close() print(a)
def write(self, value): client = None try: client = influxdb(self.host, self.port, self.user, self.passwd, self.db, timeout=InfluxdbConsts.INFLUXDB_WRITE_TIMEOUT, retries=InfluxdbConsts.INFLUXDB_WRITE_RETRIES) except Exception as e: self.logger.warn('open Exception ' + str(e)) if client is not None: try: client.write_points(self.setData(value)) except Exception as e: self.logger.warn('write Exception ' + str(e)) finally: client.close()
print(a) GPIO.add_event_detect(4,GPIO.FALLING, callback=interrupt_fired) while(True): time.sleep(1) a = 5 data = [{ 'measurement' : 'pir', 'tags':{ 'work': '2014', }, 'fields':{ 'pir': a, } }] client = None try: client = influxdb('localhost',8086,'root','root',"second") except Exception as e: print "Exception" +str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write" + str(e) finally: client.close() print("running influxdb OK")
val2 = 1 print "CH2 LEAK!!!" data = [{ 'measurement': 'sensor', 'tags': { 'chId': msg.srcID, }, 'fields': { 'seqNo': msg.seqNo, 'ch1': val1, 'ch2': val2, } }] print data client = None try: client = influxdb('localhost', 8086, 'root', 'root', 'leak') except Exception as e: print "Exception " + str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write " + str(e) finally: client.close()
ADDR = (HOST, PORT) client_socket = socket(AF_INET, SOCK_STREAM) client_socket.connect(ADDR) if __name__ == "__main__": try: print("Starting") #hpma115S0 = HPMA115S0.HPMA115S0("/dev/ttyAMA0") hpma115S0 = HPMA115S0.HPMA115S0("/dev/serial0") hpma115S0.init() hpma115S0.startParticleMeasurement() client = influxdb('localhost', 8086, 'root', 'root', 'example_script') # 키보드로 입력한 문자열을 서버로 전송하고 # 서버에서 에코되어 돌아오는 메시지를 받으면 화면에 출력합니다. # quit를 입력할 때 까지 반복합니다. while True: if (hpma115S0.readParticleMeasurement()): print("PM2.5: %d ug/m3" % (hpma115S0._pm2_5)) print("PM10: %d ug/m3" % (hpma115S0._pm10)) pm2 = hpma115S0._pm2_5 pm10 = hpma115S0._pm10 clientSocket.send(pm2.encode()) clientSocket.send(pm10.encode()) # if ret != True : print "[problem|influx]"
print(a) GPIO.add_event_detect(4, GPIO.FALLING, callback=interrupt_fired) while (True): time.sleep(1) a = 1 data = [{ 'measurement': 'pir', 'tags': { 'VisionUni': '2410', }, 'fields': { 'pir': a, } }] client = None try: client = influxdb('localhost', 8086, 'root', 'root', 'pir') except Exception as e: print "Exception" + str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write" + str(e) finally: client.close() print("running influxdb OK")
def running(): while True: p = am.read() msg = OscilloscopeMsg(p.data) print p ####### ZLeak Sensor Logic ############ print "ID:", msg.srcID, "seqNo:", msg.seqNo, "Data0:", msg.Data0, "Data1:", msg.Data1, " Data2:", msg.Data2, "Data3:", msg.Data3, "Data4:", msg.Data4, " Data5:", msg.Data5 if (msg.Data0 == msg.Data3): if (msg.Data0 <= 255): reData = msg.Data0 print reData else: if (msg.Data0 == msg.Data5): if (msg.Data0 == msg.Data1): reData = str(msg.Data0) + str(msg.Data1) print reData else: reData = str(msg.Data0) + '0' + str(msg.Data2) print reData else: reData = str(msg.Data0) + str(msg.Data1) print reData if (int(reData) >= 4000): if G.input(27) is 1: print "running function 17 button state On" G.setup(2, G.LOW) if G.input(17) is 1: print "running function 27 button state On" G.setup(3, G.LOW) print "LEAK!!!" # if (msg.ch2 > 4000): # val2 = 0 # else: # val2 = 1 # print "CH2 LEAK!!!" data = [{ 'measurement': 'sensor', 'tags': { 'chId': msg.srcID, }, 'fields': { 'seqNo': msg.seqNo, 'Value': reData, } }] # print data client = None try: client = influxdb('localhost', 8086, 'root', 'root', 'leak') except Exception as e: print "Exception " + str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write " + str(e) finally: client.close()
'measurement' : 'th', 'tags':{ 'office': '1', }, 'fields':{ 'temp' : t, 'humi' : h, } }] print("Temp={0:0.1f}*C Humidity={1:0.1f}%".format(t,h)) else: print("Read error") client = None try: client = influxdb('localhost',8086,'root','root','jjvision') except Exception as e: print "Exception" + str(e) if client is not None: try: client.write_points(data) except Exception as e: print "Exception write" + str(e) finally: client.close() time.sleep(1) except KeyboardInterrupt: print("Terminated by Keyboard") finally:
def configure(self, env): import params env.set_params(params) influxdb()
def influx_client(): global __tsdb_client if not __tsdb_client: __tsdb_client = influxdb('localhost', 8086, 'root', 'root', 'sensing') return __tsdb_client
rcvBuf = bytearray() device.reset_input_buffer() rcvBuf = device.read_until(size=12) print rcvBuf temp = rcvBuf.find('p') a = rcvBuf[2:temp] b = int(a) data = [{ 'measurement':'co2', 'tags':{ 'vision':'2410', }, 'fields':{ 'co2':a, } }] client=None client = influxdb('localhost',8086,'root','root','co2') if Client is not None: try: client.write_points(data) except Exception as e: print("Exception write") + str(e) finally: client.close() except Exception as e: print("Exception read")+str(e) time.sleep(5)