I have made progress understanding the documentation embedded in the .h and the examples. I got my knowledge from the tutorial on writing your own libraries. This was helpful in understanding some of the information the "public:" and what goes into my .ini code.
I am down to one compilation error that I don't know where to find any explanations for this error.
My code:
/* Jim Moroz's 4th attempt to combine mux and AHT examples. program TCA and AHT V4.ino
copied and pasted from the library examples code from:
-
BasicUaageini from the TCA9548A
-
adafruit_aht10_testlib from the Adafruit AHT10
My compile error:
Compilation error: Error: 2 UNKNOWN: exit status 1
*/
#include "TCA9548A.h" // Lib for mux
#include <Audrino.h> // Lib for Audrino from the example program TCA9548A
#include <Adafruit_AHT10> // Lib for AHT10
TCA9548A I2CMux; // Address can be passed into the constructor
Adafruit_AHT10 aht; //aht is an object of type Adafruit_AHTX0. Adafruit_AHTX0 is a class declared by the "Adafruit AHTX0" library
void setup() {
Serial.begin(9600); //from the TCA9548A example which conflicts with the AHT10 example that uses 115200
// IGNORED: Wire.setPins(21, 22); // ESP32 users, use setPins(sda, scl) if customised, before passing Wire to the library (the line below).
I2CMux.begin(Wire); // Wire instance is passed to the library
I2CMux.closeAll(); // Set a base state which we know (also the default state on power on)
}
void loop()
{
I2CMux.openChannel(0);
/* Code to interactive with revealed address on bus */
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
Serial.println("Chan 0 Temperature: "); Serial.println(temp.temperature); Serial.println(" degrees C");
Serial.println("Chan 0 Humidity: "); Serial.println(humidity.relative_humidity); Serial.println("% rH");
I2CMux.closeChannel(0);
I2CMux.openChannel(1);
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
Serial.println("Chan 1 Temperature: "); Serial.println(temp.temperature); Serial.println(" degrees C");
Serial.println("Chan 1 Humidity: "); Serial.println(humidity.relative_humidity); Serial.println("% rH");
I2CMux.closeChannel(1);
Delay (500);
}
Please advise.