max6675在IDF 6.01 編譯下要取哪個Componet

mt1215
Posts: 1
Joined: Tue Jun 09, 2026 9:15 am

max6675在IDF 6.01 編譯下要取哪個Componet

Postby mt1215 » Tue Jun 09, 2026 9:25 am

這邊用ESP32-S3 試著IDF 6.01編譯hayschan__max6675 發生 幾個錯誤
D:/ESP32_Projects/max6675/managed_components/hayschan__max6675/include/max6675.h:4:10: fatal error: driver/gpio.h: No such file or directory
4 | #include "driver/gpio.h"
| ^~~~~~~~~~~~~~~

-- Build files have been written to: D:/ESP32_Projects/max6675/build/bootloader
ninja: build stopped: subcommand failed.
Compilation failed because max6675.h (in "hayschan__max6675" component) includes driver/gpio.h, provided by esp_driver_gpio component(s).
However, esp_driver_gpio component(s) is not in the requirements list of "hayschan__max6675".
To fix this, add esp_driver_gpio to REQUIRES list of idf_component_register call in D:\ESP32_Projects\max6675\managed_components\hayschan__max6675\CMakeLists.txt.
ninja failed with exit code 1, output of the command is in the D:\ESP32_Projects\max6675\build\log\idf_py_stderr_output_24072 and D:\ESP32_Projects\max6675\build\log\idf_py_stdout_output_24072

建議要如何修正?
源碼是

#include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp_log.h>
#include <max6675.h>

static const char *TAG = "MAX6675_DEMO";

// 定義 GPIO 引腳
#define SPI_MISO_GPIO 11
#define SPI_SCK_GPIO 12
#define SPI_CS_GPIO 10

void app_main(void)
{
// 1. 初始化 MAX6675 設備結構體
max6675_t dev = {
.spi_dev = NULL,
.miso_gpio = SPI_MISO_GPIO,
.sclk_gpio = SPI_SCK_GPIO,
.cs_gpio = SPI_CS_GPIO
};

// 2. 初始化 MAX6675 驅動
esp_err_t res = max6675_init(&dev);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Could not initialize MAX6675 sensor: %d", res);
return;
}

ESP_LOGI(TAG, "MAX6675 initialized successfully.");

// 3. 循環讀取溫度
while (1) {
float temperature;
res = max6675_get_temperature(&dev, &temperature);

if (res == ESP_OK) {
ESP_LOGI(TAG, "Current Temperature: %.2f °C", temperature);
} else {
ESP_LOGE(TAG, "Could not read temperature from MAX6675: %d", res);
}

// MAX6675 轉換時間約為 0.22 秒,讀取頻率不建議高於 4Hz
vTaskDelay(pdMS_TO_TICKS(1000));
}
}

Who is online

Users browsing this forum: No registered users and 2 guests