Browse Source

display bme information on webpage + refacto

bme680
Mathieu Maret 2 years ago
parent
commit
5f5bd1b8ae
  1. 4
      WifiControlSensor/BMP180.ino
  2. 2
      WifiControlSensor/MQTT.ino
  3. 12
      WifiControlSensor/WebServer.ino

4
WifiControlSensor/BMP180.ino

@ -8,11 +8,9 @@ int BMP180Setup(int sda, int scl) {
bmp180Connected = bmp180.begin(sda, scl);
if (!bmp180Connected){
SKETCH_DEBUG_PRINTLN("Cannot connect to BMP180");
goto err;
return -1;
}
return 0;
err:
return -1;
}
bool BMP180IsConnected() {

2
WifiControlSensor/MQTT.ino

@ -87,7 +87,7 @@ int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...) {
va_start (args, tab);
vsnprintf(buf, sizeof(buf), (const char *)info.topic, args);
va_end(args);
SKETCH_DEBUG_PRINTF("publishing %f for %s\n", info.value, buf);
// SKETCH_DEBUG_PRINTF("publishing %f for %s\n", info.value, buf);
Adafruit_MQTT_Publish client(mqtt, buf, info.qos, info.retain);
if (!client.publish(info.value))
SKETCH_DEBUG_PRINTLN("Fail :(");

12
WifiControlSensor/WebServer.ino

@ -32,12 +32,13 @@ void WebHandleRoot() {
"<fieldset>"
"<legend>Sensors</legend>"
#ifdef CONFIG_ENABLE_BMP180
"Temperature " + String(temp, 2) + "C<br/>"
"Pressure " + String(pressure, 2) + "mB<br/>"
"" + (BMP180IsConnected() ? "<h6>BMP180</h6>Temperature " + String(temp, 2) + "C<br/> Pressure " + String(pressure, 2) + "hPa<br/>" : "BMP180 Disconnected" ) + ""
#endif
#ifdef CONFIG_ENABLE_DHT
"Temperature DHT " + String(dhtTemp, 0) + "C<br/>"
"Humidity DHT " + String(dhtHumidity, 0) + "%<br/>"
"" + (DHTIsConnected() ? "<h6>DHT</h6>Temperature " + String(dhtTemp, 0) + "C<br/> Humidity " + String(dhtHumidity, 0) + "%<br/>" : "DHT Disconnected" ) + ""
#endif
#ifdef CONFIG_ENABLE_BME680
"" + (BME680IsConnected() ? "<h6>BME680</h6>Temperature " + String(bme680T, 2) + "C<br/> Pressure " + String(bme680P, 2) + "hPa<br/> Humidity " + String(bme680H, 2) + "%<br/> Gaz " + String(bme680G, 2) + "kOhm<br/>" : "BME680 Disconnected" ) + ""
#endif
#ifdef CONFIG_ENABLE_DRY_SENSOR
"Dryness " + String((dryness * 100) / 1024) + "%<br/>"
@ -47,9 +48,6 @@ void WebHandleRoot() {
"<a href=\"/setup\">Enter Setup</a><br/>"
"<a href=\"/upload\">Update firmware</a><br/>" + optimiseConfig +
"MQTT Status: " + (MqttIsConnected() ? "Connected" : "Disconnected") + "<br/>"
#ifdef CONFIG_ENABLE_BMP180
"BMP 180 (Temp+Pression) Status: " + (BMP180IsConnected() ? "Connected" : "Disconnected") + "<br/>"
#endif
"Wifi Strength: " + WiFi.RSSI() + "dBm<br/>"
"Free space: " + ESP.getFreeSketchSpace() + "<br/>"
"Free heap: " + ESP.getFreeHeap() + "<br/>"

Loading…
Cancel
Save