Photon: SGP30 Sensor not found

Hey y’all,

I am putting together an IoT enviromental sensor suite and was hoping I could get some help with my SGP30 gas sensor. I haven’t found any problems like it on the discussion boards, so hopefully it’s just a newbie fix.

I am using a photon with firmware 1.5.0 and am flashing code from the Web IDE.

I’m using the Adafruit_SGP30 library and example file from the libraries included on the Web IDE and I’m using the particle serial monitor to watch the results after flashing. Currently I’m working with this message from the I2C debug.

SGP30 test
Sensor not found :(
                -> 0x36, 0x82,
                <- 0x0, 0x0, 0x81, 0x0, 0xCA, 0x1D, 0x42, 0x34, 0xD0,
                CRC calced: 0x81 vs. 0x81
                Read: 0x0
                CRC calced: 0x1D vs. 0x1D
                Read: 0xCA
                CRC calced: 0xD0 vs. 0xD0
                Read: 0x4234
                -> 0x20, 0x2F,
                <- 0x0, 0x22, 0x65,
                CRC calced: 0x65 vs. 0x65
                Read: 0x22

I thought my sensor was not connected correctly, but upon using the i2c_scanner tool it was found at address 0x58 which is correct.

Here’s the code from the example sketch:

// Example usage for Adafruit_SGP30 library.
// This library was modified/wrapped by SJB (
// in order to work with Particle Photon & Core.

 #include "Particle.h"
 #include "Adafruit_SGP30.h"

 Adafruit_SGP30 sgp;

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

   // If you have a baseline measurement from before you can assign it to start, to 'self-calibrate'
   //sgp.setIAQBaseline(0x8E68, 0x8F41);  // Will vary for each sensor!

 int counter = 0;
 void loop() {
   if (! sgp.IAQmeasure()) {
     Serial.println("Measurement failed");
   Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
   Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");

   if (counter == 30) {
     counter = 0;

     uint16_t TVOC_base, eCO2_base;
     if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) {
       Serial.println("Failed to get baseline readings");
     Serial.print("****Baseline values: eCO2: 0x"); Serial.print(eCO2_base, HEX);
     Serial.print(" & TVOC: 0x"); Serial.println(TVOC_base, HEX);

Any ideas?


Welcome - why not take a look at this previous post - it will probably answer your questions

From your log it appears that the sgp.begin() fails here

  if (featureset != SGP30_FEATURESET)
    return false;

The library expects a value of 0x0020 exactly but your sensor returns 0x0022 which would indicate “better” featureset than what’s required.
The latest versino of the original Adafruit library does the check this way if ((featureset & 0xF0) != SGP30_FEATURESET)

I filed a pull request for that change.

However, it’s not certain this will be reuploaded/republished anytime soon, so it’s probably best for you to pull in the library sources and add these changes yourself.

This worked! Thanks for your help. Out of curiosity, how did you figure out the 0xF0 part of your code?

That is how Adafruit did it in their latest update to their own library.
This way they would accept anything that starts with 0x002? but are not interested in the least significant digit.
Not bullet proof IMO, but it works.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.