The morning of Good Friday 2014 found Andy Meira standing outside his apartment in Mexico City with his wife and baby, waiting for the shaking to begin. He was one of the few people in a city of 25 million who knew an earthquake was coming, thanks to an early warning alarm, called the Grillo (Spanish for “cricket”) he’d spent the last two years building. This was the first time the prototype had gone off. If everything went well, Meira knew he should have between 60 and 90 seconds before the quake hit the city.

As soon as the Grillo chirped, Meira hurried his family to the park across the street from their building. “It was so exciting, because it was the first time it had gone off,” Meira says. “Up until then it had all been maths and coding.” When the ground actually started swirling underneath his feet in what would be a 7.2 quake, Meira and his wife were actually smiling, standing amid scared neighbors who had rushed out of their buildings after the shaking had already started.

Even though the Good Friday quake didn’t do any damage in Mexico City, earthquakes are not something residents take lightly. An 8.0 temblor in 1985 killed as many as 30,000 people and destroyed hundreds of buildings, including a major hospital. But the ’85 earthquake also motivated Mexico City to take action. No one knows how to predict when or where an earthquake will strike, but it’s possible to get advance warning when one is on its way. Seismic waves ripple outward from a quake’s epicenter in two forms: the p-wave, which oscillates up and down, and the s-wave, which moves horizontally. P-waves are weaker and faster; sense p-waves and you can be pretty sure that more dangerous s-waves are coming.

That’s how earthquake early warning systems around the world work, from a research network in California to the sophisticated public alert system in Japan, which automatically slows down trains and pings an alarm in every cell phone sold in the country. But Mexico was the first country to implement a public earthquake early warning system, up and running in Mexico City just six years after the devastating ‘85 quake. Now, Mexico isn’t a country known for its investment in science or its political will for large-scale infrastructure projects. So how did they get a public early warning system off the ground so early, when California is still struggling to scrape together the cash to implement one 25 years later?

The push came from the very thing that makes earthquakes in Mexico City so dangerous: the city’s geology, which is, to put it simply, really weird. The city sits in a high mountain valley smack dab in the middle of the country’s slim waist, on top of what was once a large lake. Indigenous people called the Mexica (you probably know them as the Aztecs) started draining the lake when they built a system of artificial islands and canals to serve as their capital city of Tenochtitlán; Spanish conquistadores and colonists finished the job so they’d have dry ground on which to turn Tenochtitlán into Mexico City.

But dry ground, unfortunately, didn’t mean stable ground. Today much of the city, particularly the oldest central neighborhoods, rests on loose sediment prone to shifting and shaking. So some of the most important parts of the third-largest city in the world sit on a quivering pile of mud. The closest faults are along the Pacific coast, over 200 miles away, and under almost any other geological conditions, seismic waves generated there would peter out well before they reached the capital. But that loose sediment acts like an amplifier. “Once the waves get into the lakebed, they bounce back and forth, and that causes a resonance,” says Vala Hjörleifsdóttir, an Icelandic seismologist who is a now a professor at the National Autonomous University of Mexico, or UNAM. It’s like sending a kid on a swing higher and higher with each tiny push—except the swing is an unreinforced 10-story building that eventually collapses on top of you.

The effect is so dramatic that the parts of the city built on lakebed can experience shaking 50 times more powerful than neighborhoods built on volcanic rock, according to Víctor Cruz Atienza, director of UNAM’s seismology department and author of the not-at-all terrifying book Earthquakes: A Daily Threat. What’s more, the amplified shaking tends to last a long time—up to three minutes in some cases, says Cruz. (The last earthquake I felt in Mexico City was so long it actually gave me motion sickness, like my building had turned into a boat.)

On the positive side, that distance between the faults and the city made it relatively easy for Mexico to build an earthquake early warning system. “The further you are from the epicenter, the more time you have,” Hjörleifsdóttir says. Over 100 seismic sensors now line the Pacific coast from Jalisco to Oaxaca as part of a network called Sasmex; an expansion of the network in 2010 built 64 more sensors inland, as well. As soon as one of those sensors feels a p-wave, it calculates how strong the related earthquake will be and radios a warning ahead to Mexico City and other places with the alert system, including Oaxaca City and Acapulco. Radio waves travel a lot faster than seismic waves—hence the 90 seconds of warning Meira expected from his Grillo in 2014.

When Meira moved to Mexico City in 2012, he wanted to get those Sasmex warnings. He’d spent the previous two years working in Haiti as part of the relief effort after the 2010 quake, and he knew the kind of damage earthquakes could do—as well as how an early warning system can protect you. But he found that SASMEX receivers weren’t easy to get. Earthquake warnings are announced on national TV and radio, but the market for actual alarms is geared toward businesses, schools, and government buildings.

In fact, the only available alarm, aside from the commercially nascent Grillo, is called Sarmex. When I called recently to ask about purchasing one, a sales rep quoted me a price of 20,490 pesos—over $1,300—for the cheapest system and the installation. That’s a price point that may make sense for protecting an entire school or office building, but is out of reach for everyone except the richest and most paranoid of private citizens. Smartphone apps can push alarms to your phone, but “there are too many steps” to make the relays reliably fast enough when the margin is 90 seconds, Meira says. (Not to mention that not everyone in Mexico City has a smartphone).

According to Meira (and the Japanese government, which has mandated physical alarms for its system be installed in cell phones), you really need your hardware to pick up the Sasmex radio signal directly and detect the code that means “earthquake”—which is exactly what he built the Grillo to do, with a little help from an engineer who works for the National Weather Service in the US. With funding from the Mexico City branch of the accelerator 500 Startups and a crowdfunding campaign, as well as a handful of pre-orders, Meira is now manufacturing the first batch of 175 Grillos.

The Grillo will sound an alarm up to 90 seconds before an earthquake hits Mexico City. The first batch of Grillos requires hand finishing. Meira has spent the last several weeks soldering wires in place. The LEDs flash red when the earthquake alarm goes off. Meira hopes to sell Grillos for 800 pesos, about 50 dollars. The Grillo's electronics pick up an emergency radio signal sent from 200 miles away, seconds after an earthquake hits Mexico's Pacific coast. The Grillo's plastic shell is manufactured in a small factory in Mexico City. The building survived a devastating quake in 1985 that killed up to 30,000 people.

A softball-sized black or white box with rounded corners, the Grillo fits the soothing aesthetic of alarms in our post-Nest age. The electronics inside come from China, and the plastic shell is from a small factory in the heart of Mexico City. For a few weeks now, Meira has spent his days helping to solder wires in place inside each Grillo, while other workers carefully fit the boxes together by hand—a process he and the factory owner, José Cappón Flores, hope to make more efficient just as soon as they raise enough money to invest in a better mold.

Meira initially hoped to sell the Grillo for 400 pesos, or about 26 dollars, though now that he’s deep into the the trials and tribulations of electronics manufacturing, he expects the finished product to cost twice that. He dreams of the day when anyone can walk into a department or convenience store, buy a Grillo, and have it up and running in their home within minutes. Unlike with SARMEX, there’s no installation fee, or different sized alarms for smaller and larger buildings. “A super non-techie person can just plug it in,” Meira says. It has a little cricket cartoon stamped on the front surrounded with LEDs that light up green when it’s getting good radio reception, and a calming blue when a SASMEX test signal goes out every three hours. (That’s how you know it’s working.) If an earthquake signal comes in, the LEDs flash red and the Grillo emits an urgent, growling beep, loud enough to wake you up but not so annoying that you’ll unplug it (I’m looking at you, smoke alarms).

Cappón, whose factory manufactures plastic goods ranging from car parts to nail polish caps, remembers the destruction of the 1985 earthquake, when the smell of dead bodies permeated the devastated city’s air. Even those memories aren’t enough to convince him to shell out the dough for a SARMEX system. “That’s my earthquake alarm,” he says, pointing to a wind chime hanging in a conference room. But the next time the city shakes, he expects to hear the tell-tale chirp of the Grillo in plenty of time for he and his employees to evacuate.