Your pictures appear to show a mismatch between the pin used for the IR receiver and the code in post #1.
Anyway, if the serial connection sometimes works, then I would begin to suspect that the IR library is some how interfering with it and start by commenting out all IR statements.
Since neither of your two posts which do show some serial output begin with the “loop()” I guess it gets stuck here before it has a chance to print anything.