pycom.heartbeat(False) # Disable the heartbeat LED # pybytes.connect_lora_otaa(timeout=15, nanogateway=False) flash_led_to(BLUE) # joining TTN join_lora(True) # Type 0 = dht11 # Type 1 = dht22 dht11 = 0 dht22 = 1 dht_type = dht11 th = DTH(Pin('P23', mode=Pin.OPEN_DRAIN), dht_type) # py = Pysense() #tempHum = SI7006A20(py) # ambientLight = LTR329ALS01(py) while True: # create a LoRa socket # create socket to be used for LoRa communication s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) # configure data rate s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5) # make the socket blocking # (waits for the data to be sent and for the 2 receive windows to expire) s.setblocking(True) #define which port with the socket bind
import machine from machine import Pin import time import pycom import json import _thread import ubinascii import hashlib from lib.dth import DTH from lib.umqtt.robust import MQTTClient pycom.heartbeat(False) # Type 0 = dht11 dht_type = 0 th = DTH(Pin('P23', mode=Pin.OPEN_DRAIN), dht_type) time.sleep(2) with open('my_config.json') as f: config = json.load(f) def blink_led(): for n in range(1): pycom.rgbled(0xfcfc03) time.sleep(0.5) pycom.rgbled(0x000000) time.sleep(0.2) def sub_cb(topic, msg): if msg == b'{"Command":"Red"}': pycom.rgbled(0xff0000) if msg == b'{"Command":"Blue"}': pycom.rgbled(0x0004ff)