Sensor Readings
This page explains one SensorState item inside peripherals.sensors.
SensorState Schema
| Field | Type | Required | Description |
|---|---|---|---|
index | integer | Yes | Sensor interface or channel index, starting from 1 |
type | string | Yes | Type code. Current enum values: TEMP, HUMI |
value | number | No | Current value |
unit | string | Yes | Measurement unit, for example C or % |
status | string | Yes | Sensor status. Enum: ONLINE, OFFLINE |
Sensor type Enum
| Value | Description |
|---|---|
TEMP | Temperature |
HUMI | Humidity |
Sensor status Enum
| Value | Description |
|---|---|
ONLINE | Sensor is online |
OFFLINE | Sensor is offline |
Notes:
- A single sensor interface may return multiple readings at the same
index. - Use
index + typeto identify one sensor reading. - When the sensor is offline,
valuemay be omitted.
Examples
Single-temperature sensor:
json
[
{
"index": 1,
"type": "TEMP",
"value": 30.4,
"unit": "C",
"status": "ONLINE"
}
]Temperature-humidity sensor:
json
[
{
"index": 2,
"type": "TEMP",
"value": 32.6,
"unit": "C",
"status": "ONLINE"
},
{
"index": 2,
"type": "HUMI",
"value": 54,
"unit": "%",
"status": "ONLINE"
}
]Offline sensor:
json
[
{
"index": 1,
"type": "TEMP",
"unit": "C",
"status": "OFFLINE"
}
]