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
Install dependencies
Install the required Python packages:This installs SQLAlchemy, PyMySQL, paho-mqtt, requests, and python-dotenv.
Configure environment
Create a Edit
.env file with your database and MQTT broker settings:.env with your database credentials:Create your first flow
Now let’s create a flow to receive and store sensor data from MQTT.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
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.Verify the data
Query thedata table to see your stored message:
| id | received_at | flow_code | attribute_name | attribute_value | last_msg_id |
|---|---|---|---|---|---|
| 1 | 2024-03-03 … | AHT10_SENSOR | temperature | 29.47 | 1 |
| 2 | 2024-03-03 … | AHT10_SENSOR | humidity | 47.85 | 1 |
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