Created
September 17, 2022 07:11
-
-
Save edthix/a37e794b9e3b2172b4a74ad6c281a0a8 to your computer and use it in GitHub Desktop.
PyCon MY 2022 - sample codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_connect(): | |
import network | |
wlan = network.WLAN(network.STA_IF) | |
wlan.active(True) | |
if not wlan.isconnected(): | |
print('connecting to network...') | |
wlan.connect('smartspacekk', 'smartspace09') | |
while not wlan.isconnected(): | |
pass | |
print('network config:', wlan.ifconfig()) | |
# run | |
do_connect() | |
# url of request bin or your endpoint | |
url = "https://requestbin.io/zi3sngzi" | |
import urequests | |
import ujson | |
import machine | |
data = { | |
"device_id": machine.unique_id() | |
} | |
# let's send this | |
urequests.post(url, data=ujson.dumps(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment