# ESP-IDF Pressure Tendency
[](/LICENSE)
[](https://visualstudio.microsoft.com)
[](https://platformio.org/)
[](https://registry.platformio.org/libraries/k0i05/esp_pressure_tendency)
[](https://components.espressif.com/components/k0i05/esp_pressure_tendency)
This ESP32 espressif IoT development framework (esp-idf) pressure tendency component observes the last 3-hours of atmospheric pressure samples to determine if pressure is steady, rising, or falling. Information on features and functionality are documented and can be found in the `pressure_tendency.h` header file.
## Repository
The component is hosted on github and is located here: <https://github.com/K0I05/ESP32-S3_ESP-IDF_COMPONENTS/tree/main/components/utilities/esp_pressure_tendency>
## General Usage
To get started, simply copy the component to your project's `components` folder and reference the `pressure_tendency.h` header file as an include. The component includes documentation for the peripheral such as the datasheet, application notes, and/or user manual where applicable.
```text
components
└── esp_pressure_tendency
├── CMakeLists.txt
├── README.md
├── LICENSE
├── idf_component.yml
├── library.json
├── include
│ └── pressure_tendency_version.h
│ └── pressure_tendency.h
└── pressure_tendency.c
```
## Basic Example
Once the component is referenced as an include, the functions should be visible and available for usage. The below example demonstrates a basic implementation that monitors atmospheric pressure samples and determines if pressure is steady, rising, or falling. Pressure tendency code `PRESSURE_TENDENCY_UNKNOWN` is reported when there is an insufficient number of samples to analyze.
```c
#include <pressure_tendency.h>
/* pa tendency handle and configuration */
const uint16_t tendency_samples_size = ((3600 * 3) / tii_sampling_cfg.interval_period); // 3-hours = 10,800-seconds / sampling rate
pressure_tendency_handle_t pa_tendency_hdl;
pressure_tendency_codes_t pa_tendency_code;
float pa;
float pa_3chg;
void tendency(void) {
/* attempt to initialize a pa tendency handle */
pressure_tendency_init(tendency_samples_size, &pa_tendency_hdl);
if (pa_tendency_hdl == NULL) {
ESP_LOGE(TAG, "Unable to initialize pa tendency handle");
esp_restart();
}
/* attempt to measure atmospheric pressure sensor */
pa = measure.pa();
pressure_tendency_analysis(pa_tendency_hdl, pa, &pa_tendency_code, &pa_3chg);
ESP_LOGI(TAG, "Pressure Tendency: %s", pressure_tendency_code_to_string(pa_tendency_code));
ESP_LOGI(TAG, "3-hr Pressure Change: %.2f hPa", pa_3chg);
}
```
Copyright (c) 2024 Eric Gionet (<gionet.c.eric@gmail.com>)
idf.py add-dependency "k0i05/esp_pressure_tendency^1.2.5"