Payload Format for MQTT Messages
Payload Format for MQTT Messages
To ensure proper data ingestion, all MQTT messages sent to the subscriber service must follow a structured JSON format. This format allows the system to correctly parse and store incoming data in the designated database tables. The payload must include essential metadata, such as the message type, data source, timestamp, and data fields.
MQTT Payload Structure
Each MQTT message must include the following fields:
- type: Must be
"data"
to allow correct parsing by the subscriber. - source: A unique identifier for the device or data source.
- local_time: Timestamp in Philippine Time (PHT), formatted as
YYYY-MM-DDTHH:MM:SS
. - Data Fields: The actual sensor readings, which should match the predefined data types in the system.
Example JSON Payload
{
"type": "data",
"source": "bf9dd9d5",
"local_time": "2025-02-17T14:00:00",
"SI7020_TMP": 30.5,
"SI7020_RH": 75
}
Important Notes
- The system automatically converts the
local_time
value to UTC before storing it in the database. - Ensure that all data fields in the payload match the data types you have added in Data Management > Data Types.
- Invalid or incorrectly formatted messages may be ignored or rejected by the subscriber service.
Following this structured payload format ensures seamless data processing and storage. If any discrepancies occur, review the debugging logs in the Subscriber Service settings to verify incoming messages and troubleshoot potential issues.