Temelelektronik.info

MicroPython'la Led Yakıp Söndürme(ESP8266)

Devre


Bu devre Eylül ayından itibaren 220  defa ziyaret edilmiştir.

Açıklama

#boot.py
try:
  import usocket as socket
except:
  import socket

from machine import Pin
import network

import esp
esp.osdebug(None)

import gc
gc.collect()

ssid = 'HUAWEI P smart 2019'
password = '12345687'

station = network.WLAN(network.STA_IF)
station.active(True)
station.connect(ssid, password)

while station.isconnected() == False:
  pass

print('Connection successful')
print(station.ifconfig())





#main.py
from urllib import urequest
from time import sleep
led = Pin(5, Pin.OUT)
  
def sayfagetir():
    response = urequest.urlopen("http://www.temelelektronik.info/relay.aspx?sensor=1")
    # set the correct charset below
    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:
    sayfagetir()
    sleep(5)

Download

ledyaksondur.rar