diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index e6ad18d9d9..b5b8648073 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -695,8 +695,11 @@ inline char *int8_to_str(char *buf, int8_t val) { if (v >= 100) { *buf++ = '1'; // int8 max is 128, so hundreds digit is always 1 v -= 100; - } - if (v >= 10) { + // Must write tens digit (even if 0) after hundreds + int tens = v / 10; + *buf++ = '0' + tens; + v -= tens * 10; + } else if (v >= 10) { int tens = v / 10; *buf++ = '0' + tens; v -= tens * 10;