maarten-pennings / iAQcore

Arduino library for the iAQ-core indoor air quality sensor module with I2C interface
MIT License
15 stars 7 forks source link
arduino arduino-library driver gas-library i2c-interface iaq iaqcore tvoc

iAQcore

Arduino library for the iAQ-core indoor air quality sensor module with I2C interface from ams.

Introduction

This project is an Arduino library. It implements a driver for the iAQcore. This chip is a indoor air quality sensor module with an I2C interface.

The code has been tested with

Note that the iAQcore requires a supply voltage of 3.3V ± 0.1V. So, 3.3V is ok, but do not use a 5V board. The Nano has 3v3 supply, but runs I2C on 5V. This does seem to work.

Links

The iAQcore is made by ams. This library is compatible with the following variants.

Prerequisites

It is assumed that

Installation

Installation steps

Build an example

To build an example sketch

Wiring

This library has been tested with three boards.

For the NodeMCU (ESP8266), connect as follows (I did not use pull-ups, presumably they are inside the MCU)

iAQcore ESP8266
VCC 3V3
GND GND
SDA D2
SCL D1

wiring ESP8266 NoeMCU

For the Pro mini (do not use a 5V board), connect as follows (I did not use pull-ups, presumably they are inside the MCU)

iAQcore Pro mini
VCC VCC
GND GND
SDA A4
SCL A5

wiring pro mini

For the Arduino Nano, connect as follows (I did not use pull-ups, presumably they are inside the MCU)

iAQcore Nano
VCC 3V3
GND GND
SDA A4
SCL A5

wiring nano

Connect the iAQcore module as follows

wiring iAQcore

Flash an example

To build an example sketch

Clock stretching

I2C slave devices, such as the iAQcore, are controlled by I2C masters, such as the ESP8266, pro mini or nano. The master is in charge of the communication to the slave: it toggles the clock line (SCL) high and low. Each clock pulse one bit is transferred between the master and the slave (from or to). If the slave is not yet ready, it may stretch the clock, i.e. force the SCL line low, so that the master can not complete the pulse.

The figure below shows that after the master has send the address byte of the iAQcore, this iAQcore chip stretches the SCL line for 306.8 us.

Clock stretching

Unfortunately, the ESP8266 I2C library has a clock stretch timeout of 230us. So, this timeout must be set to a higher value: Wire.setClockStretchLimit(1000).

(end of doc)