def send_data(): try: dht_T, dht_RH = read_dht.value() print('sending data ...', dht_T, dht_RH) urequests.post(url + bearer, json={"dht_T": dht_T, "dht_RH": dht_RH}) except (OSError, NameError, ValueError, TypeError): pass
def send_value(): try: dht_T, dht_RH = read_dht.value() print('dht temp: ', dht_T) # one byte print('dht RH: ', dht_RH) # one byte c.publish( topic_pub, '{"Omar": {"dht temp":' + str(dht_T) + ',"dht RH":' + str(dht_RH) + '}}') print('Sensor data sent ..') except (NameError, ValueError, TypeError): print('Failed to send!')
def send_value(): co2, voc, bmp_P, bmp_T = i2c_read.value() dht_T, dht_RH = read_dht.value() print('co2: ', co2) # two bytes print('voc: ', voc) # two bytes print( 'bmp P: ', bmp_P ) # range of BMP180 300 as min and 1100 as max 800 range, 0,02hPa acc. Atm pressure. print('bmp temp: ', bmp_T) # -40 +85 range. 125 total range. one byte print('dht temp: ', dht_T) # one byte print('dht RH: ', dht_RH) # one byte package = (struct.pack('>H', int(co2)) + struct.pack('>H', int(voc)) + struct.pack('>H', int((bmp_P - 300) * (65536 / 800))) + struct.pack('>B', int((bmp_T + 40) * (256 / 125))) + struct.pack('>B', int((dht_T + 40) * (256 / 125))) + struct.pack('>B', int((dht_RH) * (256 / 100)))) s.send(package)
def send_value(): try: co2, voc, bmp_P, bmp_T = i2c_read.value() dht_T, dht_RH = read_dht.value() # print('co2: ', co2) # two bytes # print('voc: ', voc) # two bytes # print('bmp P: ', bmp_P) # range of BMP180 300 as min and 1100 as max 800 range, 0,02hPa acc. Atm pressure. # print('bmp temp: ', bmp_T) # -40 +85 range. 125 total range. one byte # print('dht temp: ', dht_T) # one byte # print('dht RH: ', dht_RH) # one byte c.publish( topic_pub, '{"office_sensor": {"co2":' + str(co2) + ',"voc":' + str(voc) + ',"bmp P":' + str(bmp_P) + ',"bmp temp":' + str(bmp_T) + ',"dht temp":' + str(dht_T) + ',"dht RH":' + str(dht_RH) + '}}') print('Sensor data sent ..') blink_led() except (NameError, ValueError, TypeError): print('Failed to send!')
def send_value(): try: co2, voc, bmp_P, bmp_T = i2c_read.value() dht_T, dht_RH = read_dht.value() # print('co2: ', co2) # two bytes # print('voc: ', voc) # two bytes # print('bmp P: ', bmp_P) # range of BMP180 300 as min and 1100 as max 800 range, 0,02hPa acc. Atm pressure. # print('bmp temp: ', bmp_T) # -40 +85 range. 125 total range. one byte # print('dht temp: ', dht_T) # one byte # print('dht RH: ', dht_RH) # one byte package = (struct.pack('>H', int(co2)) + struct.pack('>H', int(voc)) + struct.pack('>H', int((bmp_P - 300) * (65536 / 800))) + struct.pack('>B', int((bmp_T + 40) * (256 / 125))) + struct.pack('>B', int((dht_T + 40) * (256 / 125))) + struct.pack('>B', int((dht_RH) * (256 / 100)))) s.send(package) for n in range(2): pycom.rgbled(0xfcfc03) time.sleep(1) pycom.rgbled(0x000000) time.sleep(0.5) except (NameError, ValueError, TypeError): pass