What is a Magnetometer and How Does It Work?

What is a Magnetometer and How Does It Work?