Other Arduino Codes and Videos by Robojax

Arduino code and video for DHT11 Temperature and Humidity Sensor

This is the Arduino code and video for DHT11 Temprerature and Humidity Sensor

This video shows you how to use DHT11 to measure Temperature, humidity and disply in serial monitor or use for other perpose. it shows in http://robojax.com/learn/arduino/
  1. DHT11 Library on GetHub
  2. DHT11 Manual
  3. DHT11 Library from Robojax.com

 * This is the Arduino code for  DHT11 module to read temprature and humidity
 * This code can display temprature in:
 * C is used to get Celsius
 * F is used to get fahrenheit
 * K is used for Kelvin
 * Watch the video https://youtu.be/FjZBt6eU9b4
 *  * 
 * Written by Ahmad Nejrabi for Robojax Video
 * Date: Jan 04, 2018, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.

// header file from GetHub: https://github.com/adidax/dht11
#include <dht11.h>

dht11 DHT11; // create object of DHT11
#define dhtpin 2 // set the pin to connect to DHT11

void setup() {
    Serial.begin(9600);// setting up serial monitor


void loop() {
  DHT11.read(dhtpin);// initialize the reading
  //code for Robojax.com video
  int humidity = DHT11.humidity;// get humidity

   Serial.print("C ");
   Serial.print("F ");
   Serial.print("K ");
   Serial.print(" humidity:");
   Serial.print (humidity);
   Serial.println("% ");

 * getTemp(char type)
 * type character of upper case 
 * C is used to get Celsius
 * F is used to get fahrenheit
 * K is used for Kelvin
float getTemp(char type) {
    float temp = (float)DHT11.temperature;//get temp
  if(type =='F')
    return temp * 1.8 + 32;// convert to fahrenheit
  }else if(type =='K')
    return temp + 274.15;// convert to Kelvin
   return temp; 


If you found this tutorial helpful, please support me so I can continue creating content like this. You can support me on Patreon ( Launched June 14, 2019): http://bit.ly/2ZnITLz

Or support me via PayPal