Given that 15 million babies are born prematurely every year and that preterm births are a major source of health complications in kids under five, you might expect modern medicine to have a pretty good handle on the problem.

But Larry Rand, an obstetrician at the UCSF Fetal Treatment Center, in San Francisco, says the current level of understanding of what causes preterm births and how to stop them is poor. Doctors often won’t know that a women is about to give birth until her contractions set in, which is too late to address the underlying cause or to prolong the pregnancy. He compares the current quality of forewarning to that of chest pains before a heart attack. They tell you what’s about to happen, but not early enough to do something about it.

That’s where the SmartDiaphragm comes in. A device that’s placed inside a pregnant woman’s vagina, it’s designed to sense for when microscopic changes in the cervix start to happen, and thus indicate that a child is on its way. Rand says the device, once fully developed, could give up to two weeks of early warning, thus giving doctors more options to deal with a women’s health problems.

The cervix, which sits at the lower part of the uterus, is composed mostly of collagen, the same substance in our noses and ears. During pregnancy, it remains stiff, effectively stopping a baby from leaving the womb. When a baby is about to leave the uterus, the cervix will begin to break down, becoming softer and looser. It’s possible with ultrasound to see the cervix changing shape. But looking at the collagen at a molecular level gives an earlier sense of what’s happening.

The SmartDiaphragm contains two sensors for doing that. One senses for impedance: the capacity of the collagen to conduct an electric charge. When the collagen contains more water, it will conduct more charge than when it’s still taut. The second senses for fluorescence: how objects emit light when light is shone on them. Denser collagen is more florescent. The sensors send data to a smartphone via a low-power Bluetooth connection.

“It’s like a virtual biopsy of the cervix that looks at the collagen using a noninvasive means,” says Mozziyar Etemadi, co-principal investigator on the project.

Early versions of the device looked like a large wand. More recent prototypes are smaller, made of silicone, and more like birth control diaphragms. Etemadi says the final product probably will be designed so women can place the device themselves. It’s not clear if they’ll have to wear it for short periods or longer.