|
|
@ -122,6 +122,7 @@ void printValues() { |
|
|
|
void setup() |
|
|
|
{ |
|
|
|
Serial.begin(115200); |
|
|
|
delay(10); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "setup hardware and sensors"); |
|
|
|
|
|
|
@ -156,12 +157,18 @@ void setup() |
|
|
|
helloWorld(); |
|
|
|
display.powerOff(); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "starting WiFi"); |
|
|
|
ESP_LOGD(TAG, "connecting to WiFi"); |
|
|
|
|
|
|
|
WiFi.setHostname("esp32-weatherstation"); |
|
|
|
|
|
|
|
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); |
|
|
|
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) { |
|
|
|
Serial.println(""); |
|
|
|
Serial.println("WiFi connected"); |
|
|
@ -171,7 +178,9 @@ void setup() |
|
|
|
} |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "trying to fetch over-the-air update"); |
|
|
|
ota.update(); |
|
|
|
if (WiFi.status() == WL_CONNECTED) { |
|
|
|
ota.update(); |
|
|
|
} |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "connecting to MQTT"); |
|
|
|
mqtt.begin(); |
|
|
|