0

I have connected trinket and CCS811 I am trying to build and upload sketch to the module:

  /******************************************************************************
  Read basic CO2 and TVOCs

  Marshall Taylor @ SparkFun Electronics
  Nathan Seidle @ SparkFun Electronics

  April 4, 2017

  https://github.com/sparkfun/CCS811_Air_Quality_Breakout
  https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library

  Read the TVOC and CO2 values from the SparkFun CSS811 breakout board

  A new sensor requires at 48-burn in. Once burned in a sensor requires
  20 minutes of run in before readings are considered good.

  Hardware Connections (Breakoutboard to Arduino):
  3.3V to 3.3V pin
  GND to GND pin
  SDA to A4
  SCL to A5

******************************************************************************/
#include <Wire.h>

#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811

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

CCS811 mySensor(CCS811_ADDR);

#include <SoftwareSerial.h>
const int rx = 0; //3
const int tx = 2; //4
const int alarmPin = 4;
SoftwareSerial mySerial(rx, tx);




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

  Wire.begin(); //Inialize I2C Hardware

  pinMode(alarmPin, OUTPUT);
}

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();

    mySerial.print("CO2[");
    //Returns calculated CO2 reading
    double val = mySensor.getCO2();
    mySerial.print(val);
    if(val>=2000){
      digitalWrite(alarmPin, HIGH); 
    }
    //Serial.print("] tVOC[");
    //Returns calculated TVOC reading
    //Serial.print(mySensor.getTVOC());
    //Serial.print("] millis[");
    //Display the time since program start
    //Serial.print(millis());
    //Serial.print("]");
    //Serial.println();
  }

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

However when I verify the sketch I get following errors:

In file included from C:\Users\Nitin\Desktop\co2\co2.ino:26:0:

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:77:28: error: 'TwoWire' has not been declared

  CCS811_Status_e beginCore(TwoWire &wirePort);

                            ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:97:2: error: 'TwoWire' does not name a type; did you mean 'Wire'?

  TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware

  ^~~~~~~

  Wire

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:112:13: error: 'TwoWire' has not been declared

  bool begin(TwoWire &wirePort = Wire);         //Use the Wire hardware by default

             ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:113:34: error: 'TwoWire' has not been declared

  CCS811_Status_e beginWithStatus(TwoWire &wirePort = Wire);    //Use the Wire hardware by default

                                  ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:112:33: error: could not convert 'Wire' from 'TinyM_USI_TWI' to 'int&'

  bool begin(TwoWire &wirePort = Wire);         //Use the Wire hardware by default

                                 ^~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:113:54: error: could not convert 'Wire' from 'TinyM_USI_TWI' to 'int&'

  CCS811_Status_e beginWithStatus(TwoWire &wirePort = Wire);    //Use the Wire hardware by default

                                                      ^~~~

Multiple libraries were found for "Wire.h"
 Used: C:\Users\Nitin\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.13\libraries\Wire
 Not used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Multiple libraries were found for "SparkFunCCS811.h"
 Used: C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library
 Not used: C:\Users\Nitin\Documents\Arduino\libraries\arduino_613982
Using library Wire at version 1.0 in folder: C:\Users\Nitin\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.13\libraries\Wire 
Using library SparkFun_CCS811_Arduino_Library at version 2.0.1 in folder: C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library 
Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial 
exit status 1
Error compiling for board Adafruit Gemma (ATtiny85 @ 8MHz).

I see that this library - SparkFun_CCS811_Arduino_Library is not compatible with trinket https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/issues/19

can anyone give me pointer to write sketch for trinket connected to CCS811 sensor?

1
  • read the error printout carefully ... what is it telling you?
    – jsotola
    Jun 7 '20 at 1:03
1

Looks like you have two choices

  • Use a different controller that is compatible with the normal Arduino Wire library - maybe something like the Nano?
  • Modify SparkFunCCS811.h to #include TinyWireM.h instead of Wire.h. This is actually not hard at all - just takes a bit of patience and the knowledge that "there is no magic".

Frank

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.