diff --git a/examples/demo-relay-contact-nodes.cpp b/examples/demo-relay-contact-nodes.cpp index d2c9438..d4f93ec 100644 --- a/examples/demo-relay-contact-nodes.cpp +++ b/examples/demo-relay-contact-nodes.cpp @@ -84,10 +84,12 @@ void setup() << endl; // Set callback for contact node here, just to show alternative - contactNode.onChange([](bool open) - { - // Pass 0 in timeout for infinite "on" - relay1.setRelay(open, 0); }); + contactNode.onChange( + [](bool open) + { + // Pass 0 in timeout for infinite "on" + relay1.setRelay(open, 0); + }); // Set default configuration values before Homie.setup() relay1.beforeHomieSetup(); diff --git a/platformio.ini b/platformio.ini index 14a5aea..5cba083 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,13 +17,13 @@ serial_speed = 74880 display = DISPLAY_SERIAL [env] -platform = espressif8266 +platform = espressif8266@4.1.0 ; July 2023: newer expressif platform versions cause a linker error. framework = arduino build_flags = -D ${defines.display} -D SERIAL_SPEED=${defines.serial_speed} ; (Un)comment the libraries that you do (not) have installed in your global library storage. lib_deps = - ; User homie directly, because the official release is not compatible with ESP8266 3.x - https://github.com/homieiot/homie-esp8266.git + ; Use homie directly, because the official release is not compatible with ESP8266 3.x + https://github.com/luebbe/homie-esp8266.git ; Homie Adafruit BusIO Adafruit Unified Sensor @@ -47,5 +47,11 @@ upload_speed = 230400 [env:d1_mini] board = d1_mini -; upload_port = 192.168.0.58 +upload_speed = 460800 ;230400 +; upload_port = 192.168.0.99 ; upload_protocol = espota + +; [env:esp_adc] +; board = esp12e +; #512 kb for ESP-ADC (in-circuit) +; build_flags = ${env.build_flags} -Wl,-Tesp8266.flash.512k64.ld -D HOMIE_MDNS=0 -D HOMIE_CONFIG=0 diff --git a/src/BME280Node.cpp b/src/BME280Node.cpp index 74a2af0..cf24d4f 100644 --- a/src/BME280Node.cpp +++ b/src/BME280Node.cpp @@ -82,15 +82,22 @@ void BME280Node::send() void BME280Node::takeMeasurement() { - bme.takeForcedMeasurement(); // has no effect in normal mode - - temperature = bme.readTemperature(); - humidity = bme.readHumidity(); - pressure = bme.readPressure() / 100; + // has no effect in normal mode + if (bme.takeForcedMeasurement()) + { + temperature = bme.readTemperature(); + humidity = bme.readHumidity(); + pressure = bme.readPressure() / 100; - fixRange(&temperature, cMinTemp, cMaxTemp); - fixRange(&humidity, cMinHumid, cMaxHumid); - fixRange(&pressure, cMinPress, cMaxPress); + fixRange(&temperature, cMinTemp, cMaxTemp); + fixRange(&humidity, cMinHumid, cMaxHumid); + fixRange(&pressure, cMinPress, cMaxPress); + } + else + { + printCaption(); + Homie.getLogger() << cIndent << F("Failed to take measurement") << endl; + } } void BME280Node::beforeHomieSetup() @@ -114,7 +121,7 @@ void BME280Node::setup() if (bme.begin(_i2cAddress)) { _sensorFound = true; - Homie.getLogger() << cIndent << F("found. Reading interval: ") << readInterval() << " ms" << endl; + Homie.getLogger() << cIndent << F("found. Reading interval: ") << readInterval() << F(" ms") << endl; // Parameters taken from the weather station monitoring example (advancedsettings.ino) in // the Adafruit BME280 library bme.setSampling(Adafruit_BME280::MODE_FORCED, _tempSampling, _pressSampling, _humSampling, _filter);