src/esp_dht22/esp_dht22.c
/**
 * Calculate temperature.
 *
 * @param data The pointer to 5 bytes read from the bus.
 *
 * @return Temperature in Celsius.
 */
Calculate temperature.
@param data The pointer to 5 bytes read from the bus.

@return Temperature in Celsius.
Calculate temperature . @param data The pointer to 5 bytes read from the bus . @return Temperature in Celsius .
static float calc_temp(const uint8_t *data)
{
  float temp = data[2] & 0x7F;
  temp *= 0x100;
  temp += data[3];
  temp /= 10;
  if ((data[2] & 0x80) > 0) temp *= -1;
  return temp;
}
static float calc_temp ( const uint8_t * data ) { float temp = data [ 2 ] & 0x7F ; temp *= 0x100 ; temp += data [ 3 ] ; temp /= 10 ; if ( ( data [ 2 ] & 0x80 ) > 0 ) temp *= -1 ; return temp ; }
Calculate temperature.
Calculate temperature .
// Remove negative temp indicator bit.