AHT20 is a new generation of temperature and humidity sensor embedded with a dual-row flat and no-lead SMD package, suitable for the reflow soldering. AHT20 is equipped with a newly designed ASIC chip: an improved MEMS semiconductor capacitive humidity sensor, and a standard on-chip temperature sensor.
// ARDUINO DEMO FOR GROVE-AHT20
//
#include <Wire.h>
#include "AHT20.h"
AHT20 AHT;
void setup()
{
Serial.begin(115200);
Serial.println("AHT20 DEMO");
AHT.begin();
}
void loop()
{
float humi, temp;
int ret = AHT.getSensor(&humi, &temp);
if(ret) // GET DATA OK
{
Serial.print("humidity: ");
Serial.print(humi*100);
Serial.print("%\t temerature: ");
Serial.println(temp);
}
else // GET DATA FAIL
{
Serial.println("GET DATA FROM AHT20 FAIL");
}
delay(100);
}
// END FILE
Initializing the AHT20
AHT.begin();
get all data of sensor
int ret = AHT.getSensor(&humi, &temp);
get Temperature of sensor
int ret = AHT.getTemperature(&temp);
get Humidity of sensor
int ret = AHT.getHumidity(&humi);