From 3c6e2e532bd8be555ac52c4fd8c43da3cfd811e7 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 8 Aug 2019 00:49:41 +0200 Subject: [PATCH] wifi signal strength --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 8dbae1f..cd0d4c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,7 @@ struct __attribute__((packed)) sensor_readings_t { float temperature_max = NAN; // °C float temperature_min = NAN; // °C int battery = 0; + int8_t rssi = 0; uint32_t lastUpdate = 0; } sensor_readings; @@ -208,6 +209,7 @@ void getSensorMeasurements() { } sensor_readings.battery = analogRead(_VBAT); + sensor_readings.rssi = WiFi.RSSI(); sensor_readings.lastUpdate = millis(); } @@ -488,6 +490,7 @@ void printValues() { Serial.println(sensor_readings.pm10); } + Serial.print("RSSI: "); Serial.println(sensor_readings.rssi); Serial.print("Battery: "); Serial.println(sensor_readings.battery); Serial.print("Free HEAP: "); Serial.println(ESP.getFreeHeap()); @@ -550,6 +553,12 @@ void sendValues() { delay(10); } + { + String topic_rssi = String("thomas/sensor/") + ota.getMAC() + String("/rssi"); + mqtt.publish(topic_rssi.c_str(), sensor_readings.rssi, "%d"); + delay(10); + } + } /**