CCS811 and TCA9548A multiplexer

A place to hang out and chat with other like minded tinkerers

Moderator: phalanx

Post Reply
sam634
Posts: 1
Joined: Wed Nov 21, 2018 3:03 pm

CCS811 and TCA9548A multiplexer

Post by sam634 » Wed Nov 21, 2018 3:06 pm

Hello -

I am trying to use a TCA9548A multiplexer to collect data from three CCS811 sensors using 1 Arduino.
My code compiles and it runs, but I continue to get concentrations of 0.
I would appreciate feedback on my code:

#include <Wire.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>

#include "Adafruit_CCS811.h"

#define TCAADDR 0x70
/*Creating an object for each one of the sensors*/
Adafruit_CCS811 VOC1;
Adafruit_CCS811 VOC2;
Adafruit_CCS811 VOC3;



void setup() {
Serial.begin(9600);
Serial.println("CCS811 VOC Data");

}


void tcaselect(uint8_t i) {
if (i > 7) return;

Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}


void loop(void)
{
sensors_event_t event;
/* Get a new sensor event */
tcaselect(1);
Serial.print("Sensor1_ppm CO2: ");
Serial.print(VOC1.geteCO2());
Serial.print(" ");
Serial.print("Sensor1_ppb, TVOC: ");
Serial.println(VOC1.getTVOC());

tcaselect(2);
Serial.print("Sensor2_ppm CO2: ");
Serial.print(VOC2.geteCO2());
Serial.print(" ");
Serial.print("Sensor2_ppb, TVOC: ");
Serial.println(VOC2.getTVOC());

tcaselect(3);
Serial.print("Sensor3_ppm CO2: ");
Serial.print(VOC3.geteCO2());
Serial.print(" ");
Serial.print("Sensor3_ppb, TVOC: ");
Serial.println(VOC3.getTVOC());


delay(1000);
}

Thanks!

Post Reply