Your main problem is the usage of the String class. You shouldn't use this on AVR Arduinos as it fragments the RAM rather fast and afterwards the behavior is unpredictable.
Your main problem is the usage of the String class. You shouldn't use this on AVR Arduinos as it fragments the RAM rather fast and afterwards the behavior is unpredictable.