107 lines
1.5 KiB
Markdown
107 lines
1.5 KiB
Markdown
````.ino
|
||
#include <ESP8266WiFi.h>
|
||
|
||
#include <ESP8266HTTPClient.h>
|
||
|
||
#include <WiFiClientSecure.h>
|
||
|
||
#include <WiFiClient.h>
|
||
|
||
#include <ArduinoJson.h>
|
||
|
||
|
||
|
||
const int rows = 3;
|
||
|
||
const char* wlans[rows][2] = { { "Privat W-LAN", "99842DA5D0" }, { "Rose", "Lodner2023" }, { "Privat W-LAN", "99842DA5D0" } };
|
||
|
||
const char* serverAddress = "https://api.temperature-station.lodner.dev/measurement";
|
||
|
||
|
||
|
||
WiFiClientSecure client;
|
||
|
||
HTTPClient https;
|
||
|
||
|
||
|
||
void setup() {
|
||
|
||
Serial.begin(9600);
|
||
|
||
|
||
|
||
Serial.println("Start connecting to wlan.");
|
||
|
||
|
||
|
||
for (int i = 0; i < rows; ++i) {
|
||
|
||
WiFi.begin(wlans[i][0], wlans[i][1]);
|
||
|
||
Serial.print("Connecting to: ");
|
||
|
||
Serial.println(wlans[i][0]);
|
||
|
||
|
||
|
||
int trys = 0;
|
||
|
||
while (WiFi.status() != WL_CONNECTED && trys < 30) {
|
||
|
||
Serial.print("Err connecting to: ");
|
||
|
||
Serial.print(wlans[i][0]);
|
||
|
||
Serial.print(" Versuch: ");
|
||
|
||
Serial.println(trys + 1);
|
||
|
||
trys++;
|
||
|
||
delay(1000);
|
||
|
||
}
|
||
|
||
Serial.println("");
|
||
|
||
|
||
|
||
if (WiFi.status() == WL_CONNECTED) {
|
||
|
||
Serial.print("Connected to WiFi network with IP Address: ");
|
||
|
||
Serial.println(WiFi.localIP());
|
||
|
||
break;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
if (WiFi.status() == WL_CONNECTED) {
|
||
|
||
Serial.print("Connected to WiFi network with IP Address: ");
|
||
|
||
Serial.println(WiFi.localIP());
|
||
|
||
} else {
|
||
|
||
// TODO: LED = 1 when not connected?
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
void loop() {
|
||
|
||
// put your main code here, to run repeatedly:
|
||
|
||
|
||
|
||
}
|
||
``` |