Açıklama
|
#main.pyimport osfrom urllib import urequestfrom time import sleepfrom machine import Pinimport time, ds18x20import onewiretry: import usocket as socketexcept: import socketimport networkimport espesp.osdebug(None)import gcgc.collect()led = Pin(4, Pin.OUT)station = network.WLAN(network.STA_IF)ssid = 'f@tih'password = '!1qaz2WSX3edc4RFV%56'def Baglan(): station.active(True) station.connect(ssid, password) if station.isconnected() == True: print('Connection successful') print(station.ifconfig()) return Truedef getTemp(): ow = onewire.OneWire(Pin(14)) ds = ds18x20.DS18X20(ow) roms = ds.scan() ds.convert_temp() time.sleep_ms(750) for rom in roms: return ds.read_temp(rom) def sayfagetir(value): if station.isconnected() == False: exec(open('./main.py').read(),globals()) Baglan() response = urequest.urlopen("http://www.temelelektronik.info/lion.aspx?sensor=3&temp={}".format(value)) #page_source = response.read().decode('Windows-1254') #a=page_source.count('Green') #print(a) #if a==1: #led.value(1) #else: # led.value(0)while True: lasttemp=getTemp(); sayfagetir(lasttemp) sleep(600) Program Kodları:http://temelelektronik.info/bilgi.aspx?bilgi=3938
|
|