Skip to content

Instantly share code, notes, and snippets.

@edthix
Created September 17, 2022 07:11
Show Gist options
  • Save edthix/a37e794b9e3b2172b4a74ad6c281a0a8 to your computer and use it in GitHub Desktop.
Save edthix/a37e794b9e3b2172b4a74ad6c281a0a8 to your computer and use it in GitHub Desktop.
PyCon MY 2022 - sample codes
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