#include <CCS811.h>
//CCS811 sensor(&Wire, /*IIC_ADDRESS=*/0x5A);
CCS811 sensor;
void setup(void)
{
Serial.begin(115200);
/*Wait for the chip to be initialized completely, and then exit*/
while(sensor.begin() != 0){
Serial.println("failed to init chip, please check if the chip connection is fine");
delay(1000);
}
/**
* @brief Set measurement cycle
* @param cycle:in typedef enum{
* eClosed, //Idle (Measurements are disabled in this mode)
* eCycle_1s, //Constant power mode, IAQ measurement every second
* eCycle_10s, //Pulse heating mode IAQ measurement every 10 seconds
* eCycle_60s, //Low power pulse heating mode IAQ measurement every 60 seconds
* eCycle_250ms //Constant power mode, sensor measurement every 250ms
* }eCycle_t;
*/
sensor.setMeasCycle(sensor.eCycle_250ms);
}
void loop() {
delay(1000);
if(sensor.checkDataReady() == true){
Serial.print("CO2: ");
Serial.print(sensor.getCO2PPM());
Serial.print("ppm, TVOC: ");
Serial.print(sensor.getTVOCPPB());
Serial.println("ppb");
} else {
Serial.println("Data is not ready!");
}
/*!
* @brief Set baseline
* @param get from getBaseline.ino
*/
sensor.writeBaseLine(0x847B);
//delay cannot be less than measurement cycle
//delay(1000);
}
But I would like to add a lcd screen so i can watch the monitor without Arduino IDE. I don't know how to to the code because i tried but it didn't work:
For what it's worth, I used to use that interface for talking to LCD screens and found it to be extremely messy and prone to issues with any poor connections.
Of recent I switched to using the 4 wire I2C interface for controlling my screens (and other peripherals -- you can add many devices all at once to the same serial bus) (I have one project working just fine with an LCD screen, OLED screen, and RTC module all controlled from the same 4 wires) and never looked back; it makes for a FAR less cluttered and far more reliable interface ... and programming it is much the same.
You can get converters that allow the typical 16 x 2 LCD to talk to the I2C bus for a few bucks.
Hi, no. With this post i asked how to print the first code (u can see that there's a serial print meaning it write something in the monitor) and i would like to print these monitor messages to a lcd screen
PS: I just had a closer look that the sensor and see that it has an I2C bus - in which case it's an absolute no-brainer to just hook an LCD screen up to the same bus (just put it in parallel) - in which case my sample code I gave you above will get you started in the right direction.
To convert your LCD to I2C just get one of these:
They can be found pretty much everywhere. Soooo much easier.