Skip to content

Instantly share code, notes, and snippets.

@awong1900
Last active August 17, 2016 02:57
Show Gist options
  • Save awong1900/a64bd638b89c92ee8243 to your computer and use it in GitHub Desktop.
Save awong1900/a64bd638b89c92ee8243 to your computer and use it in GitHub Desktop.
wio exmaple
# turn on relay with Grove_Relay
import requests
token = "your device token" # from you API on phone
url = "https://iot.seeed.cc/v1/node/GroveRelayD0/onOff/1?=access_token=%s" %token
r = request.post(url)
print r.json()
# get humidity with GroveTempHum
import requests
token = "your device token" # from you API page on the app
domain = "https://us.wio.seeed.io" # which server domain you choice
url = "%s/v1/node/GroveTempHumD2/humidity?=access_token=%s" %domain, token
r = request.get(url)
print r.json()
#accept wiolink's event and print it
import websocket
import thread
import time
token = "your device token" # from you API on phone
def on_message(ws, message):
print message
def on_error(ws, error):
print error
def on_close(ws):
print "### closed ###"
def on_open(ws):
ws.send(token)
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://iot.seeed.cc/v1/node/event",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()
# flash Grove-Led strip Red color
import requests
token = "your device token" # from you API on phone
url = "https://iot.seeed.cc/v1/node/GroveLedWs2812D0/clear/40/800000?=access_token=%s" %token
r = request.post(url)
print r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment