smart-home/firefly_esp32/main/Sensor/HTPA60x40dR1L0.9/README.md
小羊肉肉. 0548c1555f 更新项目文档和传感器模块
主要更改:
1. 新增使用手册:
   - AI算法更新指南
   - HTPA60x40传感器升级指南
   - 环境配置教程

2. 传感器模块优化:
   - HTPA60x40dR1L0.9传感器集成
   - HTPAd32x32L1k7传感器更新
   - 传感器配置文档完善

3. 项目文档整理:
   - 删除过期的433MHz使用指南
   - 更新README文档结构
   - 完善配置教程链接

 目标:完善项目文档,优化传感器集成
2026-02-26 18:11:43 +08:00

281 lines
7.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# HTPA60x40dR1L0.9/0.8 热成像传感器驱动
## 📋 概述
本目录包含Heimann HTPA60x40dR1L0.9/0.8热成像传感器的ESP32驱动代码。该传感器提供60x40像素分辨率的热成像数据相比32x32传感器提供更高的分辨率和更详细的热成像信息。
## 🔧 硬件规格
### 传感器参数:
- **分辨率**60x40像素 (2400个像素)
- **视场角**60° x 40° (标准版本)
- **温度范围**-20°C 到 +300°C
- **精度**±2°C (在环境温度下)
- **帧率**最高4Hz
- **接口**I2C (地址0x1A)
- **工作电压**3.3V
- **功耗**约150mA
### 与32x32版本的主要区别
- 像素数量2400 vs 1024 (增加134%)
- 数据量4800字节 vs 2048字节
- 处理时间:更长的数据读取和处理时间
- 内存需求:更大的缓冲区需求
## 📁 文件结构
```
HTPA60x40dR1L0.9/
├── HTPA60x40dR1L0.9.h # 传感器常量定义
├── HTPA_Sensor60x40.h # 传感器类声明
├── HTPA_Sensor60x40.cpp # 传感器类实现
├── htpa60x40_lookuptable.cpp # 温度查找表
├── CMakeLists.txt # 编译配置
└── README.md # 本文档
```
## 🚀 使用方法
### 1. 基本初始化
```cpp
#include "Sensor/HTPA60x40dR1L0.9/HTPA_Sensor60x40.h"
HTPA60x40 thermal_sensor;
void setup() {
// 初始化传感器
esp_err_t ret = thermal_sensor.init();
if (ret != ESP_OK) {
ESP_LOGE("MAIN", "Failed to initialize HTPA60x40 sensor");
return;
}
ESP_LOGI("MAIN", "HTPA60x40 sensor initialized successfully");
}
```
### 2. 数据读取
```cpp
void loop() {
// 处理传感器数据
if (thermal_sensor.process()) {
// 方法1获取完整60x40热成像数据
float thermal_data[2400];
if (thermal_sensor.getThermalData60x40(thermal_data)) {
// 处理2400个像素的温度数据
for (int i = 0; i < 2400; i++) {
// thermal_data[i] 包含第i个像素的温度值
}
}
// 方法2获取降采样的8x5网格数据兼容性更好
float grid_8x5[40];
if (thermal_sensor.getThermalGrid8x5(grid_8x5)) {
// 处理40个网格的平均温度
}
// 方法3获取12x8网格数据中等分辨率
float grid_12x8[96];
if (thermal_sensor.getThermalGrid12x8(grid_12x8)) {
// 处理96个网格的平均温度
}
// 方法4获取指定区域的平均温度
float region_temp;
if (thermal_sensor.getRegionTemperature(20, 15, 20, 10, &region_temp)) {
ESP_LOGI("MAIN", "Region temperature: %.2f°C", region_temp);
}
// 方法5获取最热点和最冷点
float hot_temp, cold_temp;
uint8_t hot_x, hot_y, cold_x, cold_y;
if (thermal_sensor.getHotColdSpots(&hot_temp, &hot_x, &hot_y,
&cold_temp, &cold_x, &cold_y)) {
ESP_LOGI("MAIN", "Hot spot: %.2f°C at (%d,%d)", hot_temp, hot_x, hot_y);
ESP_LOGI("MAIN", "Cold spot: %.2f°C at (%d,%d)", cold_temp, cold_x, cold_y);
}
}
vTaskDelay(pdMS_TO_TICKS(250)); // 4Hz更新频率
}
```
### 3. 与现有32x32代码的集成
```cpp
// 在主程序中可以通过条件编译选择传感器
#ifdef USE_HTPA60x40
#include "Sensor/HTPA60x40dR1L0.9/HTPA_Sensor60x40.h"
HTPA60x40 thermal_sensor;
#else
#include "Sensor/HTPAd32x32L1k7/HTPA_Sensor32_2.h"
HTPA32_2 thermal_sensor;
#endif
void init_thermal_sensor() {
esp_err_t ret = thermal_sensor.init();
if (ret != ESP_OK) {
ESP_LOGE("MAIN", "Failed to initialize thermal sensor");
}
}
```
## ⚙️ 配置选项
### I2C配置
- **SDA引脚**GPIO14
- **SCL引脚**GPIO21
- **时钟频率**1MHz (传感器), 400kHz (EEPROM)
- **地址**0x1A (传感器), 0x50 (EEPROM)
### 内存配置:
```cpp
// 在sdkconfig中增加堆内存大小
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
CONFIG_FREERTOS_HEAP_SIZE_MIN=32768
```
### 性能优化:
```cpp
// 暂停定时器以避免I2C冲突
thermal_sensor.pauseTimer();
// 执行其他I2C操作
thermal_sensor.resumeTimer();
```
## 🔍 API参考
### 主要方法:
#### `esp_err_t init()`
初始化传感器包括I2C通信、EEPROM读取、校准设置等。
#### `bool process()`
处理传感器数据返回true表示有新数据可用。
#### `bool getThermalData60x40(float* thermal_data)`
获取完整的60x40热成像数据需要2400个float的数组。
#### `bool getThermalGrid8x5(float* grid_temps)`
获取8x5网格的降采样数据需要40个float的数组。
#### `bool getThermalGrid12x8(float* grid_temps)`
获取12x8网格的降采样数据需要96个float的数组。
#### `bool getRegionTemperature(uint8_t start_x, uint8_t start_y, uint8_t width, uint8_t height, float* avg_temp)`
获取指定矩形区域的平均温度。
#### `bool getHotColdSpots(...)`
获取图像中的最热点和最冷点位置及温度。
### 信息查询方法:
#### `uint16_t getPixelCount()`
返回像素总数 (2400)。
#### `uint8_t getColumnCount()`
返回列数 (60)。
#### `uint8_t getRowCount()`
返回行数 (40)。
#### `uint16_t get_ambient_temperature()`
返回环境温度。
## ⚠️ 注意事项
### 1. 内存需求
60x40传感器需要更多内存
- 像素常量2400 × 4字节 = 9.6KB
- 像素数据2400 × 2字节 = 4.8KB
- 缓冲区约20个块 × 242字节 = 4.8KB
- 总计约19.2KB (vs 32x32的8KB)
### 2. 处理时间
更多的像素意味着:
- 更长的I2C数据传输时间
- 更多的计算处理时间
- 可能需要降低帧率以保证系统稳定性
### 3. 查找表
当前使用的是简化的查找表,实际部署时需要:
- 从Heimann获取完整的校准查找表
- 根据具体传感器型号调整参数
- 进行温度校准验证
### 4. 兼容性
代码设计为与32x32版本API兼容
- 数据量更大,需要相应调整缓冲区大小
- 网络传输可能需要压缩或分包
- 显示界面需要适配新的分辨率
## 🔧 故障排除
### 常见问题:
#### 1. 内存不足
```
E (xxx) HTPA60x40: Memory allocation failed for 2400 pixels
```
**解决方案**增加堆内存大小或使用PSRAM。
#### 2. I2C通信失败
```
E (xxx) HTPA60x40: Sensor initialization failed, check connections
```
**解决方案**检查I2C连接和电源供应。
#### 3. 数据处理缓慢
**解决方案**
- 使用降采样方法减少数据量
- 优化处理算法
- 考虑使用DMA传输
### 调试技巧:
```cpp
// 启用详细日志
esp_log_level_set("HTPA60x40", ESP_LOG_DEBUG);
// 监控内存使用
ESP_LOGI("MAIN", "Free heap: %d bytes", esp_get_free_heap_size());
// 检查传感器状态
ESP_LOGI("MAIN", "Sensor pixels: %d, columns: %d, rows: %d",
thermal_sensor.getPixelCount(),
thermal_sensor.getColumnCount(),
thermal_sensor.getRowCount());
```
## 📈 性能对比
| 特性 | HTPA32x32 | HTPA60x40 | 提升 |
|------|-----------|-----------|------|
| 像素数 | 1024 | 2400 | +134% |
| 分辨率 | 32×32 | 60×40 | +134% |
| 数据量 | 2KB | 4.8KB | +140% |
| 内存需求 | ~8KB | ~19KB | +138% |
| 处理时间 | 基准 | +150% | - |
## 🚀 未来改进
1. **硬件加速**使用ESP32的DMA功能加速I2C传输
2. **数据压缩**:实现实时数据压缩算法
3. **智能采样**:根据应用需求动态调整采样率
4. **温度校准**:实现更精确的温度转换算法
5. **多传感器支持**:支持同时使用多个传感器
---
**注意**:此代码为预备版本,在实际部署前需要:
1. 获取完整的传感器校准数据
2. 进行充分的硬件测试
3. 优化性能和内存使用
4. 验证温度精度
**文档版本**v1.0
**创建时间**2026年2月26日
**适用传感器**HTPA60x40dR1L0.9, HTPA60x40dR1L0.8