Last active
August 17, 2016 02:57
-
-
Save awong1900/a64bd638b89c92ee8243 to your computer and use it in GitHub Desktop.
wio exmaple
This file contains 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
# 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() |
This file contains 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
# 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() |
This file contains 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
#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() |
This file contains 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
# 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