Arduino UNO connection with a TCA9548A along with CHTA20 Sensors

Hello,

I am using a TCA9548A multiplexer to read and receive data from CHTA20 Sensors (Humidity & Temperature). I have tried running the code. However, nothing shows on the serial monitor when everything is uploaded. I am unsure if my hardware connection or the code is incorrect. Please help.

Here is my current code:

#include <Wire.h>
#include "CHTA20_Sensor.h"

CHTA20_Sensor CHTA20;  // Declare the CHTA20 Sensor object

void TCA9548A(uint8_t channel) {
  Wire.beginTransmission(0x70);
  Wire.write(1 << channel);
  Wire.endTransmission();
}

void setup() {
  Serial.begin(9600);
  Wire.begin();
  CHTA20.Initialize();
}

void loop() {
  TCA9548A(0); // Select the TCA9548A channel where your CHTA20 Sensor is connected

  CHTA20.readSensorBytes(); // Read data from the CHTA20 Sensor

  // Retrieve temperature and humidity from the CHTA20 Sensor
  float temperature = CHTA20.getTemperature();
  float humidity = CHTA20.getHumidity();

  // Print the data to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C\t");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  delay(1000);  // Adjust the delay based on your desired reading frequency
}

and here is my current hardware wiring:

Are you using a separate 5V power supply? If yes, it's not not advisable to power an Uno/Mega from both 5V and USB.

Have you tried a single CHTA20 (without the multiplexer)?

It is the same power supply.

Yes, it works fine with a single CHTA20

If you use the multiplexer, maybe you should select the correct multiplexer channel before calling CHTA20.Initialize(); I can not look in that library because I can't find it on the web and because it seems to be in your sketch directory (so something that you wrote yourself).

So sorry for the late reply. But i have tried putting TCA9548A(0); before the CHTA20.Initialize(); in void setup(). However, it still does not work for some reason.

Post a link to that library.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.