From 4e851affa848e7428c120a9ab359a490b5dd29ae Mon Sep 17 00:00:00 2001 From: Alexander Bobkov Date: Sat, 4 Oct 2025 00:59:04 -0400 Subject: [PATCH] esp32 temperature node --- ESP32-IDF_Temperture-Node-v2/main/hello_world_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ESP32-IDF_Temperture-Node-v2/main/hello_world_main.c b/ESP32-IDF_Temperture-Node-v2/main/hello_world_main.c index 1811821bb..f7eed8e2b 100644 --- a/ESP32-IDF_Temperture-Node-v2/main/hello_world_main.c +++ b/ESP32-IDF_Temperture-Node-v2/main/hello_world_main.c @@ -33,6 +33,16 @@ static bme280_handle_t sensor = NULL; float temperature = 0.0f; +i2c_config_t conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_21, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_io_num = GPIO_NUM_22, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = I2C_MASTER_FREQ_HZ, + .clk_flags= 0, + }; + void app_main(void) @@ -65,7 +75,7 @@ void app_main(void) printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); //i2c_master_init(); - i2c_bus_handle_t i2c_bus = i2c_bus_create(I2C_MASTER_NUM, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO); + i2c_bus_handle_t i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf); sensor = bme280_create(i2c_bus, BME280_SENSOR_ADDR); ESP_ERROR_CHECK(bme280_default_init(sensor)); ESP_ERROR_CHECK(bme280_read_temperature(sensor, &temperature));