def writefeed(): data = int(time.time()) % 10 feeddat = { "var1": data, "var2": (data - 1) * 10, "var3": (data + 5) * 20, } microgear.writeFeed("feed0001", feeddat, feedkey=netpiefeedkey)
ser = serial.Serial('/dev/ttyS0', 115200, timeout=1) ser.close() ser.open() i = 0 while 1: sleep(0.2) #ser.write("Hellowworld.\r\n".encode()) line = (ser.readline()) if (i < 10): i = i + 1 else: if len(line) > 0: netpiestring = line[6:9] print(line) print(netpiestring) netpie = float(netpiestring) #netpie = 50 print("Writing Feed") print(netpie) data2feed = {"Range": ("%1f" % netpie)} microgear.writeFeed(FEEDID, data2feed, APIKEY) i = 0 # Visualize, check the answer Original_input_image_testing = cv2.imread(Testing_img_path) cv2.imshow("This is what your computer has seen.", Original_input_image_testing) cv2.waitKey(0) cv2.destroyAllWindows()
microgear.on_disconnect = disconnect microgear.subscribe("/mails") microgear.connect(False) GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(4, GPIO.OUT, initial=GPIO.HIGH) pump_state = 0 while True: if GPIO.input(17) == 1: # turn leds on print "pump on" GPIO.output(4, GPIO.LOW) pump_state = 1 sleep(2) # sleep 1 second else: # turn leds off print "pump off" GPIO.output(4, GPIO.HIGH) pump_state = 0 sleep(2) # sleep 1 second if (microgear.connected): microgear.chat("sensorstatus", str(int(pump_state))) data = {"pump": pump_state * 10} #data = {"field1":random.randint(1, 10),"field2":random.randint(1, 10),"field3":random.randint(1, 10)} microgear.writeFeed("sobmeoi", data)
rset = True else: rset = False GPIO.output(relays[int(message[0])], rset) def disconnect(): print "disconnect is work" microgear.setalias("PCU1") microgear.on_connect = connection microgear.on_message = subscription microgear.on_disconnect = disconnect microgear.subscribe("/msg"); microgear.subscribe("/cmd"); microgear.connect(False) while True: y,m,d,h,mi,s,wd,wy,isd = time.localtime() msg = ser.readline() datalist = msg.split(',') if len(datalist) == 3: temp = datalist[0] hh = datalist[1] ec = datalist[2].rstrip() data = {"ec": ec ,"temp":temp} microgear.writeFeed("MelonFeed",data) microgear.publish("/msg",msg) time.sleep(1)
def disconnect(): print("disconnect is work") microgear.setalias("station1") microgear.on_connect = connection microgear.on_message = subscription microgear.on_disconnect = disconnect microgear.subscribe("/station1/#") microgear.connect(False) while True: if (microgear.connected): tem = ser.readline() if len(tem) > 3: tem = tem.replace("\r\n", "") c, h, t = tem.split(",") microgear.publish("/station1/temperature1", c) microgear.publish("/station1/humid", h) microgear.publish("/station1/temperature2", t) data = {"Temperature1": c, "Humid": h, "Temperature2": t} microgear.writeFeed("EGATWeather", data, "7FnyupCE8kBPHOOAVU61wh7v85crfPzk") time.sleep(3)