For the first time, the Food and Drug Administration has approved a digital pill — a medication embedded with a sensor that can tell doctors whether, and when, patients take their medicine.

The approval, announced late on Monday, marks a significant advance in the growing field of digital devices designed to monitor medicine-taking and to address the expensive, longstanding problem that millions of patients do not take drugs as prescribed.

Experts estimate that so-called nonadherence or noncompliance to medication costs about $100 billion a year, much of it because patients get sicker and need additional treatment or hospitalization.

“When patients don’t adhere to lifestyle or medications that are prescribed for them, there are really substantive consequences that are bad for the patient and very costly,” said Dr. William Shrank, chief medical officer of the health plan division at the University of Pittsburgh Medical Center.