An irregular sleep pattern isn’t just a nightmare for over-tired parents — it can also impact negatively on a baby’s health and development. Caleb Olson created his own baby sleep tracker with Raspberry Pi 4 to make it easier for those caring for babies to know when they themselves can get some sleep with less likelihood of being dragged painfully into wakefulness seven minutes later.
Babies need around 15 hours sleep a day, but they don’t get that all in one go like most adults; it happens in several short naps during daylight hours and then, hopefully, a longer stretch at night. The jam is figuring out whether they actually need picking up and tending to when they make noise or move around in their sleep, or whether they are best left to settle themselves and continue getting the shut-eye they need. The last thing you want to do is dash to the baby’s cot in a desperate attempt to get to them before they get loud enough to wake the toddler too, when they really just needed a mid-dream gurgle and to go back to sleep.
How does it work?
A camera running Real Time Streaming Protocol wirelessly transmits images of the baby to a Raspberry Pi. Open source machine learning framework MediaPipe then determines when the baby is actually sleeping, based on their body position and eye movement.
Caleb isn’t like a regular dad, he’s a cool dad. So alongside the only-slightly-ominous owl that houses the camera watching over his baby, he also developed a web application that tracks when his baby wakes up and how long they slept for, and predicts when they’re likely to take their next nap. The app also tracks long-term sleep patterns, which, in theory, if you’re lucky, makes it possible to train the baby to take longer naps and better plan your day around their sleep schedule.
GitHub is home to all the code you need to build your own baby sleep tracker. Best of luck to all of you ploughing through the early years with young children. And kudos to Caleb — our favourite kind of dad, a a coding one.