Added support for reporting for freeHeap via MQTT.

This commit is contained in:
Fabian Schlenz 2019-05-30 13:09:38 +02:00
parent b6d59758d8
commit 5321409727
3 changed files with 16 additions and 0 deletions

View File

@ -12,4 +12,6 @@ void mqtt_setup();
void mqtt_loop();
void mqtt_publish(const char* topic, int number);
#endif // mqtt_H

View File

@ -69,3 +69,11 @@ void mqtt_loop() {
mqtt_client.loop();
}
}
void mqtt_publish(const char* topic, int number) {
char t[127];
sprintf(t, MQTT_TOPIC "%s", topic);
char b[32];
sprintf(b, "%d", number);
mqtt_client.publish(t, b);
}

View File

@ -68,6 +68,12 @@ void loop() {
FastLED.show();
}
EVERY_N_SECONDS(5) {
if (REPORT_FREE_HEAP) {
mqtt_publish("free_heap", ESP.getFreeHeap());
}
}
if (MONITOR_LOOP_TIMES && millis()-loop_started_at>=MONITOR_LOOP_TIME_THRESHOLD) {
LOG("Core * Loop took "); LOG(millis()-loop_started_at); LOGln("ms.");