Prerequisites
Before you begin, ensure you have:- Python 3.12 or higher
- MariaDB or MySQL server (accessible on your network)
- MQTT broker (e.g., Mosquitto, HiveMQ)
Don’t have an MQTT broker? You can use test.mosquitto.org or install Mosquitto locally with
sudo apt install mosquitto mosquitto-clientsInstallation
1
Clone and setup
Clone the repository and create a virtual environment:
2
Install dependencies
Install the required Python packages:This installs SQLAlchemy, PyMySQL, paho-mqtt, requests, and python-dotenv.
3
Configure environment
Create a Edit
.env file with your database and MQTT broker settings:.env with your database credentials:4
Start the gateway
Run the gateway:On first run, the gateway will:
- Create database tables (
mqtt_servers,flows,data) - Insert a default MQTT broker configuration
- Connect to your MQTT broker
Create your first flow
Now let’s create a flow to receive and store sensor data from MQTT.1
Connect to your database
Connect to your MariaDB database using your preferred client:
2
Insert a flow
Create a flow that listens to the This flow:
sensors/aht10 topic and stores data in the database:- Subscribes to the
sensors/aht10MQTT topic - Validates incoming messages against the schema (requires
temperatureandhumidityas floats) - Stores valid messages in the
datatable
3
Wait for flow reload
The gateway reloads flows every 10 minutes by default. To see your flow immediately, restart the gateway:
In production, you can adjust
FLOWS_RELOAD_INTERVAL_SECONDS to reload flows more frequently.4
Publish a test message
Publish a test message to the MQTT broker using mosquitto_pub:Or using Python:
Verify the data
Query thedata table to see your stored message:
Each attribute from the JSON payload is stored as a separate row, linked by the
last_msg_id counter.
Try an HTTP endpoint flow
You can also forward messages to HTTP endpoints instead of storing them in the database. Create a flow with thePOST_ENDPOINT action:
sensors/aht10/http, the gateway will POST it to the configured endpoint URL.
Next steps
Installation guide
Detailed installation and Docker deployment instructions
Configuration
Learn about all environment variables and database settings
Flows
Understand how flows work and how to configure them
Flow examples
Explore real-world flow examples and use cases