In response to the need for efficient and scalable temperature and current monitoring, we would like to propose a custom-built solution. Instead of relying on commercial systems—which often have limited flexibility or are constrained by cloud-based restrictions—we suggest implementing a local setup based on ESP32 modules running Tasmota firmware.
Sensor data will be transmitted via MQTT to a backend composed of Docker containers. This backend includes InfluxDB for time-series data storage and Grafana for visualization. The setup allows for flexible, real-time data logging and monitoring within the local network, without depending on external platforms. Additionally, it can be extended with current sensors, cameras, or other components, making it a solid foundation for future developments such as automated firmware testing environments.
- ESP32 + Tasmota: Microcontroller modules flashed with Tasmota firmware, responsible for collecting sensor data (e.g., temperature, current) and publishing it over MQTT.
- MQTT Broker: Acts as the central message hub, receiving sensor data from ESP32 devices and distributing it to subscribers (e.g., backend services).
- InfluxDB: A time-series database that stores incoming sensor data for historical analysis and visualization.
- Grafana: Visualization platform connected to InfluxDB, used to create dashboards and monitor sensor data in real time.
- Node-RED: Optional low-code platform for wiring together data flows, enabling custom automation, alerting, or integration with other systems.
flowchart LR
ESP32[Tasmota ESP32 Devices]
MQTT[MQTT Broker]
NodeRED[Node-RED]
InfluxDB[InfluxDB]
Grafana[Grafana]
ESP32 -- MQTT Publish --> MQTT
MQTT -- Data Subscription --> NodeRED
NodeRED -- Writes Data --> InfluxDB
MQTT -- Data Subscription --> InfluxDB
InfluxDB -- Data Source --> Grafana
Data Flow Description:
- Data Collection: ESP32 devices with Tasmota firmware read sensor values and publish them to the MQTT broker.
- Message Distribution: The MQTT broker receives sensor data and makes it available to subscribers (InfluxDB, Node-RED).
- Data Processing: Node-RED can process, filter, or transform incoming data and forward it to InfluxDB for storage.
- Storage: InfluxDB stores all time-series sensor data.
- Visualization: Grafana queries InfluxDB and presents the data in customizable dashboards for monitoring and analysis.
This architecture ensures modularity, scalability, and flexibility for future extensions.
- ESP32 Development Boards: Microcontroller modules for sensor integration and wireless communication.
- Temperature Sensors (e.g., DS18B20): Digital temperature sensors compatible with Tasmota.
- Current Sensors (e.g., ACS712): For measuring electrical current.
- Power Supply: Reliable 5V USB power adapters for ESP32 devices.
- Wiring and Connectors: Jumper wires, breadboards, or terminal blocks for prototyping and connections.
- Tasmota Firmware: Open-source firmware for ESP32, flashed onto each device.
- Docker: Containerization platform for backend services.
- Docker Compose: Tool for defining and running multi-container Docker applications.
- MQTT Broker: Such as Eclipse Mosquitto, for message handling.
- InfluxDB: Time-series database for sensor data storage.
- Grafana: Visualization and dashboard platform.
- Node-RED (optional): For data processing and automation.
- MQTT Client Tools: For testing and debugging (e.g., MQTT Explorer, mosquitto_sub).
- Web Browser: For accessing Grafana dashboards and Node-RED editor.
For the sensor component, we recommend a system based on Tasmota. Tasmota is open-source firmware for ESP microcontrollers, supporting a wide range of common sensors and actuators. Communication via MQTT works out-of-the-box, and the flexible configuration allows you to build various applications without writing your own firmware.
Tasmota supports almost every ESP32, ESP32-S2, ESP32-S3, and ESP32-C3 microcontroller or development board. You are free to choose within this ecosystem. See the list of supported devices at: https://templates.blakadder.com/esp32.html
Tasmota also supports the sensors you have already ordered:
Tasmota offers a web installer, allowing you to flash most devices with firmware directly from your browser, without installing extra software. Visit https://tasmota.github.io/install/ to install the firmware. Note: your browser must support this (Edge, Chrome, and other Chromium-based browsers usually do; Firefox and derivatives do not). If you prefer traditional flashing methods, you can use tools like ESP Flash Tool or ESP.py/ESP Tool (CLI based).
When the Tasmota device is connected to your computer via USB, after flashing the firmware you can configure it using various 'Commands'. For example, you can set MQTT settings or specify which sensor is connected to which pin. Working via UART/Command is often not very intuitive for first-time users, so it is recommended to use the graphical WebUI.
Through the WebUI, you can interactively view the device status and adjust its configuration.
MQTT is one of the main ways Tasmota sends data. You can set up the broker and configure how data is published via command or the web UI.
M5Stack offers ready-made microcontroller ecosystems with many expansion options. For this use case, the Atom and Core series are most suitable. The Atom series is very compact and affordable, while the Core series offers more functionality by default.
A good starting point is the M5Stack Atom development board. These are small, low-cost, and expandable. There are also various 'Base' boards that you can easily mount the Atom module on, adding extra functionality such as:
- Prototype board (ideal for mounting sensors like the DS1820)
- RS-232
- RS-485
- CAN-bus
- LoRaWAN
- PoE Ethernet
- SD card reader
- ...
If the Atom boards are too limited, you can also choose the larger Core series. These offer more IO, often a (touch) display, battery, SD card slot, and DIN-rail mounting by default. A recommended option is the M5Stack CoreS3 Development Kit. Keep in mind that the extra features also increase complexity—but you are not required to use all features.
Most components can be easily purchased from the Dutch webshop:
https://www.tinytronics.nl
- Download Tasmota:
Visit the Tasmota releases page and download the appropriate.binfirmware for ESP32. - Connect ESP32 to Computer:
Use a USB cable to connect your ESP32 development board. - Install Flashing Tool:
Use Tasmotizer or esphome-flasher to flash the firmware. - Flash the Firmware:
- Open the flashing tool.
- Select the downloaded
.binfile. - Choose the correct serial port.
- Click "Flash" and wait for completion.
After flashing, the ESP32 will start in Wi-Fi Access Point (AP) mode.
- Connect to Tasmota AP:
On your computer or phone, connect to the Wi-Fi network namedtasmota-xxxx. - Open Configuration Portal:
Navigate to192.168.4.1in your browser.
- Enter Wi-Fi Credentials:
In the portal, enter your local Wi-Fi SSID and password. - Save and Reboot:
The ESP32 will connect to your Wi-Fi network and display its new IP address.
- Access Tasmota Web UI:
Open the ESP32's IP address in your browser. - Navigate to Configuration > Configure MQTT.
- Enter MQTT Broker Details:
- Host: IP address or hostname of your MQTT broker.
- Port: Usually
1883. - User/Password: (If required by your broker.)
- Topic: Set a unique topic for each device (e.g.,
sensor/esp32_1).
- Save Settings:
The device will restart and attempt to connect to the MQTT broker.
- Check the Tasmota web UI for MQTT status.
- Use an MQTT client (e.g., MQTT Explorer) to confirm messages are published to the correct topic.
You can now proceed to integrate the ESP32 with the rest of your monitoring stack.
This section explains how to set up the backend services (MQTT broker, InfluxDB, Grafana, and Node-RED) using Docker Compose.
The following compose.yaml file defines all required services. It uses environment variables for configuration, which you can override in a .env file or directly in the file.
services:
influxdb:
image: influxdb:1.11
container_name: influxdb
restart: unless-stopped
ports:
- "8086:8086"
volumes:
- ./influxdb:/var/lib/influxdb
environment:
INFLUXDB_DB: ${INFLUXDB_DB:-mydb}
INFLUXDB_USER: ${INFLUXDB_USER:-myuser}
INFLUXDB_USER_PASSWORD: ${INFLUXDB_USER_PASSWORD:-mypassword}
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- grafana:/var/lib/grafana
environment:
GF_SECURITY_ADMIN_USER: ${GF_SECURITY_ADMIN_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GF_SECURITY_ADMIN_PASSWORD:-admin}
depends_on:
- influxdb
nodered:
image: nodered/node-red:latest
container_name: nodered
restart: unless-stopped
ports:
- "1880:1880"
volumes:
- ./nodered:/data
environment:
- NODE_RED_ENABLE_SAFE_MODE=true
- NODE_RED_ENABLE_PROJECTS=true
depends_on:
- influxdb
- grafana
mqtt:
image: eclipse-mosquitto:latest
container_name: mqtt
restart: unless-stopped
ports:
- "1883:1883"
- "9001:9001"
volumes:
- ./mqtt/config:/mosquitto/config
- ./mqtt/data:/mosquitto/data
- ./mqtt/log:/mosquitto/log
volumes:
influxdb:
grafana:
nodered:
mqtt:Note: You can customize usernames, passwords, and database names using environment variables or by editing the file directly.
-
Install Docker and Docker Compose
Make sure Docker and Docker Compose are installed on your system. -
Directory Structure
Organize your project directory as follows:project-root/ compose.yaml influxdb/ grafana/ nodered/ mqtt/ config/ data/ log/ -
(Optional) Configure Mosquitto
Place amosquitto.conffile inmqtt/config/if you need custom broker settings. -
Start the Services
In your project directory, run:docker compose up -d
This will pull images and start all containers in the background.
-
Access the Services
- MQTT Broker: Port
1883(MQTT),9001(WebSocket) - InfluxDB: http://localhost:8086
- Grafana: http://localhost:3000 (default user:
admin, password as set above) - Node-RED: http://localhost:1880
- MQTT Broker: Port
-
Stop the Stack
To stop all services, run:docker compose down
This setup provides a modular and reproducible backend for your sensor platform.
Tasmota-enabled ESP32 devices use MQTT to publish sensor data to a central broker, enabling real-time communication with backend services.
After configuring MQTT settings in the Tasmota web UI, each ESP32 device connects to the broker and publishes sensor readings at regular intervals. Tasmota uses a topic structure that can be customized per device.
By default, Tasmota uses the following topic format:
<tasmota_topic>/SENSOR
<tasmota_topic>: The unique topic name set in the device's MQTT configuration (e.g.,tele/tasmota_D4F148).
Example:
tele/tasmota_D4F148/SENSOR
Sensor data is published as a JSON payload. The structure depends on the sensors attached and their configuration. For a device with a DS18B20 temperature sensor, the payload might look like:
{
"Time": "2024-06-01T12:34:56",
"DS18B20": {
"Temperature": 23.5
},
"TempUnit": "C"
}If you have additional sensors (e.g., current sensors), their readings will appear as extra fields in the JSON.
Backend services (InfluxDB, Node-RED, etc.) subscribe to the relevant topics (e.g., tele/+/SENSOR) to receive updates from all devices.
- You can change the topic prefix in Tasmota's MQTT settings for each device.
- Use Node-RED or similar tools to parse, filter, and route incoming MQTT messages as needed.
Tip: Use an MQTT client (like MQTT Explorer) to inspect live messages and verify correct topic and payload formats.
Node-RED is an optional but powerful component in this sensor platform. It provides a visual, flow-based programming environment for wiring together devices, APIs, and online services. In this setup, Node-RED can be used to process, transform, and route MQTT sensor data, as well as trigger automations or alerts.
- Low-Code Data Processing: Easily parse and transform incoming MQTT messages using drag-and-drop nodes.
- Automation: Set up rules to trigger notifications, control devices, or log events based on sensor data.
- Integration: Connect with external APIs, databases, or other services for advanced workflows.
- Visualization: Create simple dashboards for quick data visualization within Node-RED.
- Filtering Data: Only forward temperature readings above a certain threshold to InfluxDB.
- Alerting: Send an email or push notification if a sensor value exceeds safe limits.
- Data Enrichment: Add timestamps, device metadata, or calculated fields before storing data.
A typical Node-RED flow for this platform might look like:
- MQTT In Node: Subscribes to topics like
sensor/+/SENSORto receive all sensor data. - JSON Node: Parses the incoming JSON payload.
- Function/Change Node: Processes or filters the data as needed.
- InfluxDB Out Node: Writes the processed data to InfluxDB for storage and visualization.
-
Access Node-RED:
Open http://localhost:1880 in your browser. -
Import Example Flow:
You can import example flows from the Node-RED library or create your own. -
Install Additional Nodes:
Use the "Manage palette" option to add nodes for InfluxDB, email, or other integrations as needed. -
Deploy Flows:
After designing your flow, click "Deploy" to activate it.
Node-RED adds flexibility and extensibility to your sensor platform, making it easy to adapt to new requirements or integrate with other systems.
This section describes how to configure InfluxDB for use with the project.
Note: InfluxDB v1 is used instead of v2 because it offers simpler integration with legacy MQTT sensor data pipelines and avoids the additional complexity of authentication and API changes introduced in v2.
This section explains how to set up InfluxDB for your sensor platform, including database creation, authentication, and optional retention policies.
Once the InfluxDB container is running, you need to create a database for storing sensor data.
- Access the InfluxDB shell
Run the following command to open the InfluxDB CLI inside the container:docker exec -it influxdb influx - Create a database
In the InfluxDB shell, run:ReplaceCREATE DATABASE mydb
mydbwith your preferred database name.
By default, InfluxDB may run without authentication. To enable authentication:
- Set environment variables in
compose.yaml:environment: INFLUXDB_HTTP_AUTH_ENABLED: "true" INFLUXDB_ADMIN_USER: admin INFLUXDB_ADMIN_PASSWORD: strongpassword
- Restart the InfluxDB container
docker compose restart influxdb
- Create additional users (optional):
In the InfluxDB shell:
CREATE USER myuser WITH PASSWORD 'mypassword' GRANT ALL ON mydb TO myuser
Retention policies control how long data is kept in the database.
- Create a retention policy (e.g., keep data for 30 days):
CREATE RETENTION POLICY "thirty_days" ON "mydb" DURATION 30d REPLICATION 1 DEFAULT
- Verify retention policies:
SHOW RETENTION POLICIES ON mydb
- Use the database name, username, and password (if enabled) in your Node-RED and Grafana configurations.
- The default InfluxDB HTTP API endpoint is
http://localhost:8086.
Tip: Always back up your InfluxDB data directory (./influxdb/) regularly.
For more details, see the InfluxDB documentation.
Grafana provides powerful, customizable dashboards for visualizing sensor data stored in InfluxDB. This section explains how to connect Grafana to InfluxDB, create example dashboards, and manage dashboard imports/exports.
-
Access Grafana:
Open http://localhost:3000 in your browser. Log in with the default credentials (admin/ password set in yourcompose.yaml). -
Add InfluxDB as a Data Source:
- In the left sidebar, click Gear (⚙️) > Data Sources.
- Click Add data source and select InfluxDB.
- Set the following fields:
- URL:
http://influxdb:8086(if using Docker Compose; otherwise, usehttp://localhost:8086) - Database: Name of your InfluxDB database (e.g.,
mydb) - User/Password: As configured in InfluxDB (if authentication is enabled)
- URL:
- Click Save & Test to verify the connection.
To visualize sensor data (e.g., temperature readings):
-
Create a New Dashboard:
- Click + > Dashboard in the sidebar.
- Click Add new panel.
-
Configure the Panel Query:
- Select your InfluxDB data source.
- Enter a query, for example:
Adjust the measurement and field names to match your sensor data.
SELECT mean("Temperature") FROM "DS18B20" WHERE $timeFilter GROUP BY time($__interval) fill(null)
-
Customize Visualization:
- Choose a visualization type (e.g., Time series, Gauge).
- Set panel titles, units (e.g., Celsius), and other options.
-
Save the Dashboard:
- Click Save dashboard, give it a name, and optionally add a description.
-
Export a Dashboard:
- Open the dashboard, click the Dashboard settings (gear icon), then JSON Model.
- Click Export to download the dashboard JSON.
-
Import a Dashboard:
- In the sidebar, click + > Import.
- Upload a dashboard JSON file or paste its contents.
- Select the appropriate data source and click Import.
Tip: You can find ready-made dashboard templates for Tasmota, InfluxDB, and MQTT devices on Grafana's dashboard library.
With Grafana connected to InfluxDB, you can build real-time dashboards to monitor all your sensor data, set up alerts, and share insights with your team.
This section explains how to verify that your sensor platform is working correctly, how to check data flow through each component, and provides troubleshooting tips for common issues.
- Using MQTT Explorer or mosquitto_sub:
- Connect to your MQTT broker (default:
localhost:1883). - Subscribe to the relevant topic, e.g.:
mosquitto_sub -h localhost -t "sensor/+/SENSOR" - You should see JSON payloads from your ESP32 devices.
- Connect to your MQTT broker (default:
- Via InfluxDB CLI:
- Enter the InfluxDB shell:
docker exec -it influxdb influx - Query recent data:
USE mydb SELECT * FROM DS18B20 ORDER BY time DESC LIMIT 5
- Replace
DS18B20with your measurement name.
- Enter the InfluxDB shell:
- Open http://localhost:3000 in your browser.
- Check your dashboard panels for live or recent sensor data.
- If no data appears, verify your data source and query settings.
- Open http://localhost:1880.
- Use debug nodes to inspect incoming MQTT messages and processed outputs.
- Ensure flows are deployed and connected to the correct topics and database.
| Issue | Possible Cause | Solution |
|---|---|---|
| No MQTT messages received | ESP32 not connected, wrong broker address, Wi-Fi issues | Check ESP32 Wi-Fi and MQTT settings, verify broker is running |
| Data not appearing in InfluxDB | Node-RED flow misconfigured, wrong database/measurement | Check Node-RED logs, verify InfluxDB credentials and flow configuration |
| Grafana shows no data | Data source misconfigured, wrong query, InfluxDB not running | Check Grafana data source settings, ensure InfluxDB is up, review query syntax |
| ESP32 not connecting to Wi-Fi | Incorrect SSID/password, weak signal | Re-enter credentials, move device closer to router |
| MQTT broker fails to start | Port conflict, config error | Check Docker logs, ensure ports 1883/9001 are free, review mosquitto.conf |
Tips:
- Use container logs for debugging:
docker logs <container_name>
- Restart containers after configuration changes.
- Use MQTT clients to inspect live traffic and verify topic structure.
By following these steps, you can ensure your sensor platform is operating correctly and quickly resolve common issues.
To deepen your understanding of the technologies and architecture described in this document, the following resources provide comprehensive background, tutorials, and best practices:
-
IoT Architectures and MQTT
- MQTT Essentials – A series explaining MQTT protocol fundamentals.
- Introduction to IoT – IBM’s overview of IoT concepts and architectures.
-
Time-Series Data and Visualization
- InfluxDB Documentation – Official docs for InfluxDB, covering time-series storage and queries.
- Grafana Documentation – Guides on building dashboards and visualizing data.
-
ESP32 and Tasmota
- Tasmota Documentation – Official docs for configuring and using Tasmota firmware.
- ESP32 Overview – Espressif’s official ESP32 documentation.
-
Docker and Docker Compose
- Docker Documentation – Guides for containerization and orchestration.
- Docker Compose Overview – How to define and run multi-container applications.
-
Node-RED
- Node-RED Documentation – Tutorials and reference for flow-based programming.
- Building an IoT Sensor Network with MQTT, InfluxDB, and Grafana – Step-by-step guide for a similar stack.
- Home Automation with Tasmota, MQTT, and Node-RED – Practical examples and flows.
- Securing MQTT – How to secure your MQTT broker and communication.
- InfluxDB Security Best Practices – Recommendations for securing your database.
These resources will help you understand the rationale behind each component, how they interact, and how to extend or secure your own sensor platform.