Skip to content
All articles
Embedded Systems

Building Low-Cost IoT Telemetry Nodes with ESP32 & MQTT

Sep 18, 2026
6 min read
IoTESP32MQTTTelemetryFirmwareFreeRTOS
ShareXLinkedIn
ESP32-S3 · MQTT-62dBm
telemetry/node_01/sensors
{ temp: 26.4°C, v_bat: 3.92V }

Deploying remote microcontroller sensor nodes in industrial or domestic environments with intermittent Wi-Fi connectivity requires deliberate firmware architecture that separates high-frequency ADC sampling from asynchronous network dispatch.

#1. Overcoming ESP32 SAR ADC Non-Linearities

The ESP32 built-in 12-bit SAR ADC is notoriously non-linear, exhibiting dead-bands below 120mV and severe saturation above 2.45V even at 11dB attenuation. By combining calibrated hardware attenuators with a 12-point piecewise polynomial lookup table (LUT) and a 32-sample moving average filter, sensor voltage conversions achieve a ±2.4% error margin relative to a reference 6.5-digit multimeter.

Never poll analogRead() directly inside your network loop. Run cycle-accurate ADC sampling on FreeRTOS Core 0 and delegate Wi-Fi stack operations to Core 1.

#2. FreeRTOS Task Architecture & Ring Buffering

To eliminate telemetry dropouts during network latency spikes or router reconnects, sensor readings are pushed into a 128-slot circular FIFO ring buffer in RAM. A separate telemetry dispatcher task drains the queue over an authenticated MQTT TLS connection with exponential reconnection backoff.

  • Core 0 timer interrupt: 3.2 kS/s True RMS AC current sampling over 20ms mains periods
  • Core 1 network daemon: JSON serialization and MQTT QoS 1 payload publication
  • Hardware brownout protection: 470µF low-ESR bulk capacitor across 3.3V rail to sink Wi-Fi RF TX current bursts (up to 240mA peak)
  • Deep sleep optimization: 18.2 µA baseline quiescent current draw with ULP RTC timer wake-up
ShareXLinkedIn