stm32-dht22-ReadByte

by Marwen Maghrebi
uint8_t read_byte(void) {
    uint8_t num = 0;
    for (i = 0; i < 8; i++) {
        while (!HAL_GPIO_ReadPin(DHT22_GPIO_Port, DHT22_Pin)) {};
        __HAL_TIM_SET_COUNTER(&htim1, 0);
        while (HAL_GPIO_ReadPin(DHT22_GPIO_Port, DHT22_Pin)) {};
        if (__HAL_TIM_GET_COUNTER(&htim1) > 40) // 40μs threshold
            num |= (1 << (7 - i));
    }
    return num;
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00