SparkFun Forums 

Where electronics enthusiasts find answers.

By sam634
#201101
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!
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]