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:
