Your smartphone can post Twitter updates and find late-night pizza. But warn you of a hazardous chemical spill? Soon there will be an app for that too. The Department of Homeland Security is working on technology that allows cellphones to double as chemical detectors.

In 2008, a DHS team led by electrical engineer Stephen Dennis began investigating ways to make sensing equipment more ubiquitous and realized that nearly every person carries a computer powerful enough to run chemical-detection algorithms. The plan: When a person’s phone senses a hazardous gas in the air, it notifies local authorities, who analyze the threat and, if the gas is deadly, warn everyone in the vicinity via text message. The only hitch is, the sensors used to identify toxins are not exactly standard on iPhones.

Dennis presented the idea, dubbed Cell-All, to cellphone makers, who agreed that if DHS could devise a system that didn’t drain battery power and added just $1 to handset costs, they would consider implementing it. His group began brainstorming with NASA scientists, cellphone-chip giant Qualcomm, and sensor developer Rhevision Technology. This winter, they produced three prototypes of phones that can detect deadly industrial gases such as chlorine and ammonia.

Cell-All, Dennis says, could be ready in three years, depending on how well 40 phones work together to sniff out threats during field tests this summer. Among the variables to examine are how much air needs to flow over the sensor to get an accurate reading, how many phones it takes to pinpoint a threat—and whether the sensors can work through a pair of jeans. “We might find that the phones should only scan while you’re talking on the phone,” Dennis says. “We don’t want to drain the battery sampling pocket lint.”

How Cellphones Could Save You

1 Sample the air
A Cell-All-equipped phone senses a hazardous agent in the air. The first versions will identify dangerous industrial spills, like chlorine and ammonia.

2 Analyze the threat
A porous silicon chip in the sensor changes color if certain toxins are present. A camera reads this change and determines the nature of the chemical.

3 Alert the police
The cellphone sends a message to local authorities relaying the location and type of spill. Agents can confirm the hazard with data from nearby cellphones.

4 Spread the word
If there’s a threat, the command center could send an evacuation text message to people within range of the cell tower, like a reverse 911 call.