Homophones are words that sound alike, may have the same spelling, but differ in meaning.
Principal means main, primary, key, leader, headmaster, etc.
Principle means rule, law, code, standard, notion, etc.
Coconut was the principal ingredient in that recipe.
The Mayor arranged a meeting for all the principals in town.
He never compromises on his principles.
Both these devices work on the same principle.