Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Humidity/Temperature Monitor with DHT11 & STM32 Microcontroller
STM32 Projects

Humidity/Temperature Monitor with DHT11 & STM32 Microcontroller

Mamtaz AlamBy Mamtaz AlamUpdated:July 26, 20235 Comments3 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
STM32 DHT11 Interfacing
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Humidity & Temperature Monitoring with DHT11 & STM32 Microcontroller

This tutorial is all about Humidity & Temperature Monitoring with DHT11 & STM32 Microcontroller. DHT11 is a Humidity & Temperature sensor that is used to measure the atmospheric temperature and humidity in a particular environment or in a confined closed space. The sensor could measure the temperature from 0°C to 50°C with an accuracy of 1°C. It can measure humidity from 20% to 90% with an accuracy of 1%.

We will interface DHT11 Humidity & Temperature sensor with STM32f103c8t6 microcontroller and display the temperature and humidity data on 16×2 LCD Display.

But before starting you can go through your previous post to learn more about STM32 as well as its programming:
1. Getting Started with STM32 Microcontroller: Blinking of LED
2. STM32 Bootloader: Programming STM32F103C8 Board using USB Port
3. Interfacing 16X2 LCD Display with STM32 Bluepill Microcontroller




Bill of Materials

The following are the hardware components required for making this project.

S.N.Components NameQuantityPurchase Links
1STM32F103C Board1Amazon | AliExpress
216X2 LCD Display1Amazon | AliExpress
3DHT11 Sensor1Amazon | AliExpress
4Potentiometer 10K1Amazon | AliExpress
5Connecting Wires1Amazon | AliExpress
6Breadboard1Amazon | AliExpress


DHT11 Humidity & Temperature Sensor

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).

DHT11 Sensor

Its 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 the library, sensor readings can be up to 2 seconds old.


Circuit Diagram & Connections

Below is the circuit diagram for interfacing STM32 Microcontroller with DHT11 Humidity & Temperature Sensor.

Circuit DHT11 STM32

Supply 5V to LCD pins 2,15 from the 5V pin of STM32
Connect pin 1,5,16 of LCD to GND of STM32
Connect pin 3 of LCD to 10K Pot as shown in the above circuit.
Connect pin 4 (RS) of LCD to PB11 of STM32
Connect pin 6 (EN) of LCD to PB10 of STM32
Connect pin 11 (DB4) of LCD to PA4 of STM32
Connect pin 12 (DB5) of LCD to PA3 of STM32
Connect pin 13 (DB6) of LCD to PA2 of STM32
Connect pin 14 (DB7) of LCD to PA1 of STM32

Similarly, supply 5V to VCC Pin of DHT11 & Connect GND to GND. Connect its output Analog/Digital Pin to PA0 of STM32.



Source Code/Program

Below is the source code for interfacing DHT11 Humidity and Temperature Sensor with STM32f103c8t6.
But before that, you should have installed STM32 Board in the Arduino IDE.

There are 6 methods by which you can program STM32 Microcontroller. The methods are:

C++
1
2
3
4
5
6
1. STM32duino Bootloader Method
2. Serial Method
3. By using ST-Link Debugger
4. By BMP (Black Magic Pro)
5. Jlink Method
6. By HID bootloader 2.0

I have used the first method i.e STM32duino bootloader method. By this method, you can directly upload code to STM32 via USB port. But before that, you need to install the bootloader in STM32. To learn more about this method check here: STM32 Bootloader: Programming STM32F103C8 Board using USB Port

Add DHT11 Library before compiling this code. The download link is below:
Download DHT11 Library



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<LiquidCrystal.h>  // include the LCD library
 
const int rs = PB11, en = PB10, d4 = PA4, d5 = PA3, d6 = PA2, d7 = PA1; //STM32 Pins to which LCD is connected
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //Initialize the LCD
 
#include<DHT.h>                     //Library for using DHT sensor
#define DHTPIN PA0
#define DHTTYPE DHT11
 
DHT dht(DHTPIN, DHTTYPE);     //initilize object dht for class DHT with DHT pin with STM32 and DHT type as DHT11
 
void setup()
{
  // initialize the LCD
  lcd.begin(16,2);
  dht.begin();                                  
  lcd.print("DHT11 with STM32");
  delay(3000);
  lcd.clear();
}
 
void loop()
{
  float h = dht.readHumidity();       //Gets Humidity value
  float t = dht.readTemperature();    //Gets Temperature value
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print(" C");
  lcd.setCursor(0,1);
  lcd.print("Humid: ");
  lcd.print(h);
  lcd.print(" %");
}


Video Tutorial & Demonstration

STM32 & DHT11 Interfacing for Humidity & Temperature Measurement
Watch this video on YouTube.

In the same way you can also interface DS81B20 with STM32 Microcontrollers.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleHow to Stream Videos From Your Mobile to TV Screen
Next Article Interface BMP180 Pressure & Temperature Sensor with Arduino

Related Posts

PIR Motion Detection using Bluetooth & STM32 Board

PIR Motion Detection using Bluetooth & STM32 Board

Updated:December 23, 20234K
STM32 SHT85 Humidity Temperature Sensor

Collecting SHT85 Sensor Data using STM32 & Bluetooth Low Energy

Updated:August 20, 20222K
SX1276 STM32

Interfacing LoRa SX1276 with STM32 Microcontroller | LR1276-915MHz

Updated:May 29, 2023112K
BLE enabled Smart Bulb with STM32 & Javascript

BLE enabled Smart Bulb with STM32 & Javascript

Updated:August 20, 20222K
Create BLE Project using STM32 Microcontroller & BlueIO

Create BLE Project using STM32 Microcontroller & BlueIO

Updated:August 20, 202212K
DS18B20 STM32

Interfacing DS18B20 Temperature Sensor with STM32

Updated:August 21, 2022110K
View 5 Comments

5 Comments

  1. omitdebnath on December 9, 2019 1:03 PM

    Thank you for your Tutorial. Can I get your linkedin/mail/Facebook ID?????

    Reply
  2. Pranay on January 11, 2020 11:25 AM

    I get deta from dht only with debugging , not without debug

    Reply
  3. Saielsh on September 22, 2020 11:57 PM

    i want to use 2 temp sensors, how can i change the code to do so?

    Reply
  4. gabriel Santander on October 28, 2020 8:52 PM

    hi, I want to use the blue pill and HX711 to measure pression on a cell, how can I do that???

    Reply
  5. Vinodkumar Kanike on September 25, 2021 11:12 AM

    please anyone have connection configuration

    Reply

CommentsCancel reply

Latest Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU
    High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.