I am new to ESP32 and I have interfaced to my SHT31 sensor. However, when I use ESP_LOGD I am getting a crash and my ESP32 is rebooting. In the attached minimal example when I un-comment ESP_LOGD(tag, "i2c write start"); I get a crash.
Could someone explain what I have done wrong and why this is crashing?
Thanks
Densha
Code: Select all
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <math.h>
#include <stdbool.h>
#include <esp_err.h>
#include "sdkconfig.h"
static const char tag[] = "sht31";
esp_err_t i2c_send_command () {
// UNCOMMENT THIS LINE ESP_LOGD(tag, "i2c write start");
return ESP_OK;
}
void SHT31_task( void * arg)
{
while(1) {
esp_err_t ret = i2c_send_command ();
vTaskDelay(10000 / portTICK_PERIOD_MS);
}
}
void app_main() {
ESP_LOGD(tag, "sht31 initialize");
xTaskCreate(&SHT31_task, "sht31_task", 1024, NULL, 5, NULL);
}
Code: Select all
Crash
0x400df995: esp_vfs_write at /home/densha/esp/esp-idf/components/vfs/./vfs.c:274 (discriminator 4)
0x400d5d35: __sprint_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:437
0x400db4fe: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:1782 (discriminator 1)
0x400db641: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vprintf.c:39
0x400823e9: esp_log_write at /home/densha/esp/esp-idf/components/log/./log.c:215
0x400d1c75: i2c_send_command at /home/densha/esp/esp32_sht31/main/./main.c:14
0x400d1c7f: SHT31_task at /home/densha/esp/esp32_sht31/main/./main.c:21 (discriminator 1)