diff --git a/PROJECT_MEMORY.md b/PROJECT_MEMORY.md index 71a4e0b..2f2ce05 100644 --- a/PROJECT_MEMORY.md +++ b/PROJECT_MEMORY.md @@ -274,6 +274,17 @@ Current firmware (`main/temphummon.c`): - Bit 1 of `f[13]` (`0x02`) is NOT used for °C (leaves the degree circle incomplete) — `0x05` = °C (bits 0+2) is the correct full-degree rendering +### Internal temp sensor — accuracy/resolution notes (verified) + +The internal CPU die sensor is **live** (a CPU-stress test during bring-up +raised its reading 27.6 → 28.6°C and held it, confirming the die heats). It +measures the **silicon die**, NOT ambient air — blowing on it barely changes it. +The readout is **coarsely quantized with a per-chip calibration offset**: values +appear stuck in ~1°C steps and always end in `.6` (e.g. 27.6 / 28.6). This is +an inherent limitation of the ESP32-H2 internal sensor, not a firmware bug. +For a real ambient thermometer, wire an **external I²C sensor** (BME280/SHT40) +instead — see TODO. + ⚠️ The display uses a dot-matrix glyph style. A lone bit does not always produce a clean segment; the erase flash (white frame) is normal before each partial update. diff --git a/firmware/main/temphummon.c b/firmware/main/temphummon.c index 128cac3..9c3072c 100644 --- a/firmware/main/temphummon.c +++ b/firmware/main/temphummon.c @@ -59,6 +59,13 @@ static const uint8_t DIG_L[10][2] = { #define ICON_BAT 0x10 /* battery/power */ #define ICON_BT_BAT 0x1D /* °C + Bluetooth + battery */ +/* Debug: burn CPU for a while to stress the die and verify the internal + * temp sensor responds. Set to 1 to spin in a busy loop for STRESS_MS + * after each read (should raise/perturb the die temp). + * Verified: die rises 27.6 -> 28.6°C under load (sensor is live). */ +#define CPU_STRESS_TEST 0 +#define STRESS_MS 3000 + static void epd_wait_busy(void) { /* BUSY_N: LOW = busy, HIGH = ready */ while (gpio_get_level(PIN_BUSY) == 0) vTaskDelay(1); @@ -188,6 +195,17 @@ void app_main(void) { ESP_ERROR_CHECK(temperature_sensor_get_celsius(tsens, &t)); ESP_LOGI("temphummon", "T: %.1f°C", (double)t); +#if CPU_STRESS_TEST + /* Burn CPU hard for STRESS_MS to heat the die. */ + uint32_t ticks = pdMS_TO_TICKS(STRESS_MS); + uint32_t start = xTaskGetTickCount(); + volatile uint32_t sink = 1; + while ((xTaskGetTickCount() - start) < ticks) { + for (uint32_t i = 0; i < 100000; i++) sink = sink * 131 + i; /* ~busy */ + } + (void)sink; +#endif + uint8_t f[15]; memset(f, 0, 15); render_temp(f, t); render_humidity(f, 88.8f); /* fixed sample until a humidity sensor is wired */