NTC: add open/short detection (V near rails) instead of bogus temp

This commit is contained in:
2026-10-09 19:28:28 +08:00
parent 061fa4d950
commit cda8f482d2
2 changed files with 16 additions and 5 deletions
+8 -1
View File
@@ -53,7 +53,14 @@ int main(void)
static uint16_t temp_report_counter = 0;
if (++temp_report_counter >= 100U) { /* 主循环 10ms 一圈 → 1s */
temp_report_counter = 0;
printf("NTC temp: %.1f C\r\n", ntc_read_temperature());
float temp = ntc_read_temperature();
if (temp <= -274.0f) {
printf("NTC SHORT (PC5 pulled low)\r\n");
} else if (temp <= -273.0f) {
printf("NTC OPEN (PC5 at VREF, check NTC wiring/solder)\r\n");
} else {
printf("NTC temp: %.1f C\r\n", temp);
}
}
}
#endif