12-12-2024, 09:16 PM
I've identified an issue with my M16 board whereby the SH31 sensor becomes disconnected after the setup() function and can no longer be read. I've tried a number of variations on the bus settings, but there seems to be no effect. The relevant setup() code is this:
This works, however, once inside the loop(), attempts to read the SHT31 fail as disconnected and cannot be reset, even using the HARD option.
Could this be a conflict with the U8G2?
Full code is available via Github: https://github.com/LouPaloma/KinconyM16-...ter/Source
PHP Code:
Wire.begin(4, 5);
// Wire.setClock(100000);
Wire.setClock(10000);
Wire.setTimeOut(1000);
sht.begin();
sht.read();
temperature = sht.getFahrenheit();
humidity = sht.getHumidity();
int error = sht.getError();
if (error != 0) {
uint16_t stat = sht.readStatus();
ESP_LOGW("kincony", "Temperature sensor Error status: 0x%04x, read status: 0x%04x",
error, stat);
logSHT31BitStatus(stat);
}
This works, however, once inside the loop(), attempts to read the SHT31 fail as disconnected and cannot be reset, even using the HARD option.
PHP Code:
if (sht.isConnected()) {
sht.read();
temperature = sht.getFahrenheit();
humidity = sht.getHumidity();
int error = sht.getError();
if (error != 0) {
uint16_t stat = sht.readStatus();
ESP_LOGW("kincony", "Temperature sensor Error status: 0x%04x, read status: 0x%04x",
error, stat);
logSHT31BitStatus(stat);
}
} else {
int error = sht.getError();
ESP_LOGE("kincony", "Temperature sensor connection failure, HARD resetting...");
ESP_LOGW("kincony", "Temperature sensor Error status: 0x%04x", error);
sht.reset(true);
}
Could this be a conflict with the U8G2?
Full code is available via Github: https://github.com/LouPaloma/KinconyM16-...ter/Source