def send_analogdata(data): print("Send Data =", data) lora.frame_counter = lora.frame_counter + 1 c = CayenneLPP() c.addAnalogInput(1, lora.frame_counter) c.addAnalogInput(2, myl) c.addAnalogOutput(1, data) #c.addTemperature(1, 23.5) # Add temperature read to channel 1 # c.addAnalogInput(1,lora.frame_counter) #c.addTemperature(2, 22.7) # Add another temperature read to channel 2 #c.addRelativeHumidity(3, 88.5) # Add relative humidity read to channel 3 frame = c.getBuffer() # Get bytes #Send data packet lora.send_data(frame, len(frame), lora.frame_counter) print(lora.frame_counter) display.fill(0) display.text('Sent LPP Data to Lora!', 0, 0, 1) display.text('Sending ' + str(data) + " / " + str(lora.frame_counter), 0, 15, 1) print('Data sent!') display.show() time.sleep(10) display.fill(0)
def send_all_pi_data(temp, cpu, ram, myl): print("Send all Pi Data =", str(temp)) lora.frame_counter = lora.frame_counter + 1 c = CayenneLPP() c.addAnalogInput(1, lora.frame_counter) c.addAnalogInput(2, myl) c.addTemperature(1, temp) c.addAnalogOutput(1, cpu) c.addAnalogOutput(1, ram) frame = c.getBuffer() # Get bytes #Send data packet lora.send_data(frame, len(frame), lora.frame_counter) print("lora frame counter", lora.frame_counter) display.fill(0) display.text('Sent LPP Data to Lora!', 0, 0, 1) display.text('temp,cpu,ram t=' + str(temp), 0, 10, 1) display.text('lora frame = ' + str(lora.frame_counter), 0, 20, 1) print('Data All Pi sent!') display.show() time.sleep(10)
print("CSS811 values:") print("**************") print('eCO2: %d ppm, TVOC: %d ppb' % (s.eCO2, s.tVOC)) d.text('eCO2 ppm', 0, 30) d.text(str(s.eCO2), 70, 30) d.text('TVOC ppb', 0, 40) d.text(str(s.tVOC), 70, 40) d.show() #time.sleep(3) c = CayenneLPP() c.addTemperature(1, float(temp)) c.addBarometricPressure(2, float(pa)) c.addTemperature(3, float(tsensor.temperature)) c.addRelativeHumidity(4, float(tsensor.relative_humidity)) c.addLuminosity(5, s.eCO2) c.addLuminosity(6, s.tVOC) c.addDigitalOutput(7, 1) c.addAnalogOutput(8, 120.0) b = (ubinascii.hexlify(c.getBuffer())) print('************ Sending Data Status **************') led.value(1) ATresp = sendATcommand("AT+NMGS={0},{1}".format(int(len(b) / 2), (b.decode('utf-8')))) print('********Finish Sending & Receiving Data Status******') led.value(0) cnt = cnt + 1 time.sleep(10.0)
# Set the Counter for re-checking GPS check_gps = utime.time() while True: utime.sleep(2) print('Attempt to Send') pm25, pm10 = run_sds011.run_sensor() print('Air Quality PM2.5: {}, PM10: {}'.format(pm25, pm10)) # make the socket blocking # (waits for the data to be sent and for the 2 receive windows to expire) s.setblocking(True) # send some data c = CayenneLPP() c.addAnalogOutput(2, acc.pitch()) c.addAnalogOutput(25, pm25) c.addAnalogOutput(10, pm10) # Check if GPS data was found if coords[0] is not None: coords = gps.coordinates() if coords[0] is not None and coords[1] is not None: c.addGPS(5, coords[0], coords[1], 0) s.send(bytes(c.getBuffer())) print('SENT') # make the socket non-blocking # (because if there's no data received it will block forever...) s.setblocking(False) # every 10 seconds i want it to blink # get any data received (if any...)