Skip to content

How It Works

Dave Schmid edited this page Nov 22, 2024 · 2 revisions

Message Processing

  1. MQTT Connection:

    • Connects to an MQTT broker using the provided configuration.
    • Subscribes to the topic specified in the configuration (default: qingping/#).
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Data Structure

Sensor Data Points

Measurement sensor
Tags device_mac
Fields temperature, humidity, co2, pm25, pm10, battery

Diagnostic Data Points

Measurement diagnostic
Tags device_mac, sw_version, module_version, hw_version, wifi_ap_name, wifi_ap_mac
Fields wifi_signal, wifi_channel, timezone

Interval Management

  1. 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.
  2. Configuration:

    • Default intervals can be adjusted using the DEFAULT_REPORT_INTERVAL and DEFAULT_COLLECT_INTERVAL settings in the configuration.
  3. Real-Time Control:

    • Devices are updated dynamically upon detection, eliminating the need for manual setup or predefined lists.

Clone this wiki locally