modified: firmware/main/src/leds.c

Include internal LED in sequence
modified:   firmware/main/src/sht31.c
  Swap pins to new design, send heater-off command on init, change to i2c address 0x44 from 0x45 acording to new design
modified:   firmware/sdkconfig
  Activate RTOS control over sleep mode
This commit is contained in:
Sven Luethi committed 2024-08-17 21:05:18 +02:00
1 parent a0721e53e6
commit a65af5e141
3 files changed
+43 -14

No files matched your search

+24 -6
View File
@@ -6,10 +6,11 @@
#include "functions.h"
#include "sht31.h"
#define SDA_PIN GPIO_NUM_2
#define CLK_PIN GPIO_NUM_14
#define SENSOR_ADDR 0x45 //default address is 0x44 (pin 2 logic low). We chose 0x45 with logic high in v0.9 and 0x44 with newer versions where second sensor is removed.
#define SDA_PIN GPIO_NUM_14
#define CLK_PIN GPIO_NUM_13
#define SENSOR_ADDR 0x44 //default address is 0x44 (pin 2 logic low). We chose 0x45 with logic high in v0.9 and 0x44 with newer versions where second sensor is removed.
#define SHT31_MEASURE_CMD_HIGHREP 0x2400
#define SHT31_HEATER_OFF_CMD 0x3066
static const char * TAG = "sht31.c";
@@ -18,8 +19,8 @@ static const char * TAG = "sht31.c";
static const i2c_config_t config = {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_2,
.scl_io_num = GPIO_NUM_14,
.sda_io_num = SDA_PIN,
.scl_io_num = CLK_PIN,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_pullup_en = GPIO_PULLUP_DISABLE,
.clk_stretch_tick = 5
@@ -42,7 +43,7 @@ void sht31_sensor_test_task(void *pvParameters)
} else {
ESP_LOGE(TAG, "Failed to read from SHT31 sensor");
}
vTaskDelay(2000 / portTICK_RATE_MS);
vTaskDelay(30000 / portTICK_RATE_MS);
}
}
@@ -54,6 +55,23 @@ esp_err_t sht31_init(void) {
printf("Sensor initialization failed!\n");
return ESP_FAIL;
}
// Send the heater off command
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (SENSOR_ADDR << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, SHT31_HEATER_OFF_CMD >> 8, true);
i2c_master_write_byte(cmd, SHT31_HEATER_OFF_CMD & 0xFF, true);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to send command to SHT31");
return ret;
}
printf("Sensor initialized.\n");
return ESP_OK;
}