Here is the code:
Code:
import networkimport socketimport timeimport requestsimport urequestsfrom time import sleepfrom machine import Pin led = Pin("LED", Pin.OUT)def connect(): #Connect to WLAN wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect("NETGEAR93","...") while wlan.isconnected() == False: print("Waiting to connect...\n") sleep(1) print(wlan.ifconfig()) ''' 192.168.0.54 ''' url = 'http://192.168.0.54:8081/zeroconf/switch' myobj = {'data':{'switch':'off'} } x = urequests.post(url, json = myobj, headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0' }) x.close()try: connect()except KeyboardInterrupt: machine.reset()Statistics: Posted by RYoder97 — Sat Oct 05, 2024 5:40 am