SleePi sounds alarm when Raspberry Pi detects sleepiness

SleePi is a real-time sleepiness detection and alert system developed especially for Raspberry Pi and our Raspberry Pi Camera Module 2 NoIR.

Driver drowsiness detection was the original application for this project, and Raspberry Pi was chosen for it because it’s small enough to not obstruct a driver’s view and can be powered from a vehicle’s 12 V socket or a USB port.

sleepi setup
Teeny tiny setup

Our Raspberry Pi NoIR Camera has no infrared filter and can therefore detect infrared light. It was chosen for this project to help with driver visibility by infrared illumination in low light, because night time is when people are more likely to become drowsy.

Never drive tired

Firstly, you should absolutely never drive tired. The UK’s Driver and Vehicle Licensing Agency says that, by law, after every 5 hours 30 minutes of driving you must take a break of at least 30 minutes.

We’re sharing this project because we like the software behind this sleepiness detector, which can tell when your eyes narrow and alert you before you nod off. A safer application of this invention could be for exam cramming season when you don’t want to fall asleep before reading that final chapter of your revision guide. Or perhaps for the sleepier among us who need extra help staying awake for the New Year’s Eve countdown. We cannot miss another one of those. But we get SO sleepy.

How does SleePi work?

Eye Aspect Ratio (EAR)
How SleepPi uses EAR to detect sleepiness in the eyes

The camera tracks the position of the eyes and uses something called the Eye Aspect Ratio (EAR) to detect blinks. When squinting or blinking is observed, Raspberry Pi thinks you’re getting sleepy. When sleepiness is detected, a loud alarm sounds via the Raspberry Pi’s AUX port, connected to the car’s speaker system. The alarm carries on sounding until the camera detects that the user’s eyes are completely open again.

How do I build it?

Sai Sathvik is a dreamboat of a maker and left detailed instructions to help you build your own SleePi.

Are you a New Year’s Eve napper? Or a classroom snoozer? What do you need a SleePi for? Comment below telling us why you need this doziness detector.


Craig avatar

Very tempting to build something similar to sit in my parent’s front room. But instead of an alarm, it would announce it’s time for my step-dad to go to bed. He’s been falling asleep in front of the TV every evening for at least 25 years.

Richard avatar

The 5h30 legal limit is only for commercial drivers of passenger carrying vehicles. It is not illegal to drive your family in a private car from Land’s End to John O’Groats (typically ~14h30) without stopping, but it still isn’t a good idea to do it.

Joseph avatar

I still remember my Dad driving non-stop half-way across the USA. He did that quite a bit when I was kid on the way to Grandma’s. Started when it was dark and made good time while we were all asleep. Maybe not a good idea, but it’s certainly do-able, especially when you’re young and healthy.

Still, I kind of wonder. How many times something like that would have gone off, if he had one tracking him?

Ashley Whittaker avatar

Is it true Americans think a 4 hour drive is ‘normal’ for a day trip? Us over here on our tiny island would need at least one overnight stay at our destination before being lured to drive 4 hours there and back!

Mouse avatar

Four hours is nothing for a road trip in the states. Up to 14 hour long drives are normal and routine in my family.

Ashley Whittaker avatar

Mind blown 🤯
I once drove from Dollywood to Disney in Florida and it was… well I’d never do it again 😂

John Mood avatar

Try chatting up ANY US cop in a small town. I out in numerous 16 hour shifts, primarily driving on patrol, and one 36 hour shift where there was a hurricane coming through Charleston, SC USA. I spent 6 hours in chest deep water pushing drivers out of a KNOWN low spot, and I’m 6’6″ . I went by the station, got a meal, a two hour nap, a TV dinner (courtesy the city) three cups of hot coffee, and back out on the road. (Hurricane David 1982). 5 cars’ radios were destroyed by saltwater flooded into the streets by storm surge. Half the force had to get new ammunition because it was underwater so long. (In the US we carried revolvers in ’82), it ruined 1800 rounds of ammo, we generally didn’t want to or need to shoot much back then…

amogh avatar

you are right

Jim avatar

I tried this. If you just squint your eyes for a second it registers as you being sleepy. Needs a lot more work before it can be a viable solution.

Brian Weir avatar

If you’re squinting, that’s typically a sign of eyestrain and not fatigue. That’s not good for your eyes either.

Ridhma Shiroya avatar

So, I think this should be make compulsory in India. Because, it’s better technology to prevent road accidents in express ways. In addition, while reading from laptop, it also alerts you. Overall, a good solution for students and transportation service related people.

Anders avatar

Many newer cars already have such a function. I have done very long drives in my younger drives. Now, 3 hours is my limit, before I need to stop and nap. However, the level of concentration I apply to my driving nowadays is much more than it used to be.

Comments are closed