Documentation of lib commands ah10 and tc9548a

I cannot find the definition of the following commands that I think executed in the libraries
I have a TCA9548 I2CScanner connected to two AHT10 temp/hum transducers.
I ran the example of the TCA9548 I2CScanner with one AHT10 attached to the mux and was successful. Then ran the adafruit_AHT10_test with one sensor and was also successful.

I found this Adafruit doc "Wiring & Test | Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout | Adafruit Learning System" and the plan to modify the .ini file that uses 2 HMC5883 and replace the references to the HMC with the AHT. include the following libraries:

I want to learn the meaning of the commands in order to understand what they do based on some form of documentation.

e.g.
sensor_t sensor; mag->getSensor(&sensor), tcaselect(unit8_t i), serial println("ut"), Wire.beginTransmission(TCAADDR), WIRE.WRIT3(1<< i), Wire.end transmission(), etc

I could not find these in the Arduino documentation. I can guess their meaning from the context but like to understand them better for future programming.

I am lost. Please help.

Thanks
Jim

Can you recommend a url, or book, that helps explain these

Wire.h
Adafruit_Aht10.h

Have you looked at the code in the library files ?

Is the " code in the library files" the Wire.h file and Adafruit_AHT10.h? I can read it but do not understand, for example, where the variables TCAADDR and the function tcaselect() are in this documentation.

I have perused the Adafruit_AHD10.h, but could not find the variable "aht" in the ini statement if(! aht.begin()), for example. I found "begin()", but do not know what it means in this context.

Please send me a helpful link.
Jim

Right here:
https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/wiring-and-test

#define TCAADDR 0x70

TCAADDR is a macro with the value 0x70.

Also on that page:
https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/wiring-and-test

void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}

Neither of these are part of the library. They are the sketch code. That's why you won't find them in the library source code.

It's here:
https://github.com/adafruit/Adafruit_AHTX0/blob/2.0.1/examples/adafruit_aht_test/adafruit_aht_test.ino#L3

Adafruit_AHTX0 aht;

aht is an object of type Adafruit_AHTX0. Adafruit_AHTX0 is a class declared by the "Adafruit AHTX0" library, but aht is just an arbitrary name. You could choose any name you like for this object in your sketch. For example:

Adafruit_AHTX0 foo;

is functionally equivalent (though of course you should always use descriptive and meaningful names).

All these things are fundamentals of the Arduino programming language, but if you go looking in the Arduino Language Reference, you might not find some of this because it is not a complete documentation of the language. One of the things that is not well documented is that Arduino Programming Language is essentially just C++, and any valid C++ is also valid Arduino language (though the opposite is not true). So you will be well served in your Arduino endeavors by studying the C++ programming language.

I like this C++ tutorial:
https://www.cplusplus.com/doc/tutorial/
Some of the information is not of use for embedded systems like our Arduino boards, so you'll need to follow your intuition in gleaning the useful information.

There is also some more advanced topics that you might not have an immediate need for. My recommendation is to skim through for an overview, study and experiment with what is interesting, and take note of the rest in case you might want to refer back to it later.

Thanks

I would never have found this.

Got my path forward thanks to you.
I will work on this.

Jim

Read some C++ pages and thought I assembled my sketch to read the muxed sensors based on your links. I got 26 errors (YIKES). I checked spelling and spacing and they were OK.
This is my program with comments on what each line does.

tca9548a_and_2_AHT10.ino (2.2 KB)

Any suggestions?
Jim

Also, read more of the C++ and tried to use the Arduino IDE to execute C++ examples but could not compile. I assumed that I could use either c++ or Arduino language but could not find any way to change the language to C++. I assumed that I could use C++ as the programming language based on what you said earlier:

"One of the things that is not well documented is that Arduino Programming Language is essentially just C++, and any valid C++ is also valid Arduino language (though the opposite is not true). So you will be well served in your Arduino endeavors by studying the C++ programming language."

I will continue to slug through the tutorial and maybe be enlightened on some of the unreferenced stuff about librarys like "public", "private" etc and where to get my functions and arguments from.

Thanks
Jim

Please post the code and the full error output from compiling it. Then we can help you out.

There's no need to change the language. Just put the C++ code in your sketch. It will be compiled as C++.

I have explained my compilation issue in the first comment block /* */.

I have combined examples for the TC mux and the AH10. I don't understand the compilation error. Please advise.

My Code


/* Jim Moroz's attempt to combine mux and AHT examples

copied and pasted from the library examples code from:

  1. BasicUaageini from the TCA9548A

  2. adafruit_aht10_testlib from the Adafruit AHT10

My compile error:

Cc:\Users\jgmor\OneDrive\Documents\Arduino\TCA and AHT V1\TCA and AHT V1.ino:15:43: error: missing terminating > character

I2CMux.closeAll(); // Set a base state which we know (also the default state on power on)

                                       ^

Compilation error: Error: 2 UNKNOWN: exit status 1

*/

#include "TCA9548A.h" // Lib for mux

#include <Adafruit_AHT10.h // Lib for AHT

#include <Wire.h> // Included this library because of a compillation error

TCA9548A I2CMux; // Address can be passed into the constructor

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

// 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=0x70; //hex address of the mux HMC5883L via I2C

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

}


Thanks
Jim

As the error says, that line has a:

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:

  1. BasicUaageini from the TCA9548A

  2. 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.

I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Check the box next to "Show verbose output during: compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE's menus.
  5. Wait for the compilation to end.
  6. Right click on the black "Output" pane at the bottom of the Arduino IDE 2.x window.
  7. From the context menu, click Copy All.
  8. Open a forum reply here by clicking the Reply button.
  9. Click the </> icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  10. Press Ctrl+V. This will paste the compilation output into the code block.
  11. Move the cursor outside of the code tags before you add any additional text to your reply.
  12. Click the Reply button to post the output.
Compilation error: Error: 2 UNKNOWN: no FQBN provided

I was expecting a lot more. Hope this is helpful.

Thanks
Jim

It is helpful!

You get this error when you haven't selected a board in the Arduino IDE (FQBN is an acronym for "fully qualified board name"). So the only thing you need to do is select your Arduino board from the Arduino IDE's Tools > Board menu.

If you don't see your board on that menu, it probably means you need to install the boards platform for it via Boards Manager (Tools > Board > Boards Manager). If you have trouble with that, you can tell us which board you have and we'll provide detailed instructions.

Just got released from the hospital and revisiting my problem. The omission is obvious if you know the explanation of the error codes.

Where can I find them?

I corrected the error and came up with another error about the Wire Library that I have not included. So I included it and came up with this error:

Using board 'uno' from platform in folder: C:\Users\jgmor\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2
Using core 'arduino' from platform in folder: C:\Users\jgmor\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2
Detecting libraries used...
"C:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino" "-IC:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\standard" "C:\\Users\\jgmor\\AppData\\Local\\Temp\\arduino-sketch-3AC2EB01025F276FCF46DB7637E563AC\\sketch\\TCA and AHT V4.ino.cpp" -o nul
Alternatives for Audrino.h: []
ResolveLibrary(Audrino.h)
  -> candidates: []
Compilation error: Error: 2 UNKNOWN: exit status 1

Please tell me how to interpret this.

My code is:

/* Jim Moroz's attempt to combine mux and AHT examples. program TCA and AHT V1.ino
copied and pasted from the library examples code from:
1. BasicUaageini from the TCA9548A 
2. adafruit_aht10_testlib from the Adafruit AHT10
My compile error:

*/


#include "TCA9548A.h"  // Lib for mux
#include <Audrino.h>  // Lib for Audrino from the example program TCA9548A
#include <Adafruit_AHT10> // Lib for AHT10
#include <Wire.h> // inserted beacuse compile error suggested it needs to be included



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
   //  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);
}

Thanks
Jim

This error usually means that you have not installed the library that provides the file of that name. Most often, you can search for the library in the Arduino Library Manager (accessible via Sketch > Include Library > Manage Libraries... in the Arduino IDE menus), then install it there. The one thing you should be aware of is that the header file names don't necessarily always match the library name, so you might have to be a bit creative in your search keywords, and maybe try your luck on Google if you don't find the library in Library Manager.

But I'm wondering about this specific file "Audrino.h". Perhaps it's a play on the name "Arduino", or maybe you just spelled the file name wrong and you actually meant to write "Arduino.h"? If the latter, then there is no need to install the library because it is part of each Arduino boards platform, which you will have already installed on your computer.