Machine Learning Baby Monitor, Part 2: Learning Sleep Patterns

The first lesson a new parent learns is that the second you think you’ve finally figured out your kid’s patterns — sleeping, eating, pooping, crying endlessly in the middle of the night for no apparent reason, whatever — the kid will change it. It’s the Uncertainty Principle of kids — the mere act of observing the pattern changes it, and you’re back at square one.

As immutable as this rule seems, [Caleb Olson] is convinced he can work around it with this over-engineered sleep pattern tracker. You may recall [Caleb]’s earlier attempts to automate certain aspects of parenthood, like this machine learning system to predict when baby is hungry; and yes, he’s also strangely obsessed with automating his dog’s bathroom habits. All that preliminary work put [Caleb] in a good position to analyze his son’s sleep patterns, which he did with the feed from their baby monitor camera and Google’s MediaPipe library.

This lets him look for how much the baby’s eyes are open, calculate with a wakefulness probability, and record the time he wakes up. This worked great right up until the wave function collapsed the baby suddenly started sleeping on his side, requiring the addition of a general motion detection function to compensate for the missing eyeball data. Check out the video below for more details, although the less said about the screaming, demon-possessed owl, the better.

The data [Caleb] has collected has helped him and his wife understand the little fellow’s sleep needs and fine-tune his cycles. There’s a web app, of course, and a really nice graphical representation of total time asleep and awake. No word on naps not taken in view of the camera, though — naps in the car are an absolute godsend for many parents. We suppose that could be curated manually, but wouldn’t doubt it if [Caleb] had a plan to cover that too.

Continue reading “Machine Learning Baby Monitor, Part 2: Learning Sleep Patterns”

Sleep Posture Monitor Warns You Away From Dangerous Positions

Age, we’re told, is just a number, but that number seems to be the ever-increasing count of injuries of a ridiculous nature. Where once the younger version of us could jump from a moving car or fall out of a tree with just a few scrapes to show for the effort, add a few dozen trips around the sun and you find that just “sleeping funny” can put you out of service for a week.

Keen to avoid such woes, [Elite Worm] came up with this sleep posture alarm to watch for nocturnal transgressions, having noticed that switching to a face-down sleeping position puts a kink in his neck. He first considered using simple mechanical tilt switches to detect unconscious excursions from supine to prone. But rather than be locked into a single posture, he decided to go with an accelerometer instead. The IMU and an ATtiny85 live on a custom PCB along with a small vibrating motor, which allows for more discrete alerts than a buzzer or beeper would.

Placed in a 3D printed enclosure and clipped to his shorts, the wearable is ready to go. The microcontroller wakes up every eight seconds to check his position, sounding the alarm if he’s drifting into painful territory. [Elite] did some power analysis on the device, and while there’s room for improvement, the current estimated 18 days between charging isn’t too shabby. The video below has all the details; hopefully, design files and code will show up on his GitHub soon.

Considering that most of us spend a third of our life sleeping, it’s little wonder hackers have attacked sleep problems with gusto. From watching your brainwaves to AI-generated nonsense ASMR, there’s plenty of hacking fodder once your head hits the pillow.

Continue reading “Sleep Posture Monitor Warns You Away From Dangerous Positions”

A Sleep Monitor For Minimum Outlay

There are a variety of instruments used in sleep studies to measure bodily activity during sleep and consequent sleep quality. Many of them use techniques that perhaps aren’t so easy to replicate on the bench, but an EEG or electroencephalograph to measure brain waves can be achieved using a readily-available module. [Ben Jabituya] shows us a sleep monitor using one of these modules, an EGG Mikroe Click.

The brains of the operation is an Adafruit Adalogger Feather M0, which is hooked up to a headband containing the sensing electrodes. The write-up gives us a round-up of the available boards, which should be handy for any experimenters in this field. The firmware meanwhile was written using the Arduino IDE. It collects raw sampling data to an SD card, and one surprise comes in just how relatively small a space it requires to store a night’s results.

Finally, a Python script was used to process the data and turn it into a spectrogram to look at brain activity through the night. He envisages using the device for triggering lucid dreaming during REM sleep, but we can see it might be rather useful for sleep disorder sufferers, too. Take a look at it in the video below the break. Continue reading “A Sleep Monitor For Minimum Outlay”

AI-Generated Sleep Podcast Urges You To Imagine Pleasant Nonsense

[Stavros Korokithakis] finds the experience of falling asleep to fairy tales soothing, and this has resulted in a fascinating project that indulges this desire by using machine learning to generate mildly incoherent fairy tales and read them aloud. The result is a fantastic sort of automated, machine-generated audible sleep aid. Even the logo is machine-generated!

The Deep Dreams Podcast is entirely machine-generated, including the logo.

The project leverages the natural language generation abilities of OpenAI’s GPT-3 to create fairytale-style content that is just coherent enough to sound natural, but not quite coherent enough to make a sensible plotline. The quasi-lucid, dreamlike result is perfect for urging listeners to imagine pleasant nonsense (thanks to Nathan W Pyle for that term) as they drift off to sleep.

We especially loved reading about the methods and challenges [Stavros] encountered while creating this project. For example, he talks about how there is more to a good-sounding narration than just pointing a text-to-speech engine at a wall of text and mashing “GO”. A good episode has things like strategic pauses, background music, and audio fades. That’s where pydub — a Python library for manipulating audio — came in handy. As for the speech, text-to-speech quality is beyond what it was even just a few years ago (and certainly leaps beyond machine-generated speech in the 80s) but it still took some work to settle on a voice that best suited the content, and the project gradually saw improvement.

Deep Dreams Podcast has a GitLab repository if you want to see the code that drives it all, and you can go to the podcast itself to give it a listen.

Rock-A-Bye Baby, On The Mechatronic Crib Shaker

While an engineering mindset is a valuable tool most of the time, there are some situations where it just seems to be a bad fit. Solving problems within the family unit would seem to be one such area, but then again, this self-rocking mechatronic crib seems to be just the cure for sleepytime woes.

From the look of [Peter]’s creation, this has less of a rocking motion and more of a gentle back-and-forth swaying. Its purpose is plainly evident to anyone who has ever had to rock a child to sleep: putting a little gentle motion into the mix can help settle down a restless infant pretty quickly. Keeping the right rhythm can be a problem, though, as can endurance when a particularly truculent toddler is fighting the urge to sleep. [Peter]’s solution is a frame of aluminum extrusion with some nice linear bearings oriented across the short axis of the crib, which sits atop the whole thing.

A recirculating ball lead screw — nothing but the best for [Junior] — and a stepper drive the crib back and forth. [Peter] took care to mechanically isolate the drivetrain from the bed, and with the selection of the drive electronics and power supply, to make sure that noise would be minimal. Although thinking about it, we’ve been lulled to sleep by the whining steppers of our 3D printer more than once. Or perhaps it was the fumes.

Hats off to [Peter] for a setup that’s sure to win back a little of the new parent’s most precious and elusive commodity: sleep.

This Bunny Reminds Toddlers That It’s Night Time

It’s easy to spot recent parents, they are the people who look as though they haven’t slept in months. Sometimes the little bundle of joy responsible isn’t even a babe in arms but a toddler; old enough to wake up and find their parents for some solace but not old enough to understand that not everyone is up for being woken at 3 am. [Eyal] approached this problem in some style, by modifying a rabbit night light to indicate the time by changing colour, reminding the youngster when it’s a bit early to be rousing the grown-ups.

The bunny in question is a plastic moulding, sold with a white LED providing illumination, This was removed, and replaced with a rather nice custom PCB sporting a ring of addressable LEDs surrounding a Wemos ESP8266 board. In the darkest hours of the night, it is lit as a soft red to indicate sleep time. When an appropriate wake-up point is reached it bursts into a vibrant light show of many colours. Thus the recalcitrant early-riser can be taught to give Mum & Dad a little rest through the medium of light and colour.

This isn’t the first kids night light we’ve seen, indeed some of them have been rather elegant.

DodowDIY Is A Homebrew Sleep Aid

The Dodow is a consumer device that aims to help users sleep, through biofeedback. The idea is to synchronise one’s breathing with the gentle rhythm of the device’s blue LEDs, which helps slow the heartrate and enables the user to more easily drift off to sleep. Noting that the device is essentially a breathing LED and little more, [Daniel Shiffman] set about building his own from scratch.

An ATTiny85 runs the show; no high-powered microcontrollers are necessary here. It’s hooked up to three 5mm blue LEDs, which are slowly ramped up and down to create a smooth, attractive breathing animation. The LEDs are directed upward so that their glow can be seen on the ceiling, allowing the user to lay on their back when getting ready for sleep. It’s all wrapped up in a 3D printed enclosure that is easily modifiable to suit a variety of battery solutions; [Daniel] chose the DL123A for its convenient voltage and battery life in this case. The design is available on Thingiverse for those looking to spin their own.

It’s a neat example of where DIY can really shine – reproducing a somewhat-expensive gadget that is overpriced for its fundamental simplicity. Now when it comes to waking up again, consider building yourself a nifty smart alarm clock.