MQTT IoT Devices

RosFit is not limited to ROS 2 robots. Any device that speaks MQTT can connect to the platform, send telemetry, receive commands, and participate in device shadow synchronization. This makes RosFit a unified fleet management layer for mixed deployments of robots and IoT sensors.

Topic convention

Every device in RosFit communicates over a structured MQTT topic hierarchy. Adhering to this convention ensures that telemetry is persisted, commands are routed, and the dashboard renders device data correctly.

rosfit/{device_id}/telemetry          # Device → Cloud: sensor readings, state
rosfit/{device_id}/command            # Cloud → Device: action requests
rosfit/{device_id}/status             # Device → Cloud: online/offline heartbeat
rosfit/{device_id}/shadow/reported    # Device → Cloud: current device state
rosfit/{device_id}/shadow/desired     # Cloud → Device: desired configuration
rosfit/{device_id}/ota                # Cloud → Device: firmware update instructions
rosfit/{device_id}/log                # Device → Cloud: structured log messages
Topic suffixDirectionQoSRetainedPurpose
/telemetryDevice → Cloud0 or 1NoHigh-frequency sensor data
/commandCloud → Device1NoAction requests with acknowledgement
/statusDevice → Cloud1YesLast-will heartbeat (online/offline)
/shadow/reportedDevice → Cloud1YesCurrent device state snapshot
/shadow/desiredCloud → Device1YesDesired configuration delta
/otaCloud → Device1NoFirmware URL + checksum
/logDevice → Cloud0NoDebug, info, warning, error logs

The device_id is assigned when you register a device through the API or dashboard. Use it consistently across all topics.

Telemetry schema

Telemetry payloads are JSON objects with a flat or shallow-nested structure. RosFit's message handler parses the JSON, extracts numeric fields for time-series storage, and makes all fields available in the dashboard.

Example: greenhouse sensor

{
  "temperature": 24.5,
  "humidity": 62.3,
  "soil_moisture": 48.1,
  "light_level": 8720,
  "battery_voltage": 3.72,
  "timestamp": "2026-03-30T10:15:00Z"
}

Schema rules

RuleDescription
Top-level keys are field namesEach key becomes a column in TimescaleDB and a selectable metric in the dashboard
Numeric values are indexedIntegers and floats are stored in the hypertable for charting and alerting
String values are stored as metadataUseful for status enums ("state": "charging")
timestamp is optionalIf omitted, the server uses the MQTT message receive time
Nested objects are flattened{"position": {"x": 1.0, "y": 2.0}} becomes position.x and position.y
Arrays are stored as JSONNot indexed individually, but available in raw queries

Command schema

Commands are JSON objects sent from the cloud to a device. Each command has a command name, an optional data payload, and a unique request_id for tracking acknowledgement.

Example: set valve position

{
  "request_id": "cmd_7f3a2b",
  "command": "set_valve",
  "data": {
    "pin": 25,
    "open": true
  },
  "timeout_ms": 5000
}

Acknowledgement

Devices should publish a response to the telemetry topic (or a dedicated /command/ack sub-topic) to confirm execution:

{
  "request_id": "cmd_7f3a2b",
  "status": "completed",
  "result": {
    "pin": 25,
    "state": "open"
  },
  "executed_at": "2026-03-30T10:15:01Z"
}

The dashboard shows command status in real time: pendingdeliveredcompleted or failed.

Custom device types

By default, RosFit treats every MQTT device as a generic sensor. To unlock device-specific dashboard views, alerts, and validation, define a custom device type in devices.yaml.

device_types:
  greenhouse_controller:
    display_name: "Greenhouse Controller"
    icon: "leaf"
    telemetry:
      - field: temperature
        unit: "°C"
        range: [-10, 60]
        alert_above: 40
        alert_below: 5
      - field: humidity
        unit: "%"
        range: [0, 100]
      - field: soil_moisture
        unit: "%"
        range: [0, 100]
        alert_below: 20
      - field: light_level
        unit: "lux"
        range: [0, 100000]
    commands:
      - name: set_valve
        description: "Open or close an irrigation valve"
        parameters:
          - name: pin
            type: integer
            required: true
          - name: open
            type: boolean
            required: true
      - name: set_shade
        description: "Adjust shade cover percentage"
        parameters:
          - name: percentage
            type: number
            min: 0
            max: 100
    status_fields:
      - field: battery_voltage
        warn_below: 3.3
        critical_below: 3.0
      - field: wifi_rssi
        warn_below: -70
        critical_below: -85

Register a device with this type through the API:

curl -X POST http://localhost:8000/api/v1/devices \
  -H "Content-Type: application/json" \
  -d '{
    "name": "greenhouse-north-01",
    "type": "greenhouse_controller",
    "tags": ["greenhouse", "north-wing"]
  }'

The dashboard will automatically render type-specific widgets: temperature gauges with alert thresholds, soil moisture charts, and command buttons for valve control.

Supported categories

RosFit's MQTT integration supports any device that can publish JSON over MQTT. Below are categories with tested device examples and common telemetry fields.

Smart agriculture

Device typeExamplesTelemetry fields
Soil sensorsDragino LSE01, SenseCAP S2100soil_moisture, soil_temperature, soil_ec
Climate sensorsBME280, SHT31, Davis Vantagetemperature, humidity, pressure, wind_speed
Irrigation actuatorsESP32 + relay boards, Netafimvalve_state, flow_rate, total_volume
Crop monitoringESP32-CAM, Seeed reCameraimage_url, ndvi_estimate, growth_stage

Smart building

Device typeExamplesTelemetry fields
HVAC controllersModbus → MQTT gateways, Shellytemperature, setpoint, fan_speed, mode
Occupancy sensorsPIR, mmWave (LD2410), BLE beaconsoccupancy_count, zone, last_motion_at
Lighting controllersDALI → MQTT, Shelly Dimmerbrightness, color_temp, power_watts
Energy metersShelly EM, INA219voltage, current, power, energy_kwh

Industrial IoT

Device typeExamplesTelemetry fields
PLC gatewaysSiemens S7 → MQTT, Modbus TCPregister_values, digital_inputs, alarms
Vibration sensorsESP32 + ADXL345, Bosch CISSvibration_rms, peak_acceleration, fft_dominant_freq
Motor controllersVFDs with MQTT, ODriverpm, torque, temperature, fault_code
EnvironmentalESP32 + MQ series, PMS5003pm25, pm10, co2, voc, noise_db

Vision and edge AI

Device typeExamplesTelemetry fields
ESP32-CAMAI Thinker, XIAO ESP32S3 Senseimage_url, detection_count, inference_ms
TFLite edgeCoral Dev Board, RPi + Coral USBobject_class, confidence, bbox, fps
Intel RealSenseD435, D455, L515depth_map_url, pointcloud_topic, rgb_url
Luxonis OAK-DOAK-D, OAK-D Lite, OAK-1detection_results, spatial_coordinates, tracking_id

All devices in these categories follow the same rosfit/{device_id}/telemetry topic convention and can be managed, monitored, and controlled from a single RosFit dashboard alongside your ROS 2 robots.