Skip to content

Baryonics/dht11-stm32f4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DHT11 STM32F4 Library

This library provides an interface for the DHT11 temperature and humidity sensor using STM32F4 microcontrollers, specifically tested with the STM32 Nucleo F401RE.

Features

  • Read temperature and humidity data from the DHT11 sensor
  • Simple API for easy integration

Requirements

  • STM32F4 microcontroller (tested with STM32 Nucleo F401RE)
  • STM32CubeMX and HAL libraries
  • DHT11 sensor

Installation

  1. Clone the repository:
    git clone https://github.com/Baryonics/dht11-stm32f4.git
  2. Add the entire dht11-stm32f4 folder to your projects Libs folder.
  3. Include the DHT11 library in your CMakeLists.txt file:
    # Add sources to executable
    target_sources(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user sources here
        Libs/dht11-stm32f4/Src/dht11-stm32f4.c
    )
    
    
    # Add include paths
    target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user defined include paths
        Libs/dht11-stm32f4/Inc
    )
  4. Include the DHT11 library in your main code:
    #include "dht11-stm32f4.h"

Usage

  1. Initialize the DHT11 sensor (ensure the timer htim is prescaled so that one tick equals one microsecond. For the Nucleo F401RE, set the prescaler to 84):
  2. Initialize the DHT11 sensor:
    DHT11_Init(DHT11_DATA_Port, DHT11_DATA_Pin, htim);
  3. Read data from the sensor:
    uint16_t temp;
    uint16_t rh;
    
    DHT11_Status dht11_status = dht11_read(&temp, &rh);

API Reference

void DHT11_Init(void)

Initializes the DHT11 sensor.

DHT11_Status DHT11_Read(uint16_t *temp, uint16_t *rh)

Reads temperature and humidity data from the DHT11 sensor.

  • *temp: Pointer to a variable to store the read temperature data.
  • *rh: Pointer to a variable to store the read humidity data.
  • Returns DHT11_OK on success, or an error code on failure.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages