HomeEngineering Projects For YouIoT Device Health Monitoring Over MQTT

IoT Device Health Monitoring Over MQTT

efy-tested-1

IoT devices are widely used to monitor and control physical systems such as lights, fans, motors, and industrial equipment. This system extends that capability by monitoring the health and operational status of the IoT device itself using the ESP32-C3 Super Mini. The ESP32-C3 continuously monitors key parameters, including CPU usage, RAM utilisation, Wi-Fi signal strength (RSSI), chip temperature, flash memory usage, reset reason, device uptime, and Wi-Fi channel. These telemetry values are periodically published to a public MQTT broker for real-time visualisation on a smartphone dashboard. Bidirectional MQTT communication also enables remote control of the onboard LED and software resets. The system provides a practical, low-cost solution for remote diagnostics, preventive maintenance, and performance monitoring of embedded IoT devices.

As IoT deployments continue to grow, remote health monitoring has become increasingly important. Continuous telemetry helps identify issues such as memory leaks, poor network connectivity, overheating, and unexpected resets before they result in device failure. This improves system reliability while reducing maintenance effort.

With built-in Wi-Fi, low power consumption, and adequate processing capability, the ESP32-C3 Super Mini is well-suited for a compact health monitoring node. Combined with the lightweight MQTT protocol, it provides an efficient and scalable solution for real-time IoT device monitoring and remote management. Fig. 1 shows the ESP32-C3 IoT device health monitoring system, while the components required to build the system are listed in Table 1.

Fig. 1: Authors’ prototype setup for IoT device health monitoring
Table 1: Bill of Materials
ComponentQuantity
ESP32-C3 super mini1
USB Type-C cable1
Breadboard (optional)1
Jumper wiresAs required
LED (onboard LED may be used)1
Wi-Fi-enabled smartphone1
Laptop/PC for programming1

MQTT broker configuration

This system uses the Switchsys public MQTT broker, a free MQTT broker suitable for learning, testing, and IoT prototyping. It supports standard MQTT clients over TCP on port 1883 and does not require user authentication.

Switchsys MQTT broker details:

Broker URL

Port: 1883 (TCP, non-TLS)

Table 2 shows the MQTT topic structure used in this system for communication between the ESP32-C3 Super Mini and the IoT MQTT Panel application.

Table 2: MQTT topic structure
Message DescriptionMQTT TopicPublished BySubscribed By
Telemetryesp32c3/telemetryESP32-C3 super miniIoT MQTT panel app
LED controlEsp32c3/led/controlIoT MQTT panel appESP32-C3 super mini
LED statusEsp32c3/led/statusESP32-C3 super miniIoT MQTT panel app
Remote resetEsp32c3/resetIoT MQTT panel appESP32-C3 super mini
Formatted uptimeEsp32c3/uptimeESP32-C3 super miniIoT MQTT panel app
EFY note. Since this system uses a public MQTT broker, MQTT topic name conflicts may occur. To avoid collisions, append initials, a system identifier, or another unique suffix to each MQTT topic.

Example of a telemetry payload.

{

“cpu_usage”: 21.4,

“ram_usage”: 34.7,

“rssi”: -56,

“chip_temperature”: 45.8,

“last_reset_reason”: “POWER_ON”,

“wifi_channel”: 1,

“flash_usage”: 23.56

}

Working with the Switchsys MQTT broker

The ESP32-C3 Super Mini connects to the local Wi-Fi network and establishes an MQTT session with the Switchsys public MQTT broker. Once connected, the device periodically publishes health and system telemetry while subscribing to MQTT topics for remote control commands.

Telemetry published by the ESP32-C3 super mini

  • CPU usage (%)
  • RAM usage (%)
  • Wi-Fi signal strength (RSSI in dBm)
  • Chip temperature (°C)
  • Flash memory usage (%)
  • Reset reason
  • Wi-Fi channel (CHx)
  • Device uptime (Days:Hours:Minutes:Seconds)
  • Remote LED status

Control commands subscribed by the ESP32-C3 super mini

  • Remote LED control (on/off)
  • Remote ESP32 reset

Software configuration

Before uploading the program to the ESP32-C3 Super Mini, update the following parameters in the source code:

  • Wi-Fi SSID and password. Replace these with the credentials of the local Wi-Fi network.
  • MQTT topic names (optional). Modify the topic names if required. When using a public MQTT broker, unique topic names are recommended to prevent conflicts with topics used by other users. Appending initials, a system identifier, or another unique suffix to each topic helps avoid naming collisions.

In this system, the code is configured to publish telemetry data, LED status, and uptime information to the MQTT broker while subscribing to topics for remote LED control and device reset commands. Fig. 2 shows the Wi-Fi credentials and MQTT topic configuration defined in the ESP32-C3 source code.

Fig. 2: Wi-Fi credentials and MQTT topic configuration in the ESP32-C3 source code

CPU usage (%)

CPU usage indicates the percentage of the ESP32-C3 Super Mini’s processing capacity currently being used by running tasks. The ESP32 operates on the FreeRTOS real-time operating system (RTOS), which manages multiple tasks simultaneously.

CPU utilisation is determined by measuring the processor’s idle time. Whenever no application tasks are running, the FreeRTOS idle task executes. By monitoring the runtime of the idle task, the system estimates the percentage of time the processor is idle. The getCpuUsage() function retrieves the FreeRTOS runtime statistics, identifies the idle task, determines its idle percentage, and calculates CPU usage using the following equation:

CPU usage (%)=100−Idle Time (%)

Fig. 3 shows the getCpuUsage() function used to calculate ESP32-C3 CPU usage from the FreeRTOS idle task runtime statistics.

Fig. 3: Function to calculate CPU usage by measuring the ESP32-C3 idle task runtime

RAM usage (%)

EFY Icon

EFY++ CONTENT: ACCESS TO THIS CONTENT IS FREE! BUT YOU NEED TO BE A REGISTERED USER.

Oops! This is an EFY++ article, which means it's our Premium Content. You need to be a Registered User of our website to read its complete content.

Good News: You can register to our website for FREE! REGISTER NOW

Already a registered member? If YES, then simply login to you account below. (TIP: Use 'forgot password' feature and reset and save your new password in your browser, if you forgot the last one!)

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics