| Algorithm 3 Wireless sensor application (T, RH, light intensity, eCO2 and TVOC) | |
| 1: | Initialize components |
| 2: | Test CCS811 operation |
| 3: | Get batt. level |
| 4: | whileTruedo ▹ Main app. loop |
| 5: | Process BLE events |
| 6: | if (1 min. passed) then |
| 7: | Power up sensors |
| 8: | Wake up all components |
| 9: | Measure T and RH, save data to RAM |
| 10: | Set light sensor for continuous operation |
| 11: | Wait for light conversion |
| 12: | Get light intensity, save data to RAM |
| 13: | if (batt. level and light data from RAM > thresholds) then |
| 14: | Set mode for gas sensor |
| 15: | Start gas measurement |
| 16: | Save gas sensor output to RAM |
| 17: | end if |
| 18: | Get batt. level, save data to RAM |
| 19: | Compute thresholds values |
| 20: | end if |
| 21: | Update advertising payload with data from RAM |
| 22: | Enter low power mode |
| 23: | end while |