from oled96 import oled from PiBlynk import Blynk # read data using pin 4 instance = dht22.DHT22(pin=4) token = "---token---" blynk = Blynk(token) def cnct_cb(): print ("Connected: ") blynk.on_connect(cnct_cb) def _funCb(ACT): result = instance.read() if result.is_valid(): strTemp=("%.2f" % result.temperature) strHumi=("%.2f" % result.humidity) # Show temperature and humidity on OLED oled.yell2("Temp="+strTemp,"Humi="+strHumi) blynk.virtual_write(1,strTemp) # User Virtual port V1 blynk.virtual_write(2,strHumi) # User Virtual port V2 blynk.Ticker(_funCb, 140, False) # ~2 Hz blynk.gpio_auto("button") blynk.run()
if r1.status == 200: data1 = r1.read().decode( 'utf-8') # This will return entire content. beg = data1.find(strStart) d = data1[beg + strlanght:] end = d.find(strEnd) d = d[0:end] if len(d) < 20: return "http://%s.ngrok.io" % d else: len() conn.close() except: ip = os.popen(GET_IP_CMD).read() ip = ip.split(' ') ipLAN = ip[0] ipWiFi = ip[1] return "http://%s:8000" % ipLAN #Connect it with LAN. #return "http://%s:8000" % ipWiFi #Connect it with Wi-Fi. def _funCb(ACT): url = "%s/stream.mjpg" % geturl_ngrok() print(url) blynk.set_property(4, "url", url) blynk.Ticker(_funCb, 1400, False) # ~7 second blynk.gpio_auto("button") blynk.run()