0

I have sparkfun indoor air quality sensor CCS811 which needs to be interfaced with arduino. I have soldered wires on the sensors and connected with arduino. Have checked the connection with multimeter so that part works. But even using example code on library still I am not getting reading from sensor.

Code:-

#include <Wire.h>

#include "SparkFunCCS811.h" 

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

CCS811 mySensor(CCS811_ADDR);

void setup()
{
  Serial.begin(9600);
  Serial.println("CCS811 Basic Example");

  Wire.begin(); //Inialize I2C Harware

  //It is recommended to check return status on .begin(), but it is not
  //required.
  CCS811Core::status returnCode = mySensor.begin();
  if (returnCode != CCS811Core::SENSOR_SUCCESS)
  {
    Serial.println(".begin() returned with an error.");
    //while (1); //Hang if there was a problem.
  }
}

void loop()
{
  //Check to see if data is ready with .dataAvailable()
  if (mySensor.dataAvailable())
  {
    //If so, have the sensor read and calculate the results.
    //Get them later
    mySensor.readAlgorithmResults();

    Serial.print("CO2[");
    //Returns calculated CO2 reading
    Serial.print(mySensor.getCO2());
    Serial.print("] tVOC[");
    //Returns calculated TVOC reading
    Serial.print(mySensor.getTVOC());
    Serial.print("] millis[");
    //Simply the time since program start
    Serial.print(millis());
    Serial.print("]");
    Serial.println();
  }

  delay(10); //Don't spam the I2C bus
}

enter image description here

enter image description here enter image description here

Things I tried:- 1) different combination of A4, A5 pins 2) 0x5A & 0x5B i2c address 3) using wake pin with ground 4) using 3.3 & 5V for powering sensor

What else needs to be done?

  • Don't supply the sensor with 5V. It's datasheet states 3.6V as maximum. You can destroy it with 5V – chrisl Jan 6 at 13:11
  • We cannot see, how you connected the sensor. A4 is the SDA pin, A5 is SCL. You need to connect them to the corresponding sensor pin. Also I2C is not made for long wires. Try to add strong pullup resistors to both lines (maybe 4.7kOhm). – chrisl Jan 6 at 13:13
  • @chrisl will keep them in mind. SDA is connected to A4 and SCL is A5 so not a problem, have uploaded the wiring image above. Wires are around 50cm long so I thought it will be fine. Pull up resistors on SDA & SCL line? – suu Jan 6 at 17:00
  • Yes, one pullup resistor for each of both lines. And 50cm is already rather long (I2C is made for communication between ICs on the same PCB or similar distances, so a few cm). Strong pullups might help, if your issue is related to this. – chrisl Jan 6 at 17:48
  • thanks for helping, the problem was on the soldering part so it's solved. Moreover, I have used i2c at 1m wire where I connected Arduino and LCD which worked. Just sharing my experience if it helps. – suu Jan 7 at 6:30
1

The problem was on the soldering part. SDA & 3.3V pin on sensor were slightly in contact. I modified it and started working fine.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.