Arduino Nano 33 IoT - DHT11

This tutorial explains how to use the Arduino Nano 33 IoT to measure temperature and humidity with a DHT11 sensor and show the readings on the Serial Monitor. It includes simple steps for both the DHT11 sensor and the DHT11 module.

Arduino Nano 33 IoT DHT11 Temperature and humidity Sensor

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×DHT11 Temperature Humidity Sensor Module
1×10 kΩ resistor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of DHT11 Temperature and Humidity Sensor

DHT11
The humidity range 20% to 80%
The humidity accuracy 5%
The temperature range 0°C to 50°C
The temperature accuracy ± 2°C
The reading rate 1Hz (one time per second)
Operating Voltage3 to 5V

DHT11 Pinout

The DHT11 is available in two types: a basic sensor and a module.

DHT11 sensor module Pinout

The DHT11 sensor has four pins:

  • GND pin: Connect this pin to ground (0V).
  • VCC pin: Connect this pin to the power source (3.3V or 5V).
  • DATA pin: This pin is used for sending and receiving information between the sensor and the Arduino Nano 33 IoT.
  • NC pin: Do not connect anything to this pin.

We strongly recommend using the DHT11 module. This module comes with a built-in resistor and only three pins: VCC, GND, and DATA (or, alternatively, +, -, and OUT).

Wiring Diagram between DHT11 and Arduino Nano 33 IoT

The wiring for the Arduino Nano 33 IoT is the same for both sensors. In the original setup, you need a resistor between 5K and 10K ohms to keep the data line high. This allows the sensor and the Arduino Nano 33 IoT to communicate with each other.

Arduino Nano 33 IoT - DHT11 Sensor Wiring

The wiring diagram between Arduino Nano and 33 IoT DHT11 Temperature and humidity Sensor

This image is created using Fritzing. Click to enlarge image

Arduino Nano 33 IoT - DHT11 Module Wiring

Most DHT11 sensor modules already have a resistor built in, so you don't have to add one. This helps you avoid extra wiring or soldering work.

The wiring diagram between Arduino Nano and 33 IoT DHT11 Temperature and humidity Module

This image is created using Fritzing. Click to enlarge image

Arduino Nano 33 IoT Code - DHT11

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-dht11 */ #include <DHT.h> #define DHT11_PIN 3 // The Arduino Nano 33 IoT pin D31 connected to DHT11 sensor DHT dht11(DHT11_PIN, DHT11); void setup() { Serial.begin(9600); dht11.begin(); // initialize the DHT11 sensor } void loop() { // read humidity float humi = dht11.readHumidity(); // read temperature in Celsius float temperature_C = dht11.readTemperature(); // read temperature in Fahrenheit float temperature_F = dht11.readTemperature(true); // check whether the reading is successful or not if ( isnan(temperature_C) || isnan(temperature_F) || isnan(humi)) { Serial.println("Failed to read from DHT11 sensor!"); } else { Serial.print("Humidity: "); Serial.print(humi); Serial.print("%"); Serial.print(" | "); Serial.print("Temperature: "); Serial.print(temperature_C); Serial.print("°C ~ "); Serial.print(temperature_F); Serial.println("°F"); } // wait a 2 seconds between readings delay(2000); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Open the Library Manager by clicking the Library Manager icon on the left side of the Arduino IDE.
  • In the search box, type DHT and find the DHT sensor library made by Adafruit.
  • Click the Install button to add the library.
Arduino Nano 33 IoT DHT sensor library
  • A window will pop up asking if you want to install the parts needed for the library.
  • Click the Install All button to add all the required parts.
Arduino Nano 33 IoT Adafruit Unified sensor library
  • Copy one of the codes above and open it with the Arduino IDE.
  • Compile and send the code to the Arduino Nano 33 IoT board by clicking the Upload button in the Arduino IDE.
  • Change the sensor’s temperature by making it colder or warmer. For example, place the sensor near a hot cup of coffee.
  • See the result in the Serial Monitor. It will look like the example shown below.
COM6
Send
Humidity: 31.00% | Temperature: 27.00°C ~ 80.60°F Humidity: 31.00% | Temperature: 27.00°C ~ 80.60°F Humidity: 31.00% | Temperature: 27.00°C ~ 80.60°F Humidity: 31.00% | Temperature: 27.00°C ~ 80.60°F Humidity: 31.00% | Temperature: 28.00°C ~ 82.40°F Humidity: 31.00% | Temperature: 28.00°C ~ 82.40°F Humidity: 31.00% | Temperature: 28.00°C ~ 82.40°F Humidity: 31.00% | Temperature: 28.00°C ~ 82.40°F Humidity: 32.00% | Temperature: 28.00°C ~ 82.40°F Humidity: 31.00% | Temperature: 29.00°C ~ 84.20°F Humidity: 32.00% | Temperature: 29.00°C ~ 84.20°F Humidity: 31.00% | Temperature: 29.00°C ~ 84.20°F
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!