Getting/using sensor data from the CC1

The CC1 contains multiple sensors that can return data about the environment context. The data read from these sensors can be sent to the backend MQTT for processing, or displayed directly on the device widgets.

Sensors are defined as 2 types for reading data:

  • Sync: can read the new data rapidly when asked : temp, pressure, accelero, power management,
  • Async : reading the new data takes a significant amount of time (>1s) : GPS, BLE scan, wifi scan, NFC reader

Sensor data reading :

  • All ‘sync’ sensors are checked every X minutes (15 by default, configurable in global.json using ‘sensorCheckPeriodSecs’ ) and any data that has ‘significant’ change is sent up in MQTT message
  • Specific sensors can be checked explicitly by sending mqtt message listing the sensors to get
    • Sync sensors data will be sent immediately in an uplink mqtt
    • Async sensor data will be sent up when the sensor has completed its read – this will depend on the sensor and the specific config
  • A specific sensor can be referenced from a button widget, if pressed the sensor is read and the button value updated (includes sending to backend)
    • Note that the button text displayed can be either just the value of the sensor as a text string, or a fixed text (‘displayValue’ attribute) which can include the sensor data (include {} in the displayValue)
  • A specific sensor data element can be referenced from a text widget – this will update if the sensor is read (by any of the triggers listed above) but will not itself do a read at any point

When displaying sensor data on the device (button or text widget), each sensor has a “nice text” format for its data which is currently fixed…

Examples:

See the “system” DV for examples of using sensor data in widgets (both listing and buttons).

MQTT message to request sensor data from several sensors:

{
  "app":{
    "dev":{
       "temp":null,
       "accel":null,
       "power":null,
       "blescan":{ "scanDurationSecs":10 }
     }
   }
}

The temp, accel and power data will be returned immediately, the blescan results after 10s.

Warning : reading the sync sensors and sending the data/updating widgets takes a little time, which can delay processing of UI events. Requesting reads too often will make the UI sluggish or cause unexpected delays in processing touch events….