Skip to content

milkmansson/toit-ens16x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toit driver for the ScioSense ENS160 & ENS161 I2C/SPI Air Quality Sensors

Toit driver for ENS160/ENS161 Air Quality Sensor. This IC is found on common modules (such as [this one] from DFRobot). The device does not have its own temperature/humidity sensor, so is also found on modules combined with a sensor such as the ASAIR AHT21 temperature/humidity sensor.

Air Quality Characteristics Detected

The ScioSense datasheet has excellent explanations of what it detects (snippets taken from the datasheets):

TVOCs - 'Total Volatile Organic Compounds'

More than 5000 VOCs exist, and they are two to five times more likely to be found indoors than outdoors. Indoor VOCs are various types of hydrocarbons from mainly two sources: bio-effluents, i.e. odors from human respiration, transpiration and metabolism, and building material including furniture and household supplies. VOCs are known to cause eye irritation, headache, drowsiness or even dizziness – all summarized under the term Sick Building Syndrome (SBS). Besides industrial applications, comfort aspects (e.g. temperature), or building protection (humidity), VOCs are the main reason for ventilation. ScioSense Datasheet, p8

eCO2 - 'Equivalent CO2'

Due to the proportionality between VOCs and -CO2 generated by humans, CO2-values historically served as an air quality indicator, reflecting the total amount of VOCs (=TVOC) produced by human respiration and transpiration. This law (first revealed by Max von Pettenkofer in the 19th century) and the unavailability of suitable VOC measurement technology made CO2 the surrogate of inhabitant-generated air-pollution in confined living spaces of the past and the present, i.e. today’s standard air quality reference for demand-controlled ventilation – as adopted by most HVAC industry standards.ScioSense Datasheet, p8

AQI-UBA17 - 'UBA Air Quality Index'

The AQI-UBA17 air quality index is derived from a guideline by the German Federal Environmental Agency based on a TVOC sum signal. Although a local German guideline, it is referenced and adopted by many countries and organizations. The ENS160 outputs a rating (1..5) aligned with the standard.

AQUI-UBA TVOC Hygenic Rating Exposure Limit
5 (Unhealthy) 10-25mg/m3 (2.2-2.5ppm) Not acceptable Hours
4 (Poor) 3-10mg/m3 (0.65-2.2ppm) Major objections < 1 Month
3 (Moderate) 1-3mg/m3 (0.02-0.65ppm) Some objections < 12 Months
2 (Good) 0.3-1mg/m3 (0.065-0.022ppm) No relevant objections No Limit
1 (Excellent) <0.3mg/m3 (0-0.065ppm) No objections No Limit

ScioSense Datasheet, p11

AQI-S – relative Air Quality Index [ENS161 Only]

The AQI-S is a relative and proprietary ScioSense air quality index/output signal, classifying air quality in 500 steps between 0 and 500. It uses a reference output value of 100 for the average air quality of the past 24 hours.

  • A value of <100 means relatively better air quality than the average air quality of the past 24 hours.
  • A value of >100 means relatively worse air quality than the average air quality of the past 24 hours.

Note that this value on its own is not an air quality measurement. Please see the ENS161 Datasheet

Specific Compounds

The datasheet shows that by exposing a register for reading a specific element, readings for specific chemicals can be made using calibration for that gas.

While these channels are described in terms of individual target gases (for example acetone, ethanol, or hydrogen) they do not represent direct or calibrated concentration measurements. Each raw channel is influenced by the mixture of gases in the air, as well as by temperature, humidity, sensor aging, and cross-sensitivity effects. ScioSense does not provide a universal or sensor-independent formula to convert these raw values into ppm or mg/m3, and any such conversion requires empirical calibration against known reference concentrations for the specific sensor and environment of the intended use case.

For this reason, this driver currently does not expose convenience functions that claim to return absolute concentrations for individual gases based on raw channels. It does however expose a raw read function .read-gpr-raw-int16 for the sensor such that the user can obtain the value and do the required math. Similar to the .is-data-ready function, the .is-gpr-data-ready function can be used to assert when new GPR data is ready. (See examples information below.)

Usage

Tip

The Hardware/Software guide says "... it's important to be aware that frequently toggling between active operating modes is not advisable. If the operating mode is changed and after idle periods, it is advisable to wait for the warm-up time in order to ensure adequate sensor stability. Warm up is given as 3 minutes in standard mode [ENS160] (and 5..60 minutes if using low-power modes [ENS161]).

The driver logs information it finds at startup, and enforces the interim change to IDLE when changing to another operating mode. However, this may not be enough in all specific circumstances. See the Datasheet and Guides for more information.

Initial Startup

Warning

The datasheet states that an initial 1 hour warm up period is required when first being used (or 3..24 hours in low power modes in the ENS161), and 'Only once in the sensor's lifetime.' However, even when this initial warm up period is complete, this status will only be stored in the devices non-volatile memory after an initial 24h period of continuous operation. If unpowered before the conclusion of this 24h period, the ENS160 will resume "Initial Start-up" mode again after powering on again.

Examples

See the examples folder for examples of the driver in use, and additional information against functions in the Toitdocs alongside the driver code.

Raw resistance values (for single gas calibration)

An example as shown below. The Datasheet shows that the ENS160 exposes two registers, whereas the ENS161 has just one. (The error case of reading the additional ENS160 sensor #1 with the ENS161 is logged, but not guarded against.) See the read-raw.toit example.

Links

Issues

If there are any issues with this code, changes, or any other kind of feedback, please raise an issue. Feedback is welcome and appreciated! There are evidently many cheap clones of this device floating about, with varying results. Links to interesting articles on this:

Disclaimer

  • This driver has been written and tested with DFRobot module pictured.
  • The ENS161 has not been fully tested, but given the register map and details in its datasheet, operation is fully expected. Please test and advise!
  • All trademarks belong to their respective owners.
  • No warranties for this work, express or implied.

Credits

  • AI has been used for reviews, analysing & compiling data/results, and assisting with ensuring accuracy.
  • Florian for the tireless help and encouragement
  • The wider Toit developer team (past and present) for a truly excellent product

About Toit

One would assume you are here because you know what Toit is. If you dont:

Toit is a high-level, memory-safe language, with container/VM technology built specifically for microcontrollers (not a desktop language port). It gives fast iteration (live reloads over Wi-Fi in seconds), robust serviceability, and performance that’s far closer to C than typical scripting options on the ESP32. [link]

About

Toit driver for ScioSense ENS160 and ENS161 temperature and humidity sensor.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages