AMS iAQ-Core C

I would like to thank Jesse Casman and Craig Oda from the Learn IoT Community for providing me with the Renesas IoT Fast Prototyping Kit. These guys have a great site going that focuses on IoT and Sensors and you really should take a look if you are interested in either sensors or IoT.

The IoT Fast Prototyping Kit comes with several PMOD sensors (PMOD is a particular way of wiring a connector, like an Ardunio Shield, see Digilent’s Website for more information). One of these sensors is the AMS Renesas Sensor Board which includes the following sensors:

  1. AMS iAQ-Core Indoor Air Quality Sensor
  2. AMS ENS210 Humidity and Temperature Sensor
  3. AMS AS3935 Lightning Sensor
  4. AMS TMD3782 Proximity Sensor

Today we will be working with the AMS iAQ-Core C indoor air quality sensor. The iAQ-Core measures air quality be measuring the amount of carbon dioxide (CO2) as well as volatile organic compounds (VOCs), such as smoke, cooking odors, bio-effluence,
outdoor pollutants. The iAQ Core reports CO2 in parts per million and VOCs as parts per billion.

The iAQ Core works from 0C to 50C, reports CO2 from 450ppm to 2,000ppm, and VOCs from 125ppb to 6,000ppb.

This is a follow on article for the AMS Renesas Sensor Board. Please see AMS Renesas Sensor Board – SSP Configuration article for instructions on configuring your DK-S7G2.

Communication with the iAQ is pretty basic. There are no control registers. In fact, sending a write bit to the iAQ may brick the sensor.

Reading the data is accomplished by sending the I2C address, a read bit followed by up clocks to read up to nine bytes.


There are only two functions and a single data structure needed for the iAQ sensor.

#ifndef AMS_IAQ_CORE_C_H_
#define AMS_IAQ_CORE_C_H_

typedef struct _AMSiAQCoreData
    uint16_t Prediction;
    uint8_t Status;
    int32_t Resistance;
    uint16_t TVOC;
} AMSiAQCoreData;
ssp_err_t AMSiAQCoreInitialize(void);
ssp_err_t AMSiAQCoreUpdateSensors(i2c_master_instance_t * const i2c, uint8_t address, AMSiAQCoreData * const data, bool retryIfBusy);

#endif /* AMS_IAQ_CORE_C_H_ */

The initialize function is a placeholder, it doesn’t actually do anything.

The update function resets the data structure, attempts to read data from the sensor, optionally retrying to read the sensor if it was busy.

 * AMS_iAQ_Core_C.c
 *  Created on: Dec 6, 2016
 *      Author: lycan

#include "hal_data.h"
#include "I2C.h"
#include "AMS_iAQ_Core_C.h"

ssp_err_t AMSiAQCoreInitialize(void)
    return SSP_SUCCESS;

ssp_err_t AMSiAQCoreUpdateSensors(i2c_master_instance_t * const i2c, uint8_t address, AMSiAQCoreData * const data,
        bool retryIfBusy)
    ssp_err_t error;
    int attempts = 0;

    // Create buffer for iAQ data
    uint8_t amsData[9] =
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

    // Reset structure values
    data->Prediction = 0;
    data->Status = 0;
    data->Resistance = 0;
    data->TVOC = 0;

        // Increment attempts

        // Read sensor values
        error = I2CRead (i2c, address, amsData, 9, false);
        if (error != SSP_SUCCESS)
            return error;

        // Check if we've hit our attempt limit
        if (attempts >= 10)
            return SSP_ERR_TIMEOUT;
    } // Continue loop if the sensor was busy AND we want to retry
    while ((retryIfBusy == true) && (amsData[2] == 0x01));

    // Update data structure
    data->Prediction = (uint16_t) ((amsData[0] << 8) + amsData[1]);
    data->Status = amsData[2];
    data->Resistance = (int32_t) ((amsData[3] << 24) | (amsData[4] << 16) | (amsData[5] << 8) | (amsData[6]));
    data->TVOC = (uint16_t) ((amsData[7] << 8) + amsData[8]);

    return SSP_SUCCESS;

There is not a stand alone project for the AMS iAQ-Core C. Instead, a single project that has all four sensors on the AMS Renesas Sensor Board has been created on GitHub at


One thought on “AMS iAQ-Core C

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s