Version 1.0.1
Updated some components. Changed main code to support the new major version of zh_config. Reducing the amount of memory used.
This commit is contained in:
@ -13,7 +13,7 @@ In an existing project, run the following command to install the component:
|
||||
|
||||
```text
|
||||
cd ../your_project/components
|
||||
git clone http://git.zh.com.ru/alexey.zholtikov/zh_dht.git
|
||||
git clone https://github.com/aZholtikov/zh_dht.git
|
||||
```
|
||||
|
||||
In the application, add the component:
|
||||
@ -29,7 +29,7 @@ Reading the sensor:
|
||||
```c
|
||||
#include "zh_dht.h"
|
||||
|
||||
void app_main()
|
||||
void app_main(void)
|
||||
{
|
||||
zh_dht_handle_t dht_handle = zh_dht_init(ZH_DHT22, GPIO_NUM_5);
|
||||
float humidity;
|
||||
|
@ -24,9 +24,9 @@ extern "C"
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ZH_DHT11, ///< Sensor type DHT11
|
||||
ZH_DHT22 ///< Sensor type DHT22 or AM2302
|
||||
} __attribute__((packed)) zh_dht_sensor_type_t;
|
||||
ZH_DHT11, ///< Sensor type DHT11.
|
||||
ZH_DHT22 ///< Sensor type DHT22 or AM2302.
|
||||
} zh_dht_sensor_type_t;
|
||||
|
||||
/**
|
||||
* @brief Unique handle of the sensor.
|
||||
@ -34,34 +34,33 @@ extern "C"
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sensor_pin; ///< Sensor GPIO connection
|
||||
zh_dht_sensor_type_t sensor_type; ///< Sensor type
|
||||
} __attribute__((packed)) zh_dht_handle_t;
|
||||
uint8_t sensor_pin; ///< Sensor GPIO connection. @note
|
||||
zh_dht_sensor_type_t sensor_type; ///< Sensor type. @note
|
||||
} zh_dht_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize DHT sensor.
|
||||
* @brief Initialize DHT sensor.
|
||||
*
|
||||
* @param[in] sensor_type Sensor type (ZH_DHT11 or ZH_DHT22).
|
||||
* @param[in] sensor_pin Sensor connection gpio.
|
||||
* @param[in] sensor_type Sensor type.
|
||||
* @param[in] sensor_pin Sensor connection gpio.
|
||||
*
|
||||
* @return
|
||||
* - Handle of the sensor.
|
||||
* @return Handle of the sensor
|
||||
*/
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t sensor_pin);
|
||||
|
||||
/**
|
||||
* @brief Read DHT sensor.
|
||||
* @brief Read DHT sensor.
|
||||
*
|
||||
* @param[in] dht_handle Pointer for handle of the sensor.
|
||||
* @param[out] humidity Pointer for DHT sensor reading data of humidity.
|
||||
* @param[out] temperature Pointer for DHT sensor reading data of temperature.
|
||||
* @param[in] dht_handle Pointer for handle of the sensor.
|
||||
* @param[out] humidity Pointer for DHT sensor reading data of humidity.
|
||||
* @param[out] temperature Pointer for DHT sensor reading data of temperature.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if read was success
|
||||
* - ESP_ERR_INVALID_ARG if parameter error
|
||||
* - ESP_ERR_INVALID_RESPONSE if the bus is busy
|
||||
* - ESP_ERR_TIMEOUT if operation timeout
|
||||
* - ESP_ERR_INVALID_CRC if check CRC is fail
|
||||
* - ESP_OK if read was success
|
||||
* - ESP_ERR_INVALID_ARG if parameter error
|
||||
* - ESP_ERR_INVALID_RESPONSE if the bus is busy
|
||||
* - ESP_ERR_TIMEOUT if operation timeout
|
||||
* - ESP_ERR_INVALID_CRC if check CRC is fail
|
||||
*/
|
||||
esp_err_t zh_dht_read(const zh_dht_handle_t *dht_handle, float *humidity, float *temperature);
|
||||
|
||||
|
@ -1 +1 @@
|
||||
1.2.6
|
||||
1.0.0
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
* The main code of the zh_dht component.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zh_dht.h"
|
||||
@ -27,10 +28,10 @@ static esp_err_t _read_bit(const zh_dht_handle_t *dht_handle, bool *bit);
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t sensor_pin)
|
||||
{
|
||||
ESP_LOGI(TAG, "DHT initialization begin.");
|
||||
zh_dht_handle_t zh_dht_handle;
|
||||
zh_dht_handle.sensor_type = sensor_type;
|
||||
zh_dht_handle.sensor_pin = sensor_pin;
|
||||
gpio_config_t config;
|
||||
zh_dht_handle_t zh_dht_handle = {
|
||||
.sensor_type = sensor_type,
|
||||
.sensor_pin = sensor_pin};
|
||||
gpio_config_t config = {0};
|
||||
config.intr_type = GPIO_INTR_DISABLE;
|
||||
config.mode = GPIO_MODE_INPUT;
|
||||
config.pin_bit_mask = (1ULL << sensor_pin);
|
||||
|
Reference in New Issue
Block a user