2026-01-02 12:06:32 +03:00
2026-01-02 08:46:49 +03:00
2026-01-02 12:06:32 +03:00
2026-01-02 08:46:49 +03:00
2026-01-02 12:06:32 +03:00
2026-01-02 12:06:32 +03:00
2026-01-02 15:26:56 +03:00

ESP32 ESP-IDF component for inclinometer (via rotary encoder)

Tested on

  1. ESP32 ESP-IDF v5.5.1

SAST Tools

PVS-Studio - static analyzer for C, C++, C#, and Java code.

Attention

  1. For correct operation, please enable the following settings in the menuconfig:
GPIO_CTRL_FUNC_IN_IRAM

Using

In an existing project, run the following command to install the components:

cd ../your_project/components
git clone http://git.zh.com.ru/esp_components/zh_inclinometer

In the application, add the component:

#include "zh_inclinometer.h"

Examples

#include "zh_inclinometer.h"

double inclinometer_position = 0;

void app_main(void)
{
    esp_log_level_set("zh_inclinometer", ESP_LOG_ERROR);
    zh_inclinometer_init_config_t config = ZH_INCLINOMETER_INIT_CONFIG_DEFAULT();
    config.a_gpio_number = GPIO_NUM_26;
    config.b_gpio_number = GPIO_NUM_27;
    config.encoder_pulses = 3600;
    zh_inclinometer_init(&config);
    for (;;)
    {
        zh_inclinometer_get(&inclinometer_position);
        printf("Inclinometer position is %0.2f degrees.\n", inclinometer_position);
        vTaskDelay(100 / portTICK_PERIOD_MS);
    }
}
Description
ESP32 ESP-IDF component for inclinometer (via rotary encoder).
Readme Apache-2.0 40 KiB
Languages
C 99%
CMake 1%