Arduino Uno DHT Sensor Control Code

DHT sensors can measure temperature and humidity. You can receive fresh measurements every 2 seconds in the form of digital signals. DHT11 can sense temperature from 0 to 50 °C and humidity from 20 to 80% RH. DHT22 can sense temperature from -40 to 80 °C and humidity from 0 to 100% RH. The DHT Controller Device manages communication between a DHT sensor and the current Ozeki software.

arduino uno dht sensor
Figure 1 - Arduino Uno DHT Sensor

Required hardware

  • Arduino Uno
  • DHT11 or DHT22 sensor
  • Resistor 4.7kΩ

Source code to install on controller

Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h>
#include <OzDHTSensor.h>

// global pointers
OzIDManager* manager;
OzDHTSensor* dhtTemperature;
OzDHTSensor* dhtHumidity;

void setup()

  // instantiate objects
  manager = new OzIDManager;
  manager->_sendACK = true;
  manager->_checksum = true;

  //DHT11 sensor connected to D2 pin
  dhtTemperature = new OzDHTSensor(DHT11,DHTMode::Temperature,2);
  dhtHumidity = new OzDHTSensor(DHT11,DHTMode::Humidity,2);
  //Set it to DHT22 if using DHT22

  // welcome devices
  int x = 1;
  manager->PrintWelcomeLine(dhtTemperature, x++, "TemperatureSensor_1");
  manager->PrintWelcomeLine(dhtHumidity, x++, "HumiditySensor_1");

void loop()

More information