|
|
@ -85,26 +85,23 @@ void printValues() { |
|
|
|
Serial.println(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Setup function |
|
|
|
* |
|
|
|
* is run once on startup |
|
|
|
*/ |
|
|
|
void setup() |
|
|
|
{ |
|
|
|
Serial.begin(115200); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "setup hardware and sensors"); |
|
|
|
|
|
|
|
// initialize LED digital pin as an output.
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT); |
|
|
|
|
|
|
|
Serial.println("setup"); |
|
|
|
|
|
|
|
// initialize e-paper display
|
|
|
|
SPI.begin(18, 19, 23, TFT_CS); |
|
|
|
display.init(); |
|
|
|
Serial.println("display init done"); Serial.flush(); |
|
|
|
|
|
|
|
display.clearScreen(); |
|
|
|
display.refresh(); |
|
|
|
|
|
|
|
helloWorld(); |
|
|
|
display.powerOff(); |
|
|
|
|
|
|
|
#define BME_SDA 21 |
|
|
|
#define BME_SCL 22 |
|
|
@ -123,6 +120,15 @@ void setup() |
|
|
|
|
|
|
|
sds.begin(); |
|
|
|
|
|
|
|
display.clearScreen(); |
|
|
|
display.refresh(); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "displaying welcome screen"); |
|
|
|
helloWorld(); |
|
|
|
display.powerOff(); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "starting WiFi"); |
|
|
|
WiFi.setHostname("esp32-weatherstation"); |
|
|
|
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); |
|
|
|
wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); |
|
|
|
|
|
|
@ -134,17 +140,24 @@ void setup() |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
} |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "trying to fetch over-the-air update"); |
|
|
|
XD0OTA ota("esp32-weatherstation"); |
|
|
|
ota.update(); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "connecting to MQTT"); |
|
|
|
mqtt.begin(); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "setup done"); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Arduino main loop |
|
|
|
*/ |
|
|
|
void loop() |
|
|
|
{ |
|
|
|
Serial.println("loop"); |
|
|
|
|
|
|
|
ESP_LOGD(TAG, "loop()"); |
|
|
|
|
|
|
|
/* Do an e-paper display refresh every 2 minutes */ |
|
|
|
if (millis() - lastDisplayUpdate >= 2*60*1000) { |
|
|
|
lastDisplayUpdate = millis(); |
|
|
|
display.setFullWindow(); |
|
|
|