Last active
October 29, 2017 14:59
-
-
Save KazuyukiEguchi/d760ccd6af3f39d91d94c72bb9edf4b1 to your computer and use it in GitHub Desktop.
Wio LTE IFTTT通信編(mineo au SIM) ref: http://qiita.com/KazuyukiEguchi/items/26b29f82cca40d976409
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
#include <WioLTEforArduino.h> | |
#include <stdio.h> | |
#define APN "mineo.jp" | |
#define USERNAME "mineo@k-opti.com" | |
#define PASSWORD "mineo" | |
#define WEBHOOK_EVENTNAME "wiolte_uptime" | |
#define WEBHOOK_KEY "秘密" | |
#define WEBHOOK_URL "https://maker.ifttt.com/trigger/"WEBHOOK_EVENTNAME"/with/key/"WEBHOOK_KEY | |
#define INTERVAL (60000) | |
WioLTE Wio; | |
void setup() { | |
delay(200); | |
SerialUSB.println(""); | |
SerialUSB.println("--- START ---------------------------------------------------"); | |
SerialUSB.println("### I/O Initialize."); | |
Wio.Init(); | |
SerialUSB.println("### Power supply ON."); | |
Wio.PowerSupplyLTE(true); | |
delay(5000); | |
SerialUSB.println("### Turn on or reset."); | |
if (!Wio.TurnOnOrReset()) { | |
SerialUSB.println("### ERROR! ###"); | |
return; | |
} | |
SerialUSB.println("### Connect the \""APN"\"."); | |
delay(5000); | |
if (!Wio.Activate(APN, USERNAME, PASSWORD)) { | |
SerialUSB.println("### ERROR! ###"); | |
return; | |
} | |
} | |
void loop() { | |
char data[100]; | |
int status; | |
SerialUSB.println("### Post."); | |
sprintf(data, "{\"value1\":\"uptime %lu\"}", millis() / 1000); | |
SerialUSB.print("Post:"); | |
SerialUSB.print(data); | |
SerialUSB.println(""); | |
if (!Wio.HttpPost(WEBHOOK_URL, data, &status)) { | |
SerialUSB.println("### ERROR! ###"); | |
goto err; | |
} | |
SerialUSB.print("Status:"); | |
SerialUSB.println(status); | |
err: | |
SerialUSB.println("### Wait."); | |
delay(INTERVAL); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment