Goodnight - Measuring sleep cycles
alowhum last edited by
I'd like to make an sensor to measure my sleep cycle, in combination with MySensors. I couldn't find any earlier projects - forum posts involving "sleep" are all about low power sensors
Most commercial solutions are not privacy friendly.
- Are there projects using MySensors that I've overlooked?
- Should I do the analysis on the Arduino? or..get the sensor data into Domoticz, and do the processing there?
The sensor will have continuous power (it doesn't get to sleep).
In the end I'd like to slowly raise the lights in the room at the right moment, for example.
- What should it measure?
Motion is the obvious thing. The sensor that seems most logical to use is the MPU-6050, a common gyroscopic motion sensor (1$). But perhaps a CO2 sensor would also make a powerful combination, to better indicate sleep quality?
- How can the patterns of two people be deduced?
This is probably a question for later, somewhere in software. Commercial solutions seem to simply use two sensors, one for each pillow.
- Are there "out of the box" alternative methods I'm not thinking about? For example, the Xiaomi Mi Band is a very cheap fitness tracker. It usually communicates with your phone over Bluetooth LE, and is already used to measure sleep patterns. Perhaps the signal it generates can be used instead.
I've found a few Arduino projects online:
For this kind of project, HW plays a small role as most of the work is done in the SW to actually analyse data and give you the results. I have a Mi Band 2 but I can tell you that is not comparable with the Jawbone UP24 I had before (besides that the Mi Band it is still working and the Jawbone's battery died after 10 months and I couldn't get it replaced under warranty as they claimed the device suffered a shock, I am glad they have gone bankrupt even though the SW was really great).
Interesting subject. The PIR based project seem a good start, I don't think a CO2 sensor could give you any valuable information, I don't see what sleep related element you could measure with it ?
Motion sensor is not necessarily a better solution as you could move your legs and not your arms for example. But if you want to go this way program using a nrf51822 or nrf52832 and not arduino, so you can use a cheap fitness tracking watch using those sensors and available on ebay/aliexpress etc.
You can have a look at this solution using PIR, not all pages are available without paying for the full book, but the most important are including the methodology used and the arduino code on page 521
https://books.google.com.vn/books?id=aDysDAAAQBAJ&pg=PA514&lpg=PA514&dq=arduino+Hypnagogia+detection&source=bl&ots=sImWOf6rqf&sig=224GXZTxhpbckb8_DO1zYR_bpFE&hl=fr&sa=X&redir_esc=y#v=onepage&q=arduino Hypnagogia detection&f=false
Q1: I haven't seen any
Q2: I think you will need more processing power than the Arduino can provide, but that depends on which method you choose. The first project you linked does the processing on a laptop.
MotionGyro and sound are probably the easiest to use.
Q5: Page 6 in section/book 2 of https://se.mathworks.com/campaigns/products/offer/machine-learning-with-matlab.html has some ideas that might be useful.
alowhum last edited by
Thanks for the great replies!
@gohan I agree. Sorry to hear about the jawbone..
@nca78 - many people sleep poorly because they sleep in confined rooms where the CO2 level rises too high. A CO2 sensor could warn if the door/window has been closed, and remind not to do that.
@mfalkvidd A motion sensor, like in those lamps? Interesting idea. Would the movement it picks up be enough to deduce the sleepcycle I wonder.
@alowhum sorry, I meant gyro. Motion (PIR) would probably be too coarse.
Sound and gyro seems to be what the iphone and android apps use. My Xiaomi Mi Band 2 uses gyro and pulse. Pulse is measuring by shining two green leds and measuring the reflected light. Shines a lot in a dark bedroom
I am no scientist so I have no idea how "light sleep" is differentiated from "deep sleep", so unless you get a clear understanding of how the body reacts to different sleep states, you can't design a sensor and software that can give you any good answer (and without any lab equipment to actually compare the data to, it is actually pointless as measurement you make just gives you crude numbers without you knowing if they are good or not)
@gohan it seems you don't move much during deep sleep so a high number of movement during a time window can tell you when you are in light sleep and in a good moment to wake you up.
wallyllama last edited by
Did you see this project? Seems like it could give a lot of data on sleep.
I tried jawbone and mi band 2 together for some weeks and the results were not similar.... So I'm wondering how can we do it accurately if commercial products give different results already