As the Fukushima disaster unfolded in Japan, the Blue Lake Rancheria, in Northern California, was dealing with its own crisis. Several miles inland and uphill from the Pacific Ocean, the 100 acres of tribal land had turned into a haven for roughly 3,000 coastal dwellers who were fleeing a feared tsunami from that same earthquake. A huge line of cars assembled at the Rancheria’s gas station; one young woman ran in circles, holding her baby and weeping.

Local inundation ended up being relatively minor. But the Blue Lake Rancheria was shaken. “That was an eye-opener,” says Jana Ganion, sustainability and government affairs director at the Rancheria. “We need to prepare for the disasters that are reasonably foreseeable here.”

Tsunamis for one. But also the massive earthquake that’s going to devastate the Northwest. And California’s annual wildfires, made ever more vicious by climate change. These disasters all have one thing in common: They threaten to cut the Blue Lake Rancheria off from the grid for days, maybe weeks. Tucked behind the state’s “Redwood Curtain,” the Rancheria’s rural placement affords it few access points, and roads may be inaccessible in the aftermath of a disaster.

Blue Lake Rancheria

The answer was to help pioneer what could be the future of energy in California and beyond. Working with scientists at the Schatz Energy Research Center at nearby Humboldt State University, and the local utility PG&E, the Rancheria developed its own solar-powered microgrid, allowing it to disconnect from the main grid and run off Tesla battery power. The setup powers six buildings, including a 55,000-square-foot casino and 102 hotel rooms—over 140,000 square feet of total building space.

Matt Simon covers cannabis, robots, and climate science for WIRED.

The tribe—which tallies just 49 members—is under constant threat from wildfire, along with many other communities in California. In autumn seasonal winds rustle electric equipment, showering sparks onto dry brush below. State officials have blamed PG&E for starting 17 of California’s 21 major fires in 2017 alone, as well as for last year’s devastating Camp Fire, which virtually destroyed the town of Paradise, leveling almost 20,000 buildings and killing 85. If the utility had cut power when winds near Paradise became particularly intense, that deadly blaze might never have ignited. But concerns about local hospitals and other emergency facilities tend to prevent utilities from taking such preemptive actions. Switching to microgrids during especially dangerous wind storms could keep the state’s mountain towns much safer.

Blue Lake Rancheria

But take it from the Blue Lake Rancheria: Building a microgrid isn’t so easy as throwing up a bunch of solar panels, bolting batteries to the ground, and saying au revoir to the grid at large. It takes a whole lot of time and expertise and money, about $6.3 million for the Rancheria so far—$5 million in R&D money granted by the California Energy Commission in 2015, and the rest coming from the Rancheria itself. But that research money is an investment that communities throughout California could soon benefit from.

Construction of the Rancheria’s microgrid began in May 2016, and a little over a year later, PG&E gave its blessing to begin operation. In an ideal world where the sun always shines, the Rancheria could power itself indefinitely, recharging its batteries using more than 1,500 solar panels during the day and depleting them in the evening. But on a gloomy day, such as the one on which I toured the grounds, the panels struggle to collect photons—they’re generating 120 kilowatts, compared to 420 kilowatts when the sun is cranking full-blast. On a typical day the Rancheria still draws a small amount of power from PG&E’s grid to stabilize the system. But if they lose that connection for whatever reason, those six core buildings could theoretically last for months on solar power, with backup generators kicking in at night or during periods of cloudiness.

LEARN MORE The WIRED Guide to Climate Change

At the entrance to the Rancheria’s offices, Dave Carter, managing research engineer at Schatz Energy Research Center, shows me a pair of flat screens. One displays a family-tree-looking diagram, with lines connecting the utility and microgrid to buildings like the hotel and casino and offices. The other screen displays a graph of energy pricing throughout the day. Noon to 6 pm is when electricity costs the most, so the system charges the batteries in the morning, so it can be discharged in the afternoon when the utility has its peak pricing.