Skip to content

Instantly share code, notes, and snippets.

@KazuyukiEguchi
Last active October 29, 2017 14:59
Show Gist options
  • Save KazuyukiEguchi/d760ccd6af3f39d91d94c72bb9edf4b1 to your computer and use it in GitHub Desktop.
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
#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