To be honest: It’s like a search game that’s no fun and takes time. What is the difference between the two codes? I can’t recognise one. Your code is not self-explanatory and contains no explanatory comments, again something that costs unnecessary time.
Why do you change the default PINs of the ESP32-C3 for Serial1?
The pins you are using are the standard pins of the ESP32-C6. But you have an ESP32-C3 ?! That makes no sense.
But maybe it is all related to this: Esp32c serial screen works but serial commands wont work
I am still waiting for further information from you to be able to help you.
I therefore suggest solving your other problem first.