diff --git a/examples/default_example/main/xgzf4000-poll-data.c b/examples/default_example/main/xgzf4000-poll-data.c index 6e24cd2..54c8bb0 100644 --- a/examples/default_example/main/xgzf4000-poll-data.c +++ b/examples/default_example/main/xgzf4000-poll-data.c @@ -1,7 +1,7 @@ #include "esp_log.h" #include "xgzf4000.h" -static const char *TAG = "XGZF4000_APP"; +static const char *TAG_XGZF = "XGZF4000_APP"; #define I2C_XGZF4000_ADDR 0x50 // default I2C address of the XGZF4000 sensor #define I2C_MASTER_SCL_IO 19 // Assign the SCL pin number @@ -25,12 +25,12 @@ static void poll_air_flow_data(void) { // Log the flow rate in the selected unit #ifdef CONFIG_FLOW_RATE_UNIT_LMIN - ESP_LOGI(TAG, "Raw Flow Rate: %u, Flow Rate: %.2f L/min", flow_rate_raw, flow_rate); + ESP_LOGI(TAG_XGZF, "Raw Flow Rate: %u, Flow Rate: %.2f L/min", flow_rate_raw, flow_rate); #elif CONFIG_FLOW_RATE_UNIT_CMH - ESP_LOGI(TAG, "Raw Flow Rate: %u, Flow Rate: %.2f m³/h", flow_rate_raw, flow_rate); + ESP_LOGI(TAG_XGZF, "Raw Flow Rate: %u, Flow Rate: %.2f m³/h", flow_rate_raw, flow_rate); #endif } else { - ESP_LOGE(TAG, "Failed to read air flow data"); + ESP_LOGE(TAG_XGZF, "Failed to read air flow data"); } } @@ -42,13 +42,13 @@ void app_main(void) { .i2c_addr = I2C_XGZF4000_ADDR, }; - ESP_ERROR_CHECK(xgzf4000_new_sensor(I2C_MASTER_NUM, I2C_SDA_PIN, I2C_SCL_PIN)); + ESP_ERROR_CHECK(xgzf4000_new_sensor(I2C_MASTER_NUM, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO)); - if (init_xgzf4000_sensor() != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize XGZF4000 sensor"); - return; - } + // if (init_xgzf4000_sensor() != ESP_OK) { + // ESP_LOGE(TAG_XGZF, "Failed to initialize XGZF4000 sensor"); + // return; + // } while (1) { poll_air_flow_data(); diff --git a/include/xgzf4000.h b/include/xgzf4000.h index 4ddc38a..1924772 100644 --- a/include/xgzf4000.h +++ b/include/xgzf4000.h @@ -39,7 +39,7 @@ typedef struct { } xgzf4000_i2c_config_t; -esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) +esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin); /** * @brief Delete XGZF4000 device handle. diff --git a/xgzf4000.c b/xgzf4000.c index 00ac927..15b4ba1 100644 --- a/xgzf4000.c +++ b/xgzf4000.c @@ -19,6 +19,10 @@ #include "xgzf4000.h" #include "xgzf4000_reg.h" +#define I2C_MASTER_FREQ_HZ 100000 // I2C master frequency +#define I2C_MASTER_RX_BUF_DISABLE 0 +#define I2C_MASTER_TX_BUF_DISABLE 0 + #define K_FACTOR 1000 // Proportionality factor for converting raw flow data to actual flow rate, either 1000 or 1000 static esp_err_t xgzf4000_read_flow_data(xgzf4000_dev_handle_t dev, uint8_t *data, size_t len)