Added custom Mqtt topic for temp/hum sensor
This commit is contained in:
@@ -28,3 +28,9 @@ IPAddress dns(1,1,1,1);
|
|||||||
#define CONFIG_MQTT_IDX_Temp <TEMPidx>
|
#define CONFIG_MQTT_IDX_Temp <TEMPidx>
|
||||||
//IDX for virtual Humidity sensor
|
//IDX for virtual Humidity sensor
|
||||||
#define CONFIG_MQTT_IDX_Hum <HUMidx>
|
#define CONFIG_MQTT_IDX_Hum <HUMidx>
|
||||||
|
|
||||||
|
|
||||||
|
//Temprature Custom Mqtt topic
|
||||||
|
#define CONFIG_MQTT_Temp_TOPIC "EST-C/<SensorName>/Temp"
|
||||||
|
//Humidity Custom Mqtt topi
|
||||||
|
#define CONFIG_MQTT_Hum_TOPIC "EST-C/<SensorName>/Temp"
|
||||||
@@ -26,6 +26,10 @@ const int idxcomb = CONFIG_MQTT_IDX_Comb;
|
|||||||
const int idxtemp = CONFIG_MQTT_IDX_Temp;
|
const int idxtemp = CONFIG_MQTT_IDX_Temp;
|
||||||
const int idxhum = CONFIG_MQTT_IDX_Hum;
|
const int idxhum = CONFIG_MQTT_IDX_Hum;
|
||||||
|
|
||||||
|
//CustomMqtt
|
||||||
|
const char* custom_temperature_topic = CONFIG_MQTT_Temp_TOPIC;
|
||||||
|
const char* custom_humidity_topic = CONFIG_MQTT_Hum_TOPIC ;
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
PubSubClient client(espClient);
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
@@ -159,6 +163,9 @@ void loop()
|
|||||||
}
|
}
|
||||||
client.publish(domotopic, buffer2);
|
client.publish(domotopic, buffer2);
|
||||||
client.publish(domotopic, buffer3);
|
client.publish(domotopic, buffer3);
|
||||||
|
//Custom Mqtt
|
||||||
|
client.publish(custom_temperature_topic, String(cTemp).c_str(), true);
|
||||||
|
client.publish(custom_humidity_topic, String(CalcHumidity).c_str(), true);
|
||||||
client.loop();
|
client.loop();
|
||||||
delay(60000); //1min
|
delay(60000); //1min
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user