In this tutorial, we are going to to program the circuit with the code. This lesson is divided into two parts. In part 1 we will install the DHT11 library in Arduino IDE and program it with the default code. And in the second part we will program our breadboard circuit with the code to display temperature and humidity captured from sensor on our 128x64 I2C OLED display.
We will first download the dht11 library for arduino.
1. Go to : https://github.com/adafruit/DHT-sensor-library and download the zip library.
2. Now add the downloaded library in your Arduino IDE. If you don't know how to add library in arduino IDE, see this tutorial : "Adding External library in Arduino IDE"(Follow only still step 3 and come back here).
3. Now you will need one more file for running this library. For that goto : https://github.com/adafruit/Adafruit_Sensor and download the zip file.
4. Extract the zip file, and go inside the folder. And copy "Adafruit_sensor.h"
5. Now got "Documents->Arduino->libraries->DHT-sensor-library-master" and paste the file their.
6. Now Open your Arduino IDE and goto "File->Examples->Dht sensor library->dht tester" and click their.
7. An example code will open. Now, you need to do two changes in the example code. Now change the DHT pin to 10 "#define DHTPIN 10" in the code as shown bellow.
8. And then go and uncomment the line "#define DHTTYPE DHT11" and comment the two lines below it. We are doing it because we are using DHT11 Sensor.
9. Now upload the code in the Arduino and open your serial terminal(make sure your settings are similar to the serial terminal as shown below).
You have succesfully tested the library and the circuit. Now in the next tutorial, I will explain step by step for programming your Arduino Leonardo Pro Micro to display the DHT11 data on the OLED screen.