84 {
85 const uint8_t CMD[3] = {0xAC, 0x33, 0x00};
87
88 std::this_thread::sleep_for(
89 std::chrono::milliseconds(80));
90
91 uint8_t buf[6] = {};
93
94 if ((buf[0] & 0x80) != 0) {
95 return;
96 }
97
98
99 uint32_t raw_h = ((buf[1] << 12) | (buf[2] << 4) | (buf[3] >> 4));
100 float humidity = static_cast<float>(raw_h) * 100.0f / 1048576.0f;
101
102 if (humidity != 0.0f) {
103 humidity_ = humidity;
104 }
105
106
107 uint32_t raw_t = ((buf[3] & 0x0F) << 16) | (buf[4] << 8) | buf[5];
108 temperature_ = static_cast<float>(raw_t) * 200.0f / 1048576.0f - 50.0f;
109 }
void WriteRaw(const uint8_t *data, size_t length)
void ReadRegisters(uint8_t reg, uint8_t *buffer, size_t length)