Hats off to [Paul Brooking] as he shows off his homemade mass spectrometer in two recent videos you can see below. The first video demonstrates that the device works. The second video shows details about how it was made.
It’s not a good starter project, requiring quite a bit of sophisticated gear including two-stage vacuum pumps, Peltier cold plates, and ion sources, but if you aren’t familiar with mass spectrometers the basic idea is simple enough. You take a sample and bombard it with electrons. This creates a stream of ions of the component parts of the sample. Ions of heavy elements, obviously, weigh more than ions of lighter elements. A magnetic field deflects the ions, and the lighter ones are deflected more than the heavier ones. By detecting ions at a certain spot in the deflected beam, you can determine the relative amount of ions at a certain mass.