@akshaypatil
from m5stack import *
from m5ui import *
from uiflow import *
from easyIO import *
setScreenColor(0x111111)
import BlynkLib
BLYNK_AUTH = 'YOUR AUTH'
blynk = BlynkLib.Blynk(BLYNK_AUTH)
from machine import Pin
import _onewire
def init(pin):
Pin(pin, Pin.OPEN_DRAIN, Pin.PULL_UP)
def convert(pin):
_onewire.reset(Pin(pin))
_onewire.writebyte(Pin(pin), 0xcc)
_onewire.writebyte(Pin(pin), 0x44)
def read(pin):
_onewire.reset(Pin(pin))
_onewire.writebyte(Pin(pin), 0xcc)
_onewire.writebyte(Pin(pin), 0xbe)
tlo = _onewire.readbyte(Pin(pin))
thi = _onewire.readbyte(Pin(pin))
_onewire.reset(Pin(pin))
temp = tlo + thi * 256
if temp > 32767:
temp = temp - 65536
temp = temp * 0.0625
return(temp)
init(0)
@blynk.VIRTUAL_READ(6)
def v6_read_handler():
blynk.virtual_write(6, "%.2f"%((read(0))))
@blynk.VIRTUAL_WRITE(9) # Button Widget VPIN 9 at GPIO 26
def my_write_handler(value):
blynk.virtual_write(1, toggleIO(26))
while True:
blynk.run()
convert(0)
lcd.clear()
lcd.font(lcd.FONT_DejaVu18)
lcd.print(("%.2f"%((read(0)))), 15, 50, 0xff0000)
lcd.print(digitalRead(26), 35, 90, 0xffffff)
wait_ms(2)
And this will toggle GPIO 26.
Now with the Blynk "Eventor" widget, you can have a summer fan that switches on when the temperature is higher than 28. ;)