SparkFun Indoor Air Quality Sensor - ENS160 (Qwiic)

Hello All!

I am trying to use the SparkFun Indoor Air Quality Sensor - ENS160 (Qwiic) with Arduino and after uploading the following code:

*/

#include <SPI.h>

#include “SparkFun_ENS160.h”

SparkFun_ENS160_SPI myENS;

// Adjust pin select to suit your project’s needs.

int chipSelect = 0;

int ensStatus = 0;

void setup()

{

pinMode(chipSelect, OUTPUT);

digitalWrite(chipSelect, HIGH);

SPI.begin();

Serial.begin(115200);

if( !myENS.begin(chipSelect) )

{

Serial.println(“Did not begin.”);

while(1);

}

// Reset the indoor air quality sensor’s settings.

if( myENS.setOperatingMode(SFE_ENS160_RESET) )

Serial.println(“Ready.”);

delay(100);

// Device needs to be set to idle to apply any settings.

// myENS.setOperatingMode(SFE_ENS160_IDLE);

// Set to standard operation

// Others include SFE_ENS160_DEEP_SLEEP and SFE_ENS160_IDLE

myENS.setOperatingMode(SFE_ENS160_STANDARD);

Serial.print("Operating Mode: ");

Serial.println(myENS.getOperatingMode());

// There are four values here:

// 0 - Operating ok: Standard Opepration

// 1 - Warm-up: occurs for 3 minutes after power-on.

// 2 - Initial Start-up: Occurs for the first hour of operation.

// and only once in sensor’s lifetime.

// 3 - No Valid Output

ensStatus = myENS.getFlags();

Serial.print("Gas Sensor Status Flag: ");

Serial.println(ensStatus);

}

void loop()

{

if( myENS.checkDataStatus() )

{

Serial.print("Air Quality Index (1-5) : ");

Serial.println(myENS.getAQI());

Serial.print("Total Volatile Organic Compounds: ");

Serial.print(myENS.getTVOC());

Serial.println(“ppb”);

Serial.print("CO2 concentration: ");

Serial.print(myENS.getECO2());

Serial.println(“ppm”);

}

delay(200);

}

All I am getting is “Did not begin” on the serial monitor after 20 seconds into power up.

What am I doing wrong here?

Thanks for your time!

How are you connecting the board to your arduino? (I2C / SPI)

I noticed you define chip select as pin 0, but pin 0 is used for serial communication. Change that line to match the pin number you have connected CS to.

If you’re using SPI, you’re going to need a logic level converter between the sensor and your arduino if your arduino uses 5 volt I/O, it looks from the data sheet this particular sensors max I/O voltage is 3.3 volts.

Thanks for the reply! I am using SPI, but the board is a redboard. I should have explained better but I am using Arduino IDE to upload the code but a Sparkfun redboard. I will change the pin number to the appropriate pin in the code, thank you for the advice!