Skip to main content

AirQualityIndex

caution

This service is experimental and may change in the future.

The Air Quality Index is a measure of how clean or polluted air is. From min, good quality, to high, low quality. The range of AQI may vary between countries (https://en.wikipedia.org/wiki/Air_quality_index).

import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()

Registers

reading

Air quality index, typically refreshed every second.

  • type: Register<number> (packing format u16.16)

  • read only

import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
const value = await airQualityIndex.reading.read()
  • track incoming values
import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
airQualityIndex.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

readingError

Error on the AQI measure.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read only

import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
const value = await airQualityIndex.readingError.read()
  • track incoming values
import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
airQualityIndex.readingError.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

minReading

Minimum AQI reading, representing a good air quality. Typically 0.

  • type: Register<number> (packing format u16.16)

  • constant: the register value will not change (until the next reset)

  • read only

import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
const value = await airQualityIndex.minReading.read()
note

write and read will block until a server is bound to the client.

maxReading

Maximum AQI reading, representing a very poor air quality.

  • type: Register<number> (packing format u16.16)

  • constant: the register value will not change (until the next reset)

  • read only

import { AirQualityIndex } from "@devicescript/core"

const airQualityIndex = new AirQualityIndex()
// ...
const value = await airQualityIndex.maxReading.read()
note

write and read will block until a server is bound to the client.