ip
This commit is contained in:
parent
f161e467bf
commit
9350b6f77d
7
.vscode/arduino.json
vendored
7
.vscode/arduino.json
vendored
@ -1,7 +1,6 @@
|
||||
{
|
||||
"output": "Output",
|
||||
"port": "/dev/ttyUSB0",
|
||||
"board": "esp8266:esp8266:generic",
|
||||
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=921600,FlashSize=4M2M,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
||||
"sketch": "frontend.ino"
|
||||
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=115200,FlashSize=512K0,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
||||
"sketch": "frontend.ino",
|
||||
"port": "/dev/ttyUSB0"
|
||||
}
|
12
frontend.ino
12
frontend.ino
@ -10,7 +10,7 @@
|
||||
String inTemp,outTemp,pressure,humid;
|
||||
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
||||
short int lastBeep;
|
||||
const String httpAddr="http://192.168.100.101:1880";
|
||||
const String httpAddr="http://192.168.100.100:1880";
|
||||
|
||||
WiFiUDP ntpUDP;
|
||||
NTPClient timeClient(ntpUDP);
|
||||
@ -45,15 +45,14 @@ void loop(){
|
||||
netTasks();
|
||||
}
|
||||
else {
|
||||
delay(750);
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
void netTasks() {
|
||||
HTTPClient http;
|
||||
WiFi.forceSleepWake();
|
||||
wifiConnect();
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
wifiConnect();
|
||||
wifiConnect(false);
|
||||
}
|
||||
http.begin(httpAddr+"/inTemp");
|
||||
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
||||
@ -141,21 +140,18 @@ bool nightMode() {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void wifiConnect() {
|
||||
void wifiConnect(bool boot) {
|
||||
int beginMillis = millis();
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED && millis() - beginMillis < 30000) {
|
||||
delay(250);
|
||||
displayStatus(1);
|
||||
Serial.print(".");
|
||||
}
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
displayStatus(2);
|
||||
delay(10000);
|
||||
ESP.reset();
|
||||
} else {
|
||||
Serial.print("Connected to " + String(ssid) + "; IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
displayStatus(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user