Building an Enterprise IoT Weather Station with EMQX, InfluxDB v3, and Grafana on a VPS
Introduction: The Architecture of Modern IoT Monitoring
In the era of data-driven decision-making, real-time environmental monitoring has become a cornerstone for industries ranging from agriculture to smart city management. However, moving from a hobbyist prototype to a resilient, enterprise-grade Internet of Things (IoT) architecture requires infrastructure that can handle continuous data ingestion, guarantee low-latency messaging, and provide high-performance time-series storage. This guide provides a comprehensive blueprint for deploying a robust, self-hosted weather monitoring system and IoT dashboard. By leveraging EMQX MQTT Broker for message orchestration and InfluxDB v3 for cutting-edge time-series storage on a Virtual Private Server (VPS), you can establish a foundation capable of handling thousands of data points per second with minimal resource overhead.
The Core Tech Stack Breakdown
To understand why this specific stack is optimal for business-critical IoT applications, we must look at the unique strengths of each component:
- EMQX MQTT Broker: As the world's most scalable open-source MQTT broker, EMQX can handle millions of concurrent connections. It features a built-in SQL-based rule engine that allows you to transform and route data natively without writing external glue code.
- InfluxDB v3: The latest evolution in time-series databases, InfluxDB v3 is rebuilt in Rust and Apache Arrow. It delivers significantly improved compression, faster analytical queries, and seamless handling of high-cardinality data compared to its predecessors.
- Grafana: The industry standard for visualization, Grafana connects seamlessly to InfluxDB, turning raw telemetry into actionable, executive-ready dashboards.
- VPS Deployment: Hosting this stack on a managed VPS (such as DigitalOcean, Linode, or AWS EC2) ensures complete data ownership, fixed predictable costs, and dedicated resources.
Architecture Blueprint
Before diving into the configuration, it is essential to visualize how data flows through the pipeline:
Edge Sensors (Hardware) → Publish MQTT Packets → EMQX Broker (VPS) → Rule Engine → InfluxDB v3 (Time-Series) → Query Processing → Grafana Dashboard
Step 1: Setting Up the VPS and Installing EMQX
First, ensure your VPS is running a clean installation of Ubuntu 22.04 or 24.04 LTS. Update your package manager and secure your firewall to allow ports 1883 (MQTT), 8083 (EMQX Dashboard), 8086 (InfluxDB API), and 3000 (Grafana). The most efficient way to manage this stack is via Docker Compose, which ensures consistency and simplifies future upgrades.
Creating the Environment
Connect to your VPS via SSH and create a dedicated project directory:
mkdir -p ~/iot-stack && cd ~/iot-stackNext, construct your configuration file. Below is an optimized Docker Compose template containing EMQX, InfluxDB v3, and Grafana:
version: '3.8'
services:
emqx:
image: emqx/emqx:5.6.0
container_name: emqx
ports:
- "1883:1883"
- "8083:8083"
- "18083:18083"
volumes:
- emqx_data:/opt/emqx/data
- emqx_log:/opt/emqx/log
environment:
- EMQX_DASHBOARD__ADMIN__PASSWORD=YourSecurePassword
influxdb:
image: influxdb:3.0
container_name: influxdb
ports:
- "8086:8086"
volumes:
- influxdb_data:/var/lib/influxdb2
environment:
- INFLUXD_TLS_CERT=/etc/ssl/influxdb.crt
grafana:
image: grafana/grafana-oss:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
depends_on:
- influxdb
volumes:
emqx_data:
emqx_log:
influxdb_data:
grafana_data:Launch the stack using the command: docker compose up -d. Verify that all containers are running optimally by checking their status via docker compose ps.
Step 2: Configuring InfluxDB v3 and EMQX Integration
With the infrastructure active, access the InfluxDB management console or use the CLI to generate your organization tokens and create a new database explicitly optimized for weather telemetry, naming it weather_monitoring.
Leveraging the EMQX Data Integration Rule Engine
One of EMQX’s greatest advantages is its ability to bypass intermediary backend scripts to write data directly to your database. This minimizes latency and reduces points of failure.
- Navigate to the EMQX Dashboard at
http://your-vps-ip:18083and log in. - Go to Integration > Rules and select "Create".
- Define the SQL trigger rule to parse your incoming weather payloads. For a JSON-formatted sensor payload, use the following SQL structure:
SELECT
payload.device_id AS clientid,
payload.temperature AS temp,
payload.humidity AS humid,
payload.pressure AS baro
FROM
"weather/+/telemetry"This rule actively listens on the wildcard topic weather/+/telemetry, extracting temperature, humidity, and barometric pressure while preserving the unique device identifier.
Setting Up the InfluxDB Action
Beneath your rule, add an Action. Select InfluxDB as the target sink. Input your VPS host address, your generated authentication token, and map the incoming fields into an InfluxDB measurement called weather_metrics. Tag the incoming data by clientid to prevent high cardinality performance degradation while ensuring rapid lookups.
Step 3: Simulating and Validating Hardware Telemetry
Before deploying structural physical hardware like an ESP32 or Raspberry Pi to the field, it is highly recommended to validate your data pipelines using a programmatic script. Below is a production-ready Python simulation using the paho-mqtt library to stream simulated environmental shifts to your VPS:
import time
import json
import random
import paho.mqtt.client as mqtt
BROKER_HOST = "your-vps-ip"
PORT = 1883
TOPIC = "weather/station_01/telemetry"
client = mqtt.Client()
client.connect(BROKER_HOST, PORT, 60)
print("Streaming live telemetry to VPS...")
while True:
payload = {
"device_id": "station_01",
"temperature": round(random.uniform(22.0, 35.0), 2),
"humidity": round(random.uniform(45.0, 85.0), 1),
"pressure": round(random.uniform(1008.0, 1014.0), 1)
}
client.publish(TOPIC, json.dumps(payload))
time.sleep(5)Execute this script. Check the EMQX dashboard metrics page to verify that packets are hitting the broker and successfully triggering the rule engine pipeline into InfluxDB v3.
Step 4: Building the IoT Dashboard in Grafana
With data successfully populating InfluxDB v3, you can now build a professional dashboard to monitor the telemetry visually.
Connecting the Data Source
Open Grafana by navigating to http://your-vps-ip:3000. Log in using the default admin credentials and proceed to Connections > Data Sources. Choose InfluxDB. Since InfluxDB v3 deeply integrates with SQL and Flight SQL queries alongside traditional Flux, you can configure it using standard enterprise SQL plugins or the native Influx provider, mapping your database bucket credentials securely.
Creating Visual Panels
Create a new dashboard and construct panels for each critical environmental variable:
- Temperature Trend: Add a Time Series graph mapping historical shifts, applying a gradient color scheme (blue to red) to represent thermal changes.
- Humidity Levels: Use a Gauge panel configured with safety thresholds (e.g., green for optimal, orange for humid, red for critical moisture).
- System Health: Add a Stat panel tracking the frequency of data points transmitted by the
clientidtag, acting as an automated heartbeat indicator.
Conclusion: A Foundation for Industrial Scaling
By bypassing basic consumer-grade IoT configurations, this setup provides a secure, fast, and fully scalable platform tailored for business demands. Running EMQX and InfluxDB v3 together on a single VPS gives you full ownership of your data pipeline, eliminating third-party cloud subscription fees. As your fleet grows, this architecture scales effortlessly—allowing you to easily monitor hundreds of additional environmental sensors across multiple geographic locations.
