Files
Smart-granary-code/components/bh1750/include/bh1750_use.h

40 lines
695 B
C
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.
#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