40 lines
695 B
C
40 lines
695 B
C
#ifndef BH1750_USE_H
|
||
#define BH1750_USE_H
|
||
|
||
#include "esp_err.h"
|
||
#include "driver/i2c_master.h"
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
// 定义使用的 I2C 引脚
|
||
#define BH1750_I2C_SCL_IO 1
|
||
#define BH1750_I2C_SDA_IO 2
|
||
|
||
/**
|
||
* @brief 初始化 BH1750 传感器及其所需的 I2C 总线
|
||
*/
|
||
esp_err_t bh1750_user_init(void);
|
||
|
||
/**
|
||
* @brief 获取 I2C 总线句柄,以便其他传感器(如 AHT30)共用总线
|
||
*/
|
||
i2c_master_bus_handle_t bh1750_get_i2c_bus_handle(void);
|
||
|
||
/**
|
||
* @brief 读取一次光照强度数据 (Lux)
|
||
*/
|
||
esp_err_t bh1750_user_read(float *lux);
|
||
|
||
/**
|
||
* @brief 释放 BH1750 相关资源
|
||
*/
|
||
void bh1750_user_deinit(void);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif
|