49 lines
996 B
C++
Executable File
49 lines
996 B
C++
Executable File
#include <ESP8266WiFi.h>
|
|
|
|
IPAddress ip(192, 168, 1, 222);
|
|
IPAddress gateway(192, 168, 1, 1);
|
|
IPAddress subnet(255, 255, 255, 0);
|
|
IPAddress DNS(192, 168, 1, 1);
|
|
|
|
const char* ssid = "Livebox-37cc";
|
|
const char* password = "8A6060920A8A86896F770F2C47";
|
|
|
|
int sleepTime = 120;
|
|
|
|
void setup(){
|
|
Serial.begin(9600);
|
|
WiFi.config(ip, gateway, subnet, DNS);
|
|
delay(100);
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
// WiFi.forceSleepWake();
|
|
// delay( 1 );
|
|
// WiFi.persistent( false );
|
|
|
|
WiFi.begin(ssid, password);
|
|
Serial.print("Connecting");
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
Serial.print(".");
|
|
delay(200);
|
|
}
|
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
|
Serial.println();
|
|
Serial.println("Fail connecting");
|
|
delay(5000);
|
|
ESP.restart();
|
|
}
|
|
Serial.print(" OK ");
|
|
Serial.print("Module IP: ");
|
|
Serial.println(WiFi.localIP());
|
|
|
|
ESP.deepSleep(sleepTime * 1000000L);
|
|
|
|
delay(200);
|
|
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
|
|
}
|