About HC06 Bluetooth connection with Ardutooth

I am dealing with a low cost smart diaper project. I am integrating Arduino UNO, HC06 and SEN0114 and a low-level trigger buzzer.
When moisture value < 300, print 'Dry'
When moistureValue >= 300 && moistureValue < 700, print "wet', and buzzer ring for 5 seconds in 1000Hz
When moistureValue >=700, print 'Very Wet', buzzer ring at '2000' Hz,

The Arduino can connect to mobile app Ardutooth, but when I type command 'print' and 'snooze' for the testing, everything goes right with slightly delay. But after few days later, the command could not be run, and cannot even show 'print output' and 'Snooze activated for 3 minutes' in the serial monitor. How can I solve this, is there anything to add in this code?

The code is shown below. Other than Arduino UNO, I am also trying ESP WROOM 32

#include <SoftwareSerial.h>

const int buzzerPin = 9; // Buzzer connected to pin 9
const int moisturePin = A0; // Moisture sensor connected to A0

// Define SoftwareSerial for HC-06
SoftwareSerial BTSerial(10, 11); // Arduino(RX10, TX11),HCTx --> Arduino RX(10) , HCRX to Arduino TX(11)

bool isSnoozed = false; // Snooze state
unsigned long snoozeEndTime = 0; // Time when snooze ends

void setup() {
    Serial.begin(9600); // Open serial port for Serial Monitor
    BTSerial.begin(9600); // Open serial port for HC-06
    pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
}

void loop() {
    int moistureValue = analogRead(moisturePin); // Read sensor value
    String status;

    // Determine the moisture status
    if (moistureValue < 300) {
        status = "Dry";
        BTSerial.println("Status: Dry");
        noTone(buzzerPin); // Buzzer does nothing
        delay(5000); // Lasts for 5000 milliseconds
    } 
    else if (moistureValue >= 300 && moistureValue < 700) {
        status = "Wet";
        BTSerial.println("Status: Wet");
        if (!isSnoozed) {
            tone(buzzerPin, 1000); // Play tone at 1000 Hz
            noTone(buzzerPin); // Stop the buzzer
            delay(5000); // Lasts for 5000 milliseconds
        }
    } 
    else if (moistureValue >= 700) {
        status = "Very Wet";
        BTSerial.println("Status: Very Wet");
        if (!isSnoozed) {
            tone(buzzerPin, 2000); // Play tone at 2000 Hz
        }
    }

    // Check if snooze is active
    if (isSnoozed && millis() > snoozeEndTime) {
        isSnoozed = false; // End snooze
        Serial.println("Snooze ended.");
        BTSerial.println("Snooze ended.");
    }

    // Automatically print moisture sensor value and status to Serial Monitor
    printStatus(moistureValue, status);

    // Check for Bluetooth input
    if (BTSerial.available()) {
        String command = BTSerial.readStringUntil('\n'); // Read command
        if (command == "print") {
            printStatus(moistureValue, status); // Respond to print command
            Serial.println("Print output.");
            BTSerial.println("Print output.");
        } else if (command == "snooze") {
            isSnoozed = true; // Set snooze state
            snoozeEndTime = millis() + 180000; // 3 minutes in milliseconds
            Serial.println("Snooze activated for 3 minutes.");
            BTSerial.println("Snooze activated for 3 minutes.");
        }
    }

    // Removed the delay for smoother operation
}

void printStatus(int moistureValue, const String& status) {
    Serial.print("Moisture Sensor Value: ");
    Serial.print(moistureValue);
    Serial.print(" | Status: ");
    Serial.println(status);
}

Immediately after this line, add a line to print "command" to see how your command looks.

That is typical of the memory problems caused by using Strings on Arduinos with small amounts of RAM (like the Uno, Mega, etc.).

Strings are never necessary, so it is best to avoid using them.

so it is not related to my code, but the amount of RAM?

The readStringUntil('\n') in BTSerial.available() can lead to delays or incomplete reads if the newline character is missing or corrupted.
Use a robust command parser to handle commands efficiently.
Replace String command = BTSerial.readStringUntil('\n');
with

char command[20]; // Adjust buffer size as needed
if (BTSerial.available()) {
    size_t len = BTSerial.readBytesUntil('\n', command, sizeof(command) - 1);
    command[len] = '\0'; // Null-terminate the string
}

Your code uses Strings, which cause Arduino with small amounts of memory to crash, especially when errors occurl, like those described above.