Protecting the environment by detecting hazardous substances