A smartphone device could help millions of people avoid drinking water contaminated by arsenic.

Researchers have developed a biosensor that attaches to a phone and uses bacteria to detect unsafe arsenic levels.

The device, developed at the University of Edinburgh, generates easy-to-interpret patterns, similar to volume-bars, which display the level of contamination.

Researchers believe there is an urgent need to provide simple, affordable, on-site solutions for contaminated water sources.

In resource-limited countries, there is a lack of sufficiently skilled personnel and healthcare facilities to test water for contamination.

Researchers say new devices could replace existing tests, which are difficult to use, need specialist laboratory equipment and can produce toxic chemicals.

The contamination of water by heavy metals is a worldwide health issue. UNICEF reports that arsenic-contaminated drinking water is consumed by more than 140 million people worldwide.

Researchers tested the arsenic sensors using environment samples from affected wells in Bangladesh, which suffers from some of the world's highest levels of arsenic-contaminated groundwater.

An estimated 20 million people in Bangladesh - mostly rural poor - drink contaminated water.

Long-term exposure to unsafe levels of arsenic leads to skin lesions and cancers and is linked to 20 percent of all deaths in the worst-affected regions.

Researchers developed the biosensor by manipulating the genetic code of the bacteria Escherichia coli. They added genetic components to act as amplifiers when arsenic is detected.

Water samples were fed into a plastic device containing bacteria suspended in a gel. This produced fluorescent proteins that were visible in the presence of arsenic.

Researchers believe that the approach could be used to detect other environmental toxins, diagnose diseases and locate landmines.