No need to check the fuel cap. You already know what you did. If you messed up your O2 sensor or its harness, then that would definitely set off the check engine light. Fix the O2 sensor and your problem will be solved.
__________________
Just call me.............Mr Hyde
03 Topaz Blue 540i M-Sport
The TL-S / The 540i