|
@ -36,6 +36,7 @@ Adafruit_BME280 bme; // I2C (also available: hardware SPI |
|
|
//HardwareSerial Serial2(2);
|
|
|
//HardwareSerial Serial2(2);
|
|
|
SdsDustSensor sds(Serial2); |
|
|
SdsDustSensor sds(Serial2); |
|
|
|
|
|
|
|
|
|
|
|
XD0OTA ota("esp32-weatherstation"); |
|
|
XD0MQTT mqtt; |
|
|
XD0MQTT mqtt; |
|
|
|
|
|
|
|
|
uint32_t lastDisplayUpdate = 0; |
|
|
uint32_t lastDisplayUpdate = 0; |
|
@ -153,7 +154,6 @@ void setup() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ESP_LOGD(TAG, "trying to fetch over-the-air update"); |
|
|
ESP_LOGD(TAG, "trying to fetch over-the-air update"); |
|
|
XD0OTA ota("esp32-weatherstation"); |
|
|
|
|
|
ota.update(); |
|
|
ota.update(); |
|
|
|
|
|
|
|
|
ESP_LOGD(TAG, "connecting to MQTT"); |
|
|
ESP_LOGD(TAG, "connecting to MQTT"); |
|
@ -197,6 +197,17 @@ void loop() |
|
|
} |
|
|
} |
|
|
while (display.nextPage()); |
|
|
while (display.nextPage()); |
|
|
display.powerOff(); |
|
|
display.powerOff(); |
|
|
|
|
|
|
|
|
|
|
|
/* send values MQTT */ |
|
|
|
|
|
String topic_temperature = String("thomas/sensor/") + ota.getMAC() + String("/temperature"); |
|
|
|
|
|
String topic_humidity = String("thomas/sensor/") + ota.getMAC() + String("/humidity"); |
|
|
|
|
|
String topic_pressure = String("thomas/sensor/") + ota.getMAC() + String("/pressure"); |
|
|
|
|
|
char temperature[8]; sprintf(temperature, "%.2f", bme.readTemperature()); |
|
|
|
|
|
char humidity[7]; sprintf(humidity, "%.2f", bme.readHumidity()); |
|
|
|
|
|
char pressure[8]; sprintf(pressure, "%.2f", bme.readPressure() / 100.0F); |
|
|
|
|
|
mqtt.publish(topic_temperature.c_str(), temperature, sizeof(temperature)); |
|
|
|
|
|
mqtt.publish(topic_humidity.c_str(), humidity, sizeof(humidity)); |
|
|
|
|
|
mqtt.publish(topic_pressure.c_str(), pressure, sizeof(pressure)); |
|
|
} |
|
|
} |
|
|
/*
|
|
|
/*
|
|
|
unsigned long endTime = bme.beginReading(); |
|
|
unsigned long endTime = bme.beginReading(); |
|
|