There was an error while loading. Please reload this page.
Welcome to the aht20 wiki!
C++ example
https://github.com/Seeed-Studio/Seeed_Arduino_AHT20/blob/master/src/ATH20.cpp
unsigned char str[6]; int index = 0; while (Wire.available()) { str[index++] = Wire.read(); // receive a byte as character } if(str[0] & 0x80)return 0; unsigned long __humi = 0; unsigned long __temp = 0; __humi = str[1]; __humi <<= 8; __humi += str[2]; __humi <<= 4; __humi += str[3] >> 4; *h = (float)__humi / 1048576.0; __temp = str[3]&0x0f; __temp <<=8; __temp += str[4]; __temp <<=8; __temp += str[5]; *t = (float)__temp / 1048576.0 * 200.0 - 50.0;
Elixir equivalent
# 7 bytes (56 bits) raw_data_from_sensor = <<28, 38, 154, 118, 66, 231, 118>> <<_state::8, humi::20, temp::20, _crc::8>> = raw_data_from_sensor humiduty_rh = humi * 100 / 1048576 temperature_c = temp * 200 / 1048576 - 50