As you peer out the window of a BART car, you notice that the train is starting to slow, even though there’s no station nearby. Then, before you can turn to ask fellow passengers what’s going on, a distinct tone starts blaring from the cellphones all around you.

“Earthquake! Earthquake! Expect shaking,” your smartphone’s screen reads. “Drop. Cover. Hold on. Protect yourself now.” Seconds later, the train begins to rattle.

That’s the kind of scenario envisioned by the planners of ShakeAlert, an earthquake-warning system for California, Oregon and Washington. After more than a decade in development, it is finally about to become a reality for tens of millions of West Coast residents. The system is designed to alert them just seconds before the shaking starts so they can take cover or find a safer place to ride out the quake.

“The biggest commodity within the world of earthquake early warning is time,” said Robert-Michael de Groot, a U.S. Geological Survey scientist who is one of the coordinators of the ShakeAlert system.

Built on top of several dangerous fault lines, California already has more than 600 seismic sensors feeding data to ShakeAlert. Most are located on or near major faults and population centers along the coast.

Businesses and public agencies such as BART are already acting on alerts from the system. And the city of Los Angeles this month unveiled a pilot program aimed at alerting L.A. County residents of earthquakes of magnitude 5.0 or greater via a cellphone app, as government agencies and private firms continue to develop and test ways to expand the system for broader public use.

Depending on someone’s distance from the epicenter, the warning will range from a few seconds to tens of seconds.

USGS started developing ShakeAlert in 2006 with the help of partners that include UC Berkeley, the California Institute of Technology and the Southern California Earthquake Center. The project has received more than $100 million in funding from the federal government, the California Governor’s Office of Emergency Services and private sources such as the Gordon and Betty Moore Foundation.

In his first budget, Gov. Gavin Newsom this month set aside $16.3 million from the state’s general fund to finish the ShakeAlert system.

Several countries, including Japan, Mexico, China, Turkey and Romania, already have earthquake warning systems in place. The warnings are broadcast on television and radio and are sometimes blasted from municipal loudspeakers. Japan’s system, widely seen as the most advanced, can send alerts to certain brands of cellphones. The system went live in 2007.

Some elected officials in California have bemoaned the fact that a statewide system is not yet up and running here. But some scientists point out that unlike other countries with major earthquake faults, the United States has not had a catastrophic quake that resulted in massive loss of life since the 1906 San Francisco earthquake. As a result, U.S. funding priorities for an early warning system haven’t been as urgent as in other quake-prone countries.

“The system in Japan was developed as a result of the 1995 Kobe earthquake,” de Groot said. “And it took Japan roughly 10 years to develop their system. So I don’t think ShakeAlert in its development stages has really been slower than other countries.”

In addition, de Groot said, “we are arguably building the most advanced early earthquake-warning system in the world, so it takes longer to develop and test.”

USGS estimates that the three-state ShakeAlert system will cost $39.4 million to build, but those costs could still rise if states are not provided adequate use of existing communication systems and must build their own data infrastructure. The system will cost $38.4 million per year to maintain and operate, according to USGS estimates.

California’s portion of the system is now only half-finished. But with the recently secured state and federal funding, California’s network of 1,115 seismic sensors and about two-thirds of the system in the Pacific Northwest should be completed within the next two years, USGS says.

The earthquake warnings are possible because when a fault slips, it generates two kinds of waves. The initial waves travel faster but are weaker than the more damaging second set of waves.

When seismic sensors detect the first waves, they will quickly send alerts to monitoring centers in Seattle, Menlo Park, Berkeley and Pasadena. Within about 5 seconds, computer algorithms will then analyze the data to rapidly identify the epicenter and strength of the earthquake and decide whether the temblor will be powerful enough to warrant an alert.

Then the real challenge begins — getting a short, clear message to millions of people within the next 10 seconds.

“It ceases to be earthquake early warning when you get the message 30 seconds later,” de Groot said. “It’s earthquake notification.”

Sharie Starkie, a Redwood Estates resident who was working at a small technology company in Sunnyvale when the 1989 Loma Prieta earthquake struck, believes the system could be a lifesaver.

Starkie recalled that she had just finished putting items away in the stockroom when the shaking started that October afternoon. “I remember the shelves were just falling into each other and thinking how lucky I was that I was not back in that shelving at that time,” she said.

With a 5- to 10-second warning, Starkie said, she would have been able to get outside the building instead of having to stand in a doorway.

The ultimate goal is to send the alerts to every cellphone in the quake zone, but that’s one of the biggest technological hurdles.

While the government can use the Federal Emergency Management Agency’s Integrated Public Alert and Warning System to communicate with the public through television, Amber Alerts and other methods, the system isn’t currently fast enough for earthquake warnings. Cellphone alerts can take tens of seconds, or even minutes, to be delivered.

ShakeAlert officials say warnings will also be sent to public announcement systems, as is currently being done in Los Angeles City Hall. And the private sector is now developing the equipment to alert the public and trigger lifesaving actions such as shutting off gas lines to help prevent fires, opening doors at fire stations to ensure that engines aren’t trapped inside, and stopping elevators at the closest floors.

BART began using the alerts to decrease the speed of trains in 2012, said Anna Duckworth, a BART spokeswoman, who argues that a 10-second warning can be significant.

“It may not seem like a lot of time, but in those 10 seconds if we could slow (a train) down to almost half the speed it was going, that’s critical to preventing derailments,” she said. “It can stop people from getting hurt in the case of violent shaking, and in the long run it helps keep the system operational because we can minimize damage.”

But ShakeAlert, de Groot said, “is not going to be the panacea.”

Depending on the speed of the technology and the distance from an epicenter, warnings will not always be possible. And there will always be the possibility of false alarms.

Margaret Vinci, ShakeAlert’s Southern California coordinator, said California is “a very complex earthquake area” and that makes accurate warnings more challenging. The state can be having more than one earthquake at a time and that can make identifying tremors within milliseconds hard to get right, she said.

Related Articles Map: 4.6 earthquake in Los Angeles

4.5 earthquake rattles Southern California

East Bay gets shaken by two earthquakes

Grim milestone in Santa Cruz County: CZU fire more destructive than Loma Prieta earthquake “Our sensors also pick up all ground motion,” Vinci said. “It could be a nuclear blast in North Korea. It could be a quarry blast. It could be a sonic boom.”

But, she suggested, occasional false alarms might serve as reminders of the need for Californians to get ready for the Big One.

“We have to be prepared,” de Groot said. “ShakeAlert is one part of that preparedness.”

Correction: January 25, 2019

An earlier version of this article incorrectly stated that there has not been a magnitude 7.0 earthquake in the United States since the 1906 San Francisco earthquake. While the continental U.S. has not had a quake of magnitude 7.0 or greater since the 1906 San Francisco earthquake, the state of Alaska has experienced 12 earthquakes of that magnitude or greater since 1906.