Here is an org doing professional gas chromatograph work -- you can send them a sample of whatever drugs you've purchased plus $53 and they'll tell you what you have and the purity: https://medium.com/backchannel/inside-the-deep-web-drug-lab-... . If we actually cared about people who use drugs, we'd offer these sorts of services, and support orgs like dancesafe.
A better, and newer, option is to use Raman spectroscopy, which relies on the intrinsic molecular vibrations of a material (phonons) to shift the wavelength of interrogating light by a characteristic magnitude[1]. Once the Raman spectra is obtained, sample identification is a matter of finding the spectrum of the most similar compound in a database of known spectra. So in order to correctly identify something, it helps if it has been seen before and is present in the database.
Because Raman spectrometers are essentially a laser, some very narrow optical notch filters (band rejection at the interrogating frequency), and some fairly sensitive semiconductor detectors (often in the form of a mini spectrophotometer), the instruments can be made quite small. Some are even handheld and have integrated material databases[2].
1. http://en.wikipedia.org/wiki/Raman_spectroscopy
2. http://www.thermoscientific.com/content/tfs/en/product/trusc...
https://www.consumerphysics.com/myscio/technology
http://en.wikipedia.org/wiki/Near-infrared_spectroscopy
I suspect a lot of naive users would end up measuring the pill coating.