Just to give you some insight what the problem with this code above may be, it is worth to go walk through the code "manually" step by step:
- The while loop() will only be left if no characters available on Serial2.
- As long as Serial2.available() > 0 the code reads each single character
- and collects them in String repuesta unless it is a '\n'
- If a '\n' was received the code waits for 1 second
- If further data arrived at Serial2 within this second the while()-loop will go on adding the next characters to repuesta ...
In case that there is a time gap of more than 1 second between messages the code might work but it is not "fail-safe".