diff --git a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp index 359c6e2f50..da5c0fba37 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp @@ -15,7 +15,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector &data) { std::ostringstream output; uint8_t items_left = this->response_bytes; uint8_t index = this->offset; - char buffer[4]; + char buffer[5]; while ((items_left > 0) && index < data.size()) { uint8_t b = data[index]; switch (this->encode_) {