

The ATH20 is a digital sensor that measures both temperature and humidity, providing accurate readings for environmental monitoring and control applications. It is designed for ease of use, featuring a digital output that simplifies integration into microcontroller-based systems. The ATH20 is widely used in applications such as weather stations, HVAC systems, industrial automation, and IoT devices.








The ATH20 sensor has four pins, as described in the table below:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V to 5.5V) |
| 2 | GND | Ground connection |
| 3 | SDA | Serial Data Line for I²C communication |
| 4 | SCL | Serial Clock Line for I²C communication |
0x38.Below is an example of how to use the ATH20 sensor with an Arduino UNO:
#include <Wire.h>
// ATH20 I²C address
#define ATH20_ADDRESS 0x38
void setup() {
Wire.begin(); // Initialize I²C communication
Serial.begin(9600); // Start serial communication for debugging
// Initialize the sensor
if (!initializeATH20()) {
Serial.println("ATH20 initialization failed!");
while (1); // Halt execution if initialization fails
}
Serial.println("ATH20 initialized successfully.");
}
void loop() {
float temperature, humidity;
// Read temperature and humidity
if (readATH20(&temperature, &humidity)) {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
} else {
Serial.println("Failed to read from ATH20.");
}
delay(2000); // Wait 2 seconds before the next reading
}
bool initializeATH20() {
Wire.beginTransmission(ATH20_ADDRESS);
if (Wire.endTransmission() != 0) {
return false; // Sensor not found
}
return true;
}
bool readATH20(float *temperature, float *humidity) {
Wire.beginTransmission(ATH20_ADDRESS);
Wire.write(0xAC); // Command to start measurement
Wire.endTransmission();
delay(80); // Wait for measurement to complete
Wire.requestFrom(ATH20_ADDRESS, 6); // Request 6 bytes of data
if (Wire.available() != 6) {
return false; // Data not available
}
uint8_t data[6];
for (int i = 0; i < 6; i++) {
data[i] = Wire.read();
}
// Convert data to temperature and humidity
uint16_t rawHumidity = (data[1] << 8) | data[2];
uint16_t rawTemperature = (data[3] << 8) | data[4];
*humidity = (rawHumidity * 100.0) / 65536.0;
*temperature = ((rawTemperature * 200.0) / 65536.0) - 50.0;
return true;
}
No Data from Sensor:
0x38) matches the one used in your code.Inaccurate Readings:
I²C Communication Errors:
Q: Can the ATH20 operate at 3.3V?
A: Yes, the ATH20 supports an operating voltage range of 3.3V to 5.5V.
Q: Do I need external pull-up resistors for I²C communication?
A: Yes, if your microcontroller or breakout board does not have built-in pull-up resistors, you need to add 4.7kΩ resistors on the SDA and SCL lines.
Q: How often can I take measurements?
A: The sensor has a response time of less than 2 seconds, so you can take measurements approximately every 2 seconds.
Q: Can the ATH20 be used outdoors?
A: While the ATH20 can be used outdoors, it should be protected from direct sunlight, rain, and extreme conditions to ensure accurate readings and longevity.