diff --git a/WifiControlSensor/MQTT.ino b/WifiControlSensor/MQTT.ino index a6a4fe8..146a66a 100644 --- a/WifiControlSensor/MQTT.ino +++ b/WifiControlSensor/MQTT.ino @@ -26,6 +26,10 @@ int setupMQTT(char *server, char *user, char *passwd, int port) { return 0; } +int MQTT_isConnected(){ + return mqtt->connected(); +} + // Function to connect and reconnect as necessary to the MQTT server. // Should be called in the loop function and it will take care if connecting. int MQTT_connect() { diff --git a/WifiControlSensor/WebServer.ino b/WifiControlSensor/WebServer.ino index 57fce3a..6a6c84f 100644 --- a/WifiControlSensor/WebServer.ino +++ b/WifiControlSensor/WebServer.ino @@ -1,6 +1,7 @@ void handleRoot() { server.send(200, "text/html", "

You are connected


" "Current temperature " + String(temp, 2) + "C
" + "MQTT Status :" + (MQTT_isConnected()? "Connected":"Disconnected") +"
" "Setup
" "OTA mode
" "ON
" diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index 67acc21..d7bcb5f 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -70,6 +70,7 @@ int getTemperature(double &t); /* MQTT decl */ int MQTT_connect(); +int MQTT_isConnected(); int setupMQTT(char *server, char *user, char *passwd, int port); int publishMQTT(int temp);