Introduction: Interfacing DHT Sensor With OLED & ArduinoUno

Picture of Interfacing DHT Sensor With OLED & ArduinoUno

Hello, Makers!!

In this Instructable, I'll show you how to Interface DHT sensor with OLED using the ArduinoUNO.

For example, growing plants require specific temperature and humidity to be maintained, in this instructable I'm going to show you how to make a device that measures the humidity data and temperature data and displays it on an OLED screen.

Step 1: Components Required

Picture of Components Required

Here is the list of components required to get started with the Instructable,
Hardware Components

  • Arduino Uno
  • DHT11
  • 0.96” SSD1306 OLED
  • Bread Board
  • Jumper Wires
  • Micro USB Cable

Software Components

  • Arduino IDE

Step 2: Description

Picture of Description

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on the data pin (no analog input pins needed). It's fairly simple to use but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using library, sensor readings can be up to 2 seconds old

Step 3: DHT11 Connection

Picture of DHT11 Connection

Wiring the DHT11 to the Arduino Uno is really easy, but the connections are different depending on which type you have either 3-pins or 4-pins.

The wiring connections are made as follows :

  • Pin 1 of the DHT11 goes into GND of the Arduino Uno.
  • Pin 2 of the DHT11 goes into +5V of the Arduino Uno.
  • Pin 3 of the DHT11 goes into Digital Pin 7 of the Arduino Uno.

Step 4: DHT Library Setup

DHT sensor can be easily coded with a library file called dhtlib. dhtlib, this library can be used for reading both values from DHT sensors. The DHT11 only returns integers (e.g. 20) and does not support negative values

The library file can be downloaded by following steps

1. Go to > Sketch

2. Include Library

3. Manage Library

4. Download dhtlib library file Or you can download the attached file below.

Step 5: OLED Connection

Picture of OLED Connection

Connection scheme:

  • CS pin of the OLED is connected to Digital Pin 8 of the ArduinoUNO.
  • DC of the OLED is connected to Digital Pin 9 of the ArduinoUNO.
  • Reset of the OLED is connected to Digital Pin 10 of the ArduinoUNO.
  • SDA of the OLED is connected to Digital Pin 11 of the ArduinoUNO.
  • SCK of the OLED is connected to Digital Pin 12 of the ArduinoUNO.
  • VDD of the OLED is connected to 5v of the ArduinoUNO.
  • GND of the OLED is connected to ground (GND) pin of the ArduinoUNO.

Step 6: OLED Library Setup

Picture of OLED Library Setup

OLED can be easily coded with a library file called Ug8lib. Ug8lib is a graphics library which supports many different monochrome displays.

The library file can be downloaded by following steps

1. Go to > Sketch

2. Include Library

3. Manage Library

4. Download U8g lib library file Or you can download from the link attached below.

"U8glib_Arduino"

Step 7: CODE

<p>#include <U8glib.h>

#include <dht.h>

dht DHT;
#define DHT11_PIN 7

U8GLIB_SSD1306_128X64

u8g(12, 11, 8, 9, 10); // arduino HW SPI com: SCK = 12,SDA = 11,CS = 8,DC = 9,RES = 10

void setup() {
/* nothing to do here */
}

void loop()
{
   u8g.firstPage();  
     
   /* Keep looping until finished drawing screen */
  do 
  {
    
   u8g.setFont(u8g_font_osb18);

   int chk = DHT.read11(DHT11_PIN);

   char dht_str[8];
   itoa(DHT.temperature,dht_str,10);
   u8g.drawStr(20, 20, "T:");
   u8g.drawStr(50, 20, dht_str);
   u8g.drawStr(80, 20, "C");</p><p>    itoa(DHT.humidity,dht_str,10);
   u8g.drawStr(20, 60, "H:");
   u8g.drawStr(50, 60, dht_str);
   u8g.drawStr(80, 60, "%");
   
  delay(1000);
  
 } while(u8g.nextPage());
}

Step 8: OUTPUT

Picture of OUTPUT

That's all Makers.

You have successfully completed another instructable, It takes pretty less time to create this instructable, and it's fun too.

Comments

About This Instructable

154views

7favorites

License:

Bio: Work until you no longer have to introduce yourself.
More by TheCircuit:Carrot Almond MilkshakeDIY - Flower VasePotato Stuffing - Who's Hungry
Add instructable to: