Skip to content

Instantly share code, notes, and snippets.

@linusheck
Last active September 21, 2018 08:57
Show Gist options
  • Save linusheck/8ba678d3e5935a3669e89e6484e47b1f to your computer and use it in GitHub Desktop.
Save linusheck/8ba678d3e5935a3669e89e6484e47b1f to your computer and use it in GitHub Desktop.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* POST_TO = /* local IP of router here */;
// Sensitive data omitted
const char* POST_REQUEST = "ACT=LOGI%40LTYP=1%40MAC=%40IP=%40ERV=%40URL=%40PUB=1%40MEDM=0%40USR=%40PASS=";
void setup() {
Serial.begin(115200);
}
void loop() {
WiFi.begin(/* network name */);
Serial.println();
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("Connected!");
Serial.println("Posting");
HTTPClient http;
http.begin(POST_TO);
http.POST(POST_REQUEST);
http.writeToStream(&Serial);
http.end();
WiFi.disconnect();
WiFi.forceSleepBegin();
delay(10*60*1000);
WiFi.forceSleepWake();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment