Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###
- #
- # Assume the SensorBoard has following sensors:
- #
- # 1. st-hts221, to measure the temperature/humidity inside the box.
- # 2. st-hts221, to measure the temperature/humidity outside the box.
- # 3. gp2y1010au, to measure barometric pressure outside the box.
- # 4. iaq-core-p, to measure the CO2 and TVOC.
- #
- # SensorBoard shall output the measurements of environment's air properties sourrounding
- # the box, with following format:
- #
- # ```
- # ![PREFIX],[MEASUREMENT][EOL]
- # ```
- #
- # In BNF Grammar, it is represented as follows:
- #
- # <PACKET> ::= '!' <PREFIX> ',' <MEASUREMENT> <EOL>
- # <PREFIX> ::= <CHAR> { <CHAR> }*
- # <MEASUREMENT> ::= <INTEGER>
- # <CHAR> ::= <DIGIT> | <LETTER>
- # <INTEGER> ::= <DIGIT> { <DIGIT> }
- # <DIGIT> ::= [ '0' .. '9' ]
- # <LETTER> ::= [ 'A' .. 'Z' ]
- # <EOL> ::= '\n'
- #
- #
- # Here are sample outputs:
- #
- # ```text
- # !TI,26.5
- # !HI,65
- # !TE,27.5
- # !HE,73
- # !P,1344
- # !VC,998
- # !V,-32767
- # ```
- #
- # First, sensorboard parser shall parse above output data to produce following JSON structure:
- #
- # ```json
- # {
- # "st-hts221": {
- # "0": {
- # "temperature": 26.5,
- # "humidity": 65
- # },
- # "1": {
- # "temperature": 26.5,
- # "humidity": 65
- # }
- # },
- # "gp2y1010au": {
- # "0": {
- # "pressure": 1344
- # }
- # },
- # "iaq-core-p": {
- # "0": {
- # "co2": 998,
- # "tvoc": -32767
- # }
- # }
- # }
- # ```
- #
- # Then, apply sensor name/alias transformation. You can notice that original sensor name will
- # be re-used when aliasname of sensors are not found in `schema` section. And, for naming
- # convention, all `-` will be converted to underline `_` in sensor name.
- #
- # ```json
- # {
- # "thermometer": {
- # "inside": {
- # "temperature": 26.5,
- # "humidity": 65
- # },
- # "outside": {
- # "temperature": 26.5,
- # "humidity": 65
- # }
- # },
- # "barometric_pressure": {
- # "0": {
- # "pressure": 1344
- # }
- # },
- # "iaq_core_p": {
- # "0": {
- # "co2": 998,
- # "tvoc": -32767
- # }
- # }
- # }
- # ```
- #
- # Then, apply calibration calculation on the measured values:
- #
- # ```json
- # {
- # "thermometer": {
- # "inside": {
- # "temperature": 26.5,
- # "temperature_calibrated": 29.95,
- # "humidity": 65,
- # "humidity_calibrated": 65.5
- # },
- # "outside": {
- # "temperature": 26.5,
- # "humidity": 65
- # }
- # },
- # "barometric_pressure": {
- # "0": {
- # "pressure": 1344,
- # "pressure_calibrated": 1894.28
- # }
- # },
- # "iaq_core_p": {
- # "0": {
- # "co2": 998,
- # "co2_calibrated": 1135.79,
- # "tvoc": -32767,
- # "tvoc_calibrated": -34335.35
- # }
- # }
- # }
- # ```
- #
- # Then, add `err` to each measurement when `keep_error` is true. Here are the pseudo codes
- # to detect error:
- #
- # if `keep_error` is false then
- # measurement[name] = value
- # measurement[name + 'calibrated'] = calibrate(value)
- #. else if `value` is inside `calibrated_range` then
- # measurement[name] = value
- # measurement[name + 'calibrated'] = calibrate(value)
- # measurement[name + '_err'] = null
- # else if `value` is inside `range` then
- # if `strict` then
- # measurement[name] = value
- # measurement[name + 'calibrated'] = calibrate(value)
- # measurement[name + '_err'] = -32786 # indicate the value is not tested before shipment
- # else
- # measurement[name] = value
- # measurement[name + 'calibrated'] = calibrate(value)
- # measurement[name + '_err'] = null
- # fi
- # else
- # measurement[name] = null
- # measurement[name + 'calibrated'] = null
- # measurement[name + '_err'] = value
- # fi
- #
- # Here are the ouptuts:
- #
- # ```json
- # {
- # "thermometer": {
- # "inside": {
- # "temperature": 26.5,
- # "temperature_calibrated": 29.95,
- # "humidity": 65,
- # "humidity_calibrated": 65.5
- # },
- # "outside": {
- # "temperature": 26.5,
- # "humidity": 65
- # }
- # },
- # "barometric_pressure": {
- # "0": {
- # "pressure": 1344,
- # "pressure_calibrated": 1894.28,
- # "pressure_err": null
- # }
- # },
- # "iaq_core_p": {
- # "0": {
- # "co2": 998,
- # "co2_calibrated": 1135.79,
- # "tvoc": null,
- # "tvoc_calibrated": null,
- # "tvoc_err": -32767
- # }
- # }
- # }
- # ```
- #
- # Please note, the `calibrate_args` and `calibrated_range` shall be read from EEPROM of SBC, and
- # other information in `spec` shall be provided by SensorBoard.
- #
- #
- schema:
- st-hts221/0:
- alias: thermometer/inside
- st-hts221/1:
- alias: thermometer/outside
- gp2y1010au/0:
- alias: barometric_pressure/0
- spec:
- st-hts221/0:
- temperature:
- prefix: TI
- unit: °C
- range: [-40, 120]
- calibrated_range: [0, 85]
- calibrate_args: [0, 1.1, 0.8] # calibrated = ax^2 + bx + c, x = raw value, [a, b, c], optional
- keep_error: false # optional
- strict: false
- humidity:
- prefix: HI
- unit: \%rH
- range: [0, 100]
- calibrated_range: [20, 90] # calibrated = ax^2 + bx + c, x = raw value, [a, b, c], optional
- calibrate_args: [0, 0.9, 7] # optional
- keep_error: false
- strict: false
- st-hts221/1:
- temperature:
- prefix: TE
- unit: °C
- range: [-40, 120]
- calibrated_range: [0, 85]
- keep_error: false
- strict: false
- humidity:
- prefix: HE
- unit: \%rH
- range: [0, 100]
- calibrated_range: [20, 90]
- keep_error: false
- strict: false
- gp2y1010au/0:
- pressure:
- prefix: P
- unit: hPa
- range: [50, 10000]
- calibrated_range: [260, 1260]
- calibrate_args: [0, 1.37, 53]
- keep_error: true
- strict: true
- iaq-core-p/0:
- co2:
- prefix: VC
- unit: ppm
- range: [400, 50000]
- calibrated_range: [400, 4000]
- calibrate_args: [0, 1.105, 33]
- keep_error: true
- strict: true
- tvoc:
- prefix: V
- unit: ppb
- range: [100, 10000]
- calibrated_range: [125, 600]
- calibrate_args: [0, 1.05, 70]
- keep_error: true
- strict: true
Add Comment
Please, Sign In to add comment