Guest User

Untitled

a guest
May 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. ###
  2. #
  3. # Assume the SensorBoard has following sensors:
  4. #
  5. # 1. st-hts221, to measure the temperature/humidity inside the box.
  6. # 2. st-hts221, to measure the temperature/humidity outside the box.
  7. # 3. gp2y1010au, to measure barometric pressure outside the box.
  8. # 4. iaq-core-p, to measure the CO2 and TVOC.
  9. #
  10. # SensorBoard shall output the measurements of environment's air properties sourrounding
  11. # the box, with following format:
  12. #
  13. # ```
  14. # ![PREFIX],[MEASUREMENT][EOL]
  15. # ```
  16. #
  17. # In BNF Grammar, it is represented as follows:
  18. #
  19. # <PACKET> ::= '!' <PREFIX> ',' <MEASUREMENT> <EOL>
  20. # <PREFIX> ::= <CHAR> { <CHAR> }*
  21. # <MEASUREMENT> ::= <INTEGER>
  22. # <CHAR> ::= <DIGIT> | <LETTER>
  23. # <INTEGER> ::= <DIGIT> { <DIGIT> }
  24. # <DIGIT> ::= [ '0' .. '9' ]
  25. # <LETTER> ::= [ 'A' .. 'Z' ]
  26. # <EOL> ::= '\n'
  27. #
  28. #
  29. # Here are sample outputs:
  30. #
  31. # ```text
  32. # !TI,26.5
  33. # !HI,65
  34. # !TE,27.5
  35. # !HE,73
  36. # !P,1344
  37. # !VC,998
  38. # !V,-32767
  39. # ```
  40. #
  41. # First, sensorboard parser shall parse above output data to produce following JSON structure:
  42. #
  43. # ```json
  44. # {
  45. # "st-hts221": {
  46. # "0": {
  47. # "temperature": 26.5,
  48. # "humidity": 65
  49. # },
  50. # "1": {
  51. # "temperature": 26.5,
  52. # "humidity": 65
  53. # }
  54. # },
  55. # "gp2y1010au": {
  56. # "0": {
  57. # "pressure": 1344
  58. # }
  59. # },
  60. # "iaq-core-p": {
  61. # "0": {
  62. # "co2": 998,
  63. # "tvoc": -32767
  64. # }
  65. # }
  66. # }
  67. # ```
  68. #
  69. # Then, apply sensor name/alias transformation. You can notice that original sensor name will
  70. # be re-used when aliasname of sensors are not found in `schema` section. And, for naming
  71. # convention, all `-` will be converted to underline `_` in sensor name.
  72. #
  73. # ```json
  74. # {
  75. # "thermometer": {
  76. # "inside": {
  77. # "temperature": 26.5,
  78. # "humidity": 65
  79. # },
  80. # "outside": {
  81. # "temperature": 26.5,
  82. # "humidity": 65
  83. # }
  84. # },
  85. # "barometric_pressure": {
  86. # "0": {
  87. # "pressure": 1344
  88. # }
  89. # },
  90. # "iaq_core_p": {
  91. # "0": {
  92. # "co2": 998,
  93. # "tvoc": -32767
  94. # }
  95. # }
  96. # }
  97. # ```
  98. #
  99. # Then, apply calibration calculation on the measured values:
  100. #
  101. # ```json
  102. # {
  103. # "thermometer": {
  104. # "inside": {
  105. # "temperature": 26.5,
  106. # "temperature_calibrated": 29.95,
  107. # "humidity": 65,
  108. # "humidity_calibrated": 65.5
  109. # },
  110. # "outside": {
  111. # "temperature": 26.5,
  112. # "humidity": 65
  113. # }
  114. # },
  115. # "barometric_pressure": {
  116. # "0": {
  117. # "pressure": 1344,
  118. # "pressure_calibrated": 1894.28
  119. # }
  120. # },
  121. # "iaq_core_p": {
  122. # "0": {
  123. # "co2": 998,
  124. # "co2_calibrated": 1135.79,
  125. # "tvoc": -32767,
  126. # "tvoc_calibrated": -34335.35
  127. # }
  128. # }
  129. # }
  130. # ```
  131. #
  132. # Then, add `err` to each measurement when `keep_error` is true. Here are the pseudo codes
  133. # to detect error:
  134. #
  135. # if `keep_error` is false then
  136. # measurement[name] = value
  137. # measurement[name + 'calibrated'] = calibrate(value)
  138. #. else if `value` is inside `calibrated_range` then
  139. # measurement[name] = value
  140. # measurement[name + 'calibrated'] = calibrate(value)
  141. # measurement[name + '_err'] = null
  142. # else if `value` is inside `range` then
  143. # if `strict` then
  144. # measurement[name] = value
  145. # measurement[name + 'calibrated'] = calibrate(value)
  146. # measurement[name + '_err'] = -32786 # indicate the value is not tested before shipment
  147. # else
  148. # measurement[name] = value
  149. # measurement[name + 'calibrated'] = calibrate(value)
  150. # measurement[name + '_err'] = null
  151. # fi
  152. # else
  153. # measurement[name] = null
  154. # measurement[name + 'calibrated'] = null
  155. # measurement[name + '_err'] = value
  156. # fi
  157. #
  158. # Here are the ouptuts:
  159. #
  160. # ```json
  161. # {
  162. # "thermometer": {
  163. # "inside": {
  164. # "temperature": 26.5,
  165. # "temperature_calibrated": 29.95,
  166. # "humidity": 65,
  167. # "humidity_calibrated": 65.5
  168. # },
  169. # "outside": {
  170. # "temperature": 26.5,
  171. # "humidity": 65
  172. # }
  173. # },
  174. # "barometric_pressure": {
  175. # "0": {
  176. # "pressure": 1344,
  177. # "pressure_calibrated": 1894.28,
  178. # "pressure_err": null
  179. # }
  180. # },
  181. # "iaq_core_p": {
  182. # "0": {
  183. # "co2": 998,
  184. # "co2_calibrated": 1135.79,
  185. # "tvoc": null,
  186. # "tvoc_calibrated": null,
  187. # "tvoc_err": -32767
  188. # }
  189. # }
  190. # }
  191. # ```
  192. #
  193. # Please note, the `calibrate_args` and `calibrated_range` shall be read from EEPROM of SBC, and
  194. # other information in `spec` shall be provided by SensorBoard.
  195. #
  196. #
  197.  
  198. schema:
  199. st-hts221/0:
  200. alias: thermometer/inside
  201. st-hts221/1:
  202. alias: thermometer/outside
  203. gp2y1010au/0:
  204. alias: barometric_pressure/0
  205.  
  206.  
  207. spec:
  208. st-hts221/0:
  209. temperature:
  210. prefix: TI
  211. unit: °C
  212. range: [-40, 120]
  213. calibrated_range: [0, 85]
  214. calibrate_args: [0, 1.1, 0.8] # calibrated = ax^2 + bx + c, x = raw value, [a, b, c], optional
  215. keep_error: false # optional
  216. strict: false
  217. humidity:
  218. prefix: HI
  219. unit: \%rH
  220. range: [0, 100]
  221. calibrated_range: [20, 90] # calibrated = ax^2 + bx + c, x = raw value, [a, b, c], optional
  222. calibrate_args: [0, 0.9, 7] # optional
  223. keep_error: false
  224. strict: false
  225.  
  226. st-hts221/1:
  227. temperature:
  228. prefix: TE
  229. unit: °C
  230. range: [-40, 120]
  231. calibrated_range: [0, 85]
  232. keep_error: false
  233. strict: false
  234. humidity:
  235. prefix: HE
  236. unit: \%rH
  237. range: [0, 100]
  238. calibrated_range: [20, 90]
  239. keep_error: false
  240. strict: false
  241.  
  242. gp2y1010au/0:
  243. pressure:
  244. prefix: P
  245. unit: hPa
  246. range: [50, 10000]
  247. calibrated_range: [260, 1260]
  248. calibrate_args: [0, 1.37, 53]
  249. keep_error: true
  250. strict: true
  251.  
  252. iaq-core-p/0:
  253. co2:
  254. prefix: VC
  255. unit: ppm
  256. range: [400, 50000]
  257. calibrated_range: [400, 4000]
  258. calibrate_args: [0, 1.105, 33]
  259. keep_error: true
  260. strict: true
  261. tvoc:
  262. prefix: V
  263. unit: ppb
  264. range: [100, 10000]
  265. calibrated_range: [125, 600]
  266. calibrate_args: [0, 1.05, 70]
  267. keep_error: true
  268. strict: true
Add Comment
Please, Sign In to add comment