Hendrik Langer 5 years ago
parent
commit
91c428eda2
  1. 13
      src/main.cpp

13
src/main.cpp

@ -122,6 +122,7 @@ void printValues() {
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
delay(10);
ESP_LOGD(TAG, "setup hardware and sensors"); ESP_LOGD(TAG, "setup hardware and sensors");
@ -156,12 +157,18 @@ void setup()
helloWorld(); helloWorld();
display.powerOff(); display.powerOff();
ESP_LOGD(TAG, "starting WiFi"); ESP_LOGD(TAG, "connecting to WiFi");
WiFi.setHostname("esp32-weatherstation"); WiFi.setHostname("esp32-weatherstation");
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD);
wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2);
Serial.println("Connecting Wifi..."); for (int tries=0; wifiMulti.run() != WL_CONNECTED && tries < 10; tries++) {
Serial.print(".");
delay(500);
}
if(wifiMulti.run() == WL_CONNECTED) { if(wifiMulti.run() == WL_CONNECTED) {
Serial.println(""); Serial.println("");
Serial.println("WiFi connected"); Serial.println("WiFi connected");
@ -171,7 +178,9 @@ void setup()
} }
ESP_LOGD(TAG, "trying to fetch over-the-air update"); ESP_LOGD(TAG, "trying to fetch over-the-air update");
if (WiFi.status() == WL_CONNECTED) {
ota.update(); ota.update();
}
ESP_LOGD(TAG, "connecting to MQTT"); ESP_LOGD(TAG, "connecting to MQTT");
mqtt.begin(); mqtt.begin();

Loading…
Cancel
Save