Too difficult to do an exact pinpoint based on the information we know.
But in my opinion, if a 5-6 year old car is giving you a check engine light (CEL), I'd have Toyota check it because it can't be good - spotty service records on the warranty/service booklet will confirm if the previous owner was lazy with the maintenance. Who knows what else is just about ready to break?
I'll have Toyota do all necessary preventive maintenance and repairs so you can start anew with the car (kahit sa labas mo na ipa-maintain afterwards).