A startup is building a smartphone-connected gadget that aims to tell you if the pill you’re about to take is really what you think it is by shining light on it.

A scan of a known Viagra pill with Stratio’s LinkSquare spectrometer shows that it matches a reference scan.

San Jose-based Stratio’s device, called LinkSquare, is a tiny spectrometer—a device that measures the intensity of wavelengths of light. Since the reflected light spectrum varies from one object to another, Stratio claims it can figure out what a specific pill’s reflective signature is and then compare known pills (data for which would be stored in a smartphone app’s database) to others you may want to scan to see how they match up.

Fake drugs have proven to be a growing problem: last year, Interpol reported that it seized 20.7 million counterfeit medications in an operation aimed at rounding up those sold by online pharmacies. This was more than twice as much as they seized two years earlier.

Stratio has received some funding from the National Science Foundation and says it plans to start selling LinkSquare later this year for $199, initially through a crowdfunding campaign that is expected to start in June. The company also hopes to offer software developers tools to create their own applications for it.

Stratio says it eventually plans to branch out beyond pills to testing other items that can be mislabeled, like food (fish, for instance), and thinks it could be useful for consumers and companies, too.

“We’re hoping people can use this to assuage some of their fears about the things they consume,” says Leslie Grothaus, Stratio's head of business development and communications.

LinkSquare looks kind of like a portable smartphone battery: it’s rectangular, mostly white, with yellow on each end, and connects to a smartphone via a USB cable. There’s a little window on its long top side, onto which Stratio cofounder and systems engineering head Youngsik Kim places a Viagra pill in a demo of the device. A range of light (from the visible to the near infrared) from optical elements in the LinkSquare shines onto the pill, and the way in which the light reflects back across the pill is captured by an image sensor and illustrated in two graphs on the smartphone’s display. Kim repeats the process with two other similar-looking pills, also purporting to be Viagra (one is a generic pill, the other a fake), and their graphs look similar, but noticeably different, to the original wavy line plotted on the bottom of the smartphone’s screen.

There are still a number of challenges to be worked out, such as building a database of medications that LinkSquare will be able to detect. Kim says Stratio is researching other pills beyond Viagra, but declines to name them.

Stratio will also have to figure out how to make it easier to position objects on LinkSquare’s sensor in order to scan them properly. Kim shows me how moving one of the pills to an off-center position can change how the light reflects off of it, and says the company is trying to fix this, especially since it may be hard for elderly users—who could be interested in using LinkSquare to sort out pills.

“Making it more robust is something we need to figure out before it’s going to be sold,” he says.

This article has been updated to correct that Leslie Grothaus is not a Stratio cofounder.