-
Notifications
You must be signed in to change notification settings - Fork 0
How It Works
Dave Schmid edited this page Nov 22, 2024
·
2 revisions
-
MQTT Connection:
- Connects to an MQTT broker using the provided configuration.
- Subscribes to the topic specified in the configuration (default:
qingping/#
).
-
Dynamic Device Registration:
- Automatically registers devices upon receiving their first message.
- Optionally sets device reporting and collection intervals if the
SET_DEVICE_INTERVALS
flag is enabled.
-
Message Types:
-
Type 17 (Sensor Data):
- Processes temperature, humidity, CO2, PM2.5, PM10, and battery levels.
- Extracts data from the payload and creates structured points for InfluxDB.
-
Type 13 (Diagnostic Data):
- Handles device diagnostics, such as WiFi status, device version, and hardware information.
- Extracts diagnostic fields and stores them for analysis.
-
Type 17 (Sensor Data):
-
Timestamps:
- Uses the payload timestamp by default.
- If the
USE_CURRENT_TIME
flag is enabled, the current time is used instead of the payload timestamp.
-
Data Writing:
- Formats the extracted data into InfluxDB points with appropriate tags and fields.
- Writes the data to InfluxDB in real-time, ensuring minimal latency for analysis.
Measurement | sensor |
---|---|
Tags | device_mac |
Fields |
temperature , humidity , co2 , pm25 , pm10 , battery
|
Measurement | diagnostic |
---|---|
Tags |
device_mac , sw_version , module_version , hw_version , wifi_ap_name , wifi_ap_mac
|
Fields |
wifi_signal , wifi_channel , timezone
|
-
Automatic Interval Updates:
- If
SET_DEVICE_INTERVALS
is enabled, the application sends an MQTT message to each detected device to set default intervals for:- Reporting Interval: Frequency at which the device sends data.
- Collection Interval: Frequency at which the device collects sensor data.
- If
-
Configuration:
- Default intervals can be adjusted using the
DEFAULT_REPORT_INTERVAL
andDEFAULT_COLLECT_INTERVAL
settings in the configuration.
- Default intervals can be adjusted using the
-
Real-Time Control:
- Devices are updated dynamically upon detection, eliminating the need for manual setup or predefined lists.