# Reading Negative Temperatures with DHT22

**URL:** <https://forum.arduino.cc/t/reading-negative-temperatures-with-dht22/953855>\
**Category:** Sensors\
**Created:** [January 31, 2022, 11:00pm UTC](https://forum.arduino.cc/t/reading-negative-temperatures-with-dht22/953855 "2022-01-31T23:00:19Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![henderjl](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@henderjl](https://forum.arduino.cc/u/henderjl)\
**Post date:** [February 3, 2022, 2:42am UTC](https://forum.arduino.cc/t/reading-negative-temperatures-with-dht22/953855/8 "2022-02-03T02:42:44Z")

</div>

In case this could help someone else who may have had this problem, I am posting the modified "simple example" that will report negative temperatures accurately with a DHT22 sensor and Arduino board.

```cpp
// Temperature and Humidity Sensor
// Uses the following Arduino libraries:
// DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor

#include <Adafruit_Sensor.h>
#include <DHT_U.h>

#define DHTPIN 1
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT_Unified dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);

  // Initialize the temperature sensor.
  dht.begin();
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
}

void loop() {
  //Read the sensor event
  sensors_event_t event;
  
  //Get temperature & print value
  dht.temperature().getEvent(&event);
  float temperature = event.temperature;  
  Serial.print(temperature);
  Serial.print(" ");
  
  //Get relative humidity and print value
  dht.humidity().getEvent(&event);
  float humidity = event.relative_humidity;
  Serial.println(humidity);
  
  delay(10000);
}
```

---

_[View the full topic](https://forum.arduino.cc/t/reading-negative-temperatures-with-dht22/953855)._
