0

I am trying to conect Adafruit SGP30 Air Quality Sensor to arduino nano and get values from it, but it seems that my code is not working properly. I followed instruction on the adafruit webpage, installed the Adafruit_SGP30 library and uploaded to my microcontroller. But surprisingly when I open serial monitor text appears: SGP30 test, but no data.

Does anybody know where I made mistake?

This is my code:

#include <Wire.h>
#include "Adafruit_SGP30.h"

Adafruit_SGP30 sgp;

void setup() {
Serial.begin(115200);
Serial.println("SGP30 test");

if (! sgp.begin()){
Serial.println("Sensor not found :(");
while (1);
}
Serial.print("Found SGP30 serial #");
Serial.print(sgp.serialnumber[0], HEX);
Serial.print(sgp.serialnumber[1], HEX);
Serial.println(sgp.serialnumber[2], HEX);
}

void loop() {
sgp.IAQmeasure();
Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print("\t");
Serial.print("eCO2 "); Serial.println(sgp.eCO2);
delay(1000);
}
  • 1
    Did you run a i2c scanner? Do you have an other i2c sensor to check if the bus is working? Can you be more precise what the output is to the serial monitor? Is it only "SGP30 test"? then it might get stuck inside sgp.begin, that means the i2c bus is not working, perhaps shorted somewhere or the sensor module has no power. – Jot Jun 25 '18 at 3:37
  • Do you have pullup resistors on the I2C bus lines? – chrisl Jun 25 '18 at 19:46
  • I have the same problem as yours. – sunhao Nov 4 '18 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.