Like other protected forests around the world, Tambopata National Reserve in southeastern Peru is under constant threat from illegal logging. But with limited resources and just a handful of rangers to help protect the 1,000-square-mile reserve, authorities there have found it hard to catch loggers in the act.

But last March, cleverly designed listening devices placed high in Tambopata’s trees detected the sounds of chainsaws in the area and automatically sent an urgent alert to the authorities, who swooped in and arrested two men.

“Without this information, what would happen is that you can never get the authorities in place by the time you need them there,” said Luisa Ríos, a coordinator for the Lima-based Peruvian Society for Environmental Law.

If the arrests were good news for the locals, they also represented a victory of sorts for the global environment. Forests soak up vast amounts of the greenhouse gas carbon dioxide while pumping out oxygen, and forest loss around the world contributes a hefty 17 percent of the carbon emissions that drive climate change.

In some regions, illegal logging accounts for up to 90 percent of deforestation — and there’s never been a good way to stop it.

Guardians of the forest

The devices that brought down the Tambopata loggers are among the hundred or so that the Rainforest Connection, a San Francisco-based nonprofit, has deployed in forests in Peru and nine other nations in recent years.

Forest "guardians" are created by tethering old cellphones to solar panels, which then stream recordings of the rainforest to the cloud to be analyzed. Rainforest Connection

Consisting of smartphones tethered to solar panels, the devices — nicknamed "Guardians" — listen in on animal calls, wind, rain, and other ambient sounds and continuously transmit the audio to the cloud, where they’re analyzed by machine-learning algorithms similar to those police use to detect gunshots in urban areas.

If acoustic signatures of logging are detected, the phones alert authorities via text or email — as happened in the Tambopata reserve.

“Rangers and guards, they barely have enough fuel and manpower to go out to [large forested areas] on a regular basis,” said Rainforest Connection CEO Topher White. “So having this real-time counting of what’s happening in the park is important for them to be able to choose where they go on a given day.”

Each device can listen in on about one square mile of forest, so they directly monitor only about 100 square miles of land. But because the devices are strategically placed where loggers tend to access protected areas, they help protect about 1,000 square miles of forest, White said.

That’s a tiny fraction of the 15 million square miles of forested land around the world, of course, but the devices now in place are enough to help keep some 6.5 million metric tons of carbon locked in trees rather than released into the atmosphere by logging.

And there are plans to deploy many more of the devices. “Over the next six to eight months, we expect to launch at least 200 Guardians in 20 new endangered forest sites across the Amazon, Africa, Indonesia and North America,” Saskia Fisher, an outreach coordinator for the nonprofit, told NBC News MACH in an email.

She said the additional devices would help protect an additional 2,000 square miles of forest — the equivalent of taking four million cars off the road for a year.

One of Rainforest Connection's "guardian" devices installed high in the tree canopy to serve as forest sentinels. Rainforest Connection

Michael Wolosin, head of the Washington D.C.-based research firm Forest Climate Analytics, shares White’s enthusiasm for the guardian program. “To actually catch the bad actors who are stealing the trees, in real time, get somebody arrested, or stopping them as soon as they’ve cut down one tree and before they’ve cut down 10 trees, I think is absolutely a critical part of the picture,” he said.

A better way

There are other ways to keep tabs on illegal logging but nothing that provides real-time enforcement.

Since 2014, Global Forest Watch, an initiative run by the Washington D.C.-based World Research Institute, has been using photographs taken by NASA's Landsat satellites to detect forest clearing. Software developed by the University of Maryland’s Global Land Analysis and Discovery (GLAD) lab spots any rapid loss of greenery by comparing an image of one area to an image of the same area taken eight days previously.

If suspicious changes are seen, GLAD alerts are sent to local communities or authorities on the ground.

But since many days pass before an alert is sent, it’s hard for authorities to catch loggers in the act. What’s more, LandSat imagery lacks the resolution required to detect the loss of individual trees, or any patches smaller than about 100 by 100 feet.

Wolosin says new satellite technology could help solve both problems. For instance, swarms of low-cost “microsatellites” that can take frequent, high-resolution images are being tested, but there are not yet enough of them in orbit to provide continuous real-time monitoring across the globe.

For now, Peru’s Tambopata National Reserve is counting on the guardians.

Protecting such areas is important not only for the sake of the climate but also for wildlife and for the indigenous people who live there. “These people are threatened by illegal activities,” Ríos said. “When you are protecting the forest, you are also protecting everything that is in there.”

FOLLOW NBC NEWS MACH ON TWITTER, FACEBOOK, AND INSTAGRAM.