Skip to content
Tutorial
18 min read
October 17, 2026

Live DHT11 and BMP280 Dashboard with ESP32 and MQTT

Send DHT11 temperature/humidity and BMP280 temperature/pressure from an ESP32 to Node-RED over MQTT, validate JSON telemetry, and build a Dashboard 2.0 view with sensible ranges and clear stale-data status.

Live DHT11 and BMP280 Dashboard with ESP32 and MQTT

This project combines two sensors on an ESP32 and displays their measurements in Node-RED. The DHT11 supplies temperature and relative humidity. The BMP280 supplies barometric pressure and its own temperature reading; it does not measure humidity. Keeping the two temperature sources distinct prevents a misleading dashboard.

The data path is ESP32 firmware → MQTT broker → Node-RED validation and parsing → FlowFuse Dashboard widgets. Establish the broker connection first using Node-RED with MQTT, then add sensors and dashboard widgets. The code below uses commonly available Arduino libraries; record the actual library versions and test the sketch on your own wiring before treating its readings as validated measurements.

Image pending: Image placeholder: full architecture showing ESP32 with DHT11 and BMP280 → MQTT broker → Node-RED MQTT In → JSON parsing/validation → Dashboard 2.0 gauges and chart.

Hardware, wiring and libraries

You need an ESP32 development board, a DHT11 sensor/module, a BMP280 breakout, jumper wires, an MQTT broker and Node-RED with FlowFuse Dashboard installed.

For the example, the DHT11 DATA pin is connected to GPIO 4; the BMP280 uses I2C on SDA GPIO 21 and SCL GPIO 22. These are example assignments for a typical ESP32 DevKit, not universal board requirements. Check your board pinout and breakout documentation. Some modules have regulators or level shifting; do not infer a breakout's voltage tolerance solely from the sensor-chip name.

Install these Arduino libraries: DHTesp, Adafruit BMP280 Library, Adafruit Unified Sensor (if requested by the library manager), and PubSubClient. This example assumes an ESP32 Arduino core and the stated library APIs. The MQTT connection here uses plain MQTT for a trusted local lab; use a suitable secure transport for untrusted networks.

Image pending: Image placeholder: wiring diagram for ESP32, DHT11 VCC/DATA/GND and BMP280 VIN/GND/SDA/SCL. Label GPIOs as examples and call out breakout voltage requirements.

1. Upload the ESP32 firmware

Replace the Wi-Fi and broker placeholders locally. The broker hostname must be reachable from the ESP32; 127.0.0.1 refers to the ESP32 itself, not the Raspberry Pi broker. The sketch sends one JSON record every five seconds, which is slow enough for a beginner monitoring example and respects the DHT11's update interval.

C++

The sample code illustrates the message path and failure handling; it has not been physically tested on your exact board. Review the API of the library versions installed on your machine before uploading. For a production device, add broker authentication/TLS appropriate to your network, exponential reconnect backoff, a unique ID per physical board, and better sensor retry logic. The sample intentionally skips publishing when a sensor returns invalid data instead of disguising a failed read as zero.

Image pending: Image placeholder: Arduino IDE code view showing the sensor read and JSON publish block, with all Wi-Fi credentials replaced by placeholders.

2. Build the Node-RED flow

Create a flow with these stages:

MQTT In → JSON → validation → Dashboard widgets

Configure MQTT In to subscribe to solderhub/lab/esp32-01/telemetry on the correct broker. Add a JSON node if incoming payload arrives as a string; inspect it in Debug because payload handling depends on node configuration and data type. Configure the dashboard and UI nodes using Node-RED Dashboard 2.0: Install Buttons, Switches and Gauges.

Before forwarding values to gauges, check that the payload is an object and each expected property is a finite number. If the incoming MQTT message is malformed or a field is missing, send it to an error path and keep the last valid reading marked with its timestamp rather than resetting the gauge to zero.

Image pending: Image placeholder: Node-RED editor flow with MQTT In, JSON node, validation Function, four dashboard widgets and a Debug/error branch.

3. Build the dashboard

Use FlowFuse Dashboard, package @flowfuse/node-red-dashboard, for new dashboard work. The legacy node-red-dashboard package is deprecated. Create separate values for DHT11 temperature, DHT11 relative humidity, BMP280 pressure and BMP280 temperature. Label every widget with the sensor source and unit.

Use a gauge for the current value and a chart for trends. Set ranges to useful values for your test environment rather than implying sensor accuracy. Add a last-update timestamp or online/stale indicator: when MQTT stops, the old gauge value must not look live.

Image pending: Image placeholder: responsive Dashboard 2.0 page with separate DHT11 temperature, DHT11 humidity, BMP280 pressure and last-update status; show units in labels.

4. Keep units and sensor errors honest

DHT11 is a low-cost, relatively low-resolution sensor. Avoid displaying decimal places that imply precision it cannot deliver. BMP280 pressure readings depend on calibration, weather and altitude; do not present a simple pressure gauge as a weather forecast.

A device can stay online while one sensor fails. Track sensor read validity separately from MQTT connection status. If a value cannot be read, skip it or publish an explicit validity field in your schema. Never silently write 0 °C or 0% humidity to mean “no data.”

Image pending: Image placeholder: visual showing a valid sample, failed sensor read and stale retained dashboard value, with clear status labels.

Troubleshooting

No MQTT messages: verify topic, broker host and connection; test a simple publication from a command-line client.

JSON parse error: inspect the raw payload and confirm valid JSON, and whether the JSON node expects a string.

DHT read fails: recheck DATA wiring, supply and supported sampling interval; review library diagnostics.

BMP280 not detected: check I2C wiring, address (commonly 0x76 or 0x77) and breakout supply requirements.

Dashboard looks frozen: check arrival timestamps and Node-RED node status. A blank or old gauge is not proof of a zero sensor reading.

Image pending: Image placeholder: completed project photo showing ESP32, DHT11 and BMP280 breakouts with dashboard values and timestamps.

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.