11# Component: AHT20
2- I2C driver for Aosong AHT20 humidity and temperature sensor using esp-idf.
2+ I2C driver with Sensor Hub support for Aosong AHT20 humidity and temperature sensor using esp-idf.
33Tested with AHT20 using ESP32 and ESP32-S3 devkits.
44
55# Features
@@ -8,9 +8,9 @@ Tested with AHT20 using ESP32 and ESP32-S3 devkits.
88
99 Thread-safe via esp-i2c-driver
1010
11- CRC checksum verification (optional via menuconfig)
11+ CRC checksum verification (optional, only via menuconfig)
1212
13- Configurable I2C clock speed (pre-compilation, not runtime,via menuconfig) )
13+ Configurable I2C clock speed (pre-compilation, not runtime, only via menuconfig)
1414
1515 Unit tested
1616
@@ -45,46 +45,45 @@ Tested with AHT20 using ESP32 and ESP32-S3 devkits.
4545
4646# How To Use
4747
48- This driver includes a demo example project.
49-
50- Follow the example to learn how to initialize the driver and read the sensor data.
51-
5248All public APIs are documented in aht20.h.
5349
54-
50+ ## Driver
5551
5652Following are the general guidelines.
5753``` c
5854 // create a AHT20 device object and receive a device handle for it
59- // my_i2c_bus_handle is a preintialized i2c_bus_handle_t object
55+ // my_i2c_bus_handle here is a preintialized i2c_bus_handle_t i2c_bus object
6056 aht20_handle_t aht20_handle = aht20_create( my_i2c_bus_handle, AHT20_ADDRESS_LOW ); // addresses are in aht20.h
6157
62- // use the previously created AHT20 device handle for initializing the associated device
58+ // use the previously created AHT20 device handle for initializing the AHT20
6359 aht20_init (aht20_handle);
6460
65- //read both humidity and temperature at once from device, using AHT20 device handle
66- aht20_read_humiture(aht20_handle); //Other public APIs are documented in aht20.h.
61+ float_t temperature;
6762
68- //access the results stored in AHT20 device object, using the AHT20 device handle
69- //other apis require user to explicitly pass variable address to hold data
70- printf("tempertature = %.2fC humidity = %.3f \n", aht20_handle->humiture.temperature, aht20_handle->humiture.humidity);
63+ aht20_read_temperature( aht20_handle, &temperature);
7164
72- //to get reaw values create a object of following data type
73- aht20_raw_reading_t raw_value;
74- aht20_read_raw( aht20_handle, &raw_value);
75- printf("tempertature = %uC humidity = %u \n", raw_value.temperature, raw_value.humidity);
65+ printf("Temperature = %.2f°C\n", temperature);
66+
67+ vTaskDelay(pdMS_TO_TICKS(2000));
68+
69+ float_t temperature;
70+
71+ aht20_read_temperature( aht20_handle, &temperature);
72+
73+ printf("Temperature = %.2f°C\n", temperature);
7674```
7775
7876
79- # How to Configure CRC and I2C clock speed
77+ ## How to Configure CRC
8078Additionally, select in menuconfig under Component Config → AHT20; to use CRC(default is not used)
8179or change the clock speed of device (default is 100KHz).
8280
8381Note : It is recommended to use clock speeds in upper ranges of 100kHz to 200kHz.
8482Higher clock speeds may cause occasional data inconsistencies depending on your board layout and wiring.
8583
86- 
84+ 
85+
8786
8887or
8988In sdkconfig under Component Config → AHT20,
90- 
89+
0 commit comments