Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. Has anyone here made a sleep tracker for measuring your quality of sleep at night?

Has anyone here made a sleep tracker for measuring your quality of sleep at night?

Scheduled Pinned Locked Moved General Discussion
21 Posts 9 Posters 3.3k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Vincent GijsenV Offline
    Vincent GijsenV Offline
    Vincent Gijsen
    wrote on last edited by
    #11

    THe NRF58122 can also be used with the NRF24l01 aircompatible protocol (instead of BLE), integrating even more into mysensors, as a notification device for example

    1 Reply Last reply
    0
    • alowhumA alowhum

      I'm also building a sleep tracker alarm clock. This is what I'm working on:

      Software:

      • Use Sadeh algorithm.
        Example. Simple explanation. Here's some hardcore science.

      Hardware:

      • Use HB100 or similar doppler radar pointed at the bed. I have a normal radar in my current experiment, but I would also like to get the movement intensity as well, for even better detection. I don't want anything that has to be put in the bed, or that has to be worn. Too annoying. The data is sent to the controller.
      • Use bright LED that the Arduino slowly fades up in intensity as the ideal wake up time approaches.
      • If still not awake at the deadline time, play a sound. Either a normal buzzer that plays a tune, but preferably I want to use a little $2 device that allows for audio recording and playback, and that can be triggered via a pin. This way fun wake up messages can be played, which gives it a nice social aspect.
      • An RTC keeps the time. I don't want users to have to set the time, so I'm exploring how to automate that (get it from MySensors most likely, but there ways of over engineering this..).
      • Use a Serial LCD screen that has built in drawing functions to create graphs of the previous night. It also shows the time.
      • Add in a MH-Z19B CO2 detector, and also show a graph for that. From experience I think a CO2 sensor is useful in the bedroom. This data is sent to the controller.
      • Possible: use a PIR sensor to detect when people are standing up in the middle of the night (pointed to the regio above the bed, or the door), so that the system can be sure that this is an awake moment.
      • Probably not: add in a CO sensor.

      Interface

      • Probably use a endless rotation knob with built in button to set the wake up time. Another option is a joystick (could be a fun design element).
      • Pressing a button when you want to go to bed starts the system, and turns off the LCD. No light during sleep!
      • When you are supposed to wake up the LED's but also the screen turns on, so you can see the clock and graph data.
      • During the night, if the PIR is triggered, the screen could turn on shortly to show the time.
      • Possibly: toggle if there is one or two people sleeping in the bed.
      • Possibly: toggle if a child or adult is sleeping in the bed.

      Issues

      • The current design means that you have to turn on the alarm every night. The advantage is that you are less likely to record sex activities - that would be creepy.
      • If two people sleep in the bed, the wake up functionality cannot be precise. But it can still work on a simpler level: wake both up when neither is in REM sleep - in other words, allow waking up procedure to start when there is significant movement.

      Interesting sources

      Commercial devices comparison
      http://sleep.cs.brown.edu/comparison/
      https://blog.adafruit.com/2016/05/31/smarter-sleep/
      https://onlinelibrary.wiley.com/doi/full/10.1111/j.1365-2869.2008.00706.x

      Maker creations
      https://code.google.com/archive/p/lolosalarmclock/ (2010, download the zip from Google Code). Youtube Video.
      http://flyingpudding.com/projects/sleep_tracker/
      https://www.instructables.com/id/WeggUp-A-sleeping-cycle-and-light-alarm-clocke/
      https://link.springer.com/chapter/10.1007%2F978-3-319-44215-0_36 (scientific, but hidden behind paywall :-( )
      https://www.instructables.com/id/Sleep-Cycle-Alarm-Clock-with-Motion-Sensor/ (very basic, alarm goes off after 3 detections of motion)
      https://forum.mysensors.org/topic/9444/clock-with-temperature-humidity-and-co2-level-sensors/2 (MySensors alarm clock, no sleep cycle detection)
      https://github.com/leoscholl/sense-alarm/blob/master/worker_src/c/accel.c (Pebble watch app that seems to use Sadeh algorithm)

      What you could measure
      track heart-rate
      breathing
      body temperature
      sound
      ambient light
      EEG (brainwaves)
      (source)

      What professionals measure:
      "Professional sleep clinics use polysomnography,which involves taking multiple measurements including brain activity, eye movements, heart rate and rhythm, blood pressure, and the amount of oxygen in your blood." Source

      scalzS Offline
      scalzS Offline
      scalz
      Hardware Contributor
      wrote on last edited by scalz
      #12

      @alowhum said in Has anyone here made a sleep tracker for measuring your quality of sleep at night?:

      • Use HB100 or similar doppler radar pointed at the bed.

      I'm already shutting down wifi during night because I think we already eat too much waves (because of this +security, I don't want or can't rely on wifi), so I'm not sure if I would like to have doppler pointed to me during nights. Maybe I'm paranoid, maybe not :)

      1 Reply Last reply
      0
      • alowhumA Offline
        alowhumA Offline
        alowhum
        Plugin Developer
        wrote on last edited by
        #13

        Well, scientifically speaking those high frequencies wouldn't penetrate your body.

        More interestingly, I tried the PIR sensor last night, and to my surprise it gave more data than the radar sensor. It saw motion when the radar sensor didn't. So maybe the PIR is the way to go.

        @jamzm It depends on what your goal is. While I can't speak for @NeverDie, my goal is not medical. And as my scientific sources in the post above point out, for simple things like figuring out the best time to wake you up, a simple movement indication is totally fine.

        Basically the rule of the alarm clock should be:

        • Wake up where there is at least some movement in bed, indicating the sleeper is not in the REM phase (when you basically become motionless).

        Simple. And this is what one of the existing Arduino alarm clocks basically does.

        With the Sadeh algorithm this can become a bit more precise, as you can also take the sleep cycle into account. The PIR sensor actually seemed to show periods of no movement 90 minutes apart. I didn't even expect that, since there were two people sleeping in the bed.

        The Sadeh alghorithm is really simple too.

        • If there are 15 continuous minutes in which there is very little to no movement, then this is designated as the REM phase.
        • From then on you switch what you are looking for, and basically wait for a 5 minute period in which there is lots movement. That's the best time to start the wake up procedure.
        NeverDieN 1 Reply Last reply
        1
        • alowhumA alowhum

          Well, scientifically speaking those high frequencies wouldn't penetrate your body.

          More interestingly, I tried the PIR sensor last night, and to my surprise it gave more data than the radar sensor. It saw motion when the radar sensor didn't. So maybe the PIR is the way to go.

          @jamzm It depends on what your goal is. While I can't speak for @NeverDie, my goal is not medical. And as my scientific sources in the post above point out, for simple things like figuring out the best time to wake you up, a simple movement indication is totally fine.

          Basically the rule of the alarm clock should be:

          • Wake up where there is at least some movement in bed, indicating the sleeper is not in the REM phase (when you basically become motionless).

          Simple. And this is what one of the existing Arduino alarm clocks basically does.

          With the Sadeh algorithm this can become a bit more precise, as you can also take the sleep cycle into account. The PIR sensor actually seemed to show periods of no movement 90 minutes apart. I didn't even expect that, since there were two people sleeping in the bed.

          The Sadeh alghorithm is really simple too.

          • If there are 15 continuous minutes in which there is very little to no movement, then this is designated as the REM phase.
          • From then on you switch what you are looking for, and basically wait for a 5 minute period in which there is lots movement. That's the best time to start the wake up procedure.
          NeverDieN Offline
          NeverDieN Offline
          NeverDie
          Hero Member
          wrote on last edited by NeverDie
          #14

          @alowhum Interesting information. Do you know whether you actually feel better if you wake up according to that algorithm?

          1 Reply Last reply
          0
          • alowhumA Offline
            alowhumA Offline
            alowhum
            Plugin Developer
            wrote on last edited by
            #15

            Yes, you do. This is the algorithm used in most of the armbands/apps.

            1 Reply Last reply
            1
            • Z Offline
              Z Offline
              Zeph
              Hero Member
              wrote on last edited by
              #16

              Some thoughts.

              The last sleep study I had was simple - they sent me home with a recording device attached to two finger sensors; one was for heart rate and oxygenation, one was supposed to detect REM sleep (both had lights aimed at the skin or fingernail, did not appear to be accelerometers). I was surprised that they could detect REM sleep in that manner, but it would be worth looking into.

              I wonder if one could detect movement with a cheaper BLE wristband, like the Xiomi MiBand? Not sure if anybody has cracked the OTA protocol. (OTA meaning generic Over the Air, not FOTA = Firmware/Flash Over the Air). I used to have one (before some firmware update from Xiomi bricked it), and it had a very long battery life and was small).

              Building one's own wearable device - homebuilt and yet sturgy seems likely to be bigger and clunky; but maybe others can build tiny wearables.

              Doppler Radar - I don't think my turning over in my sleep would result in a lot of motion towards/away the sensor from if mounted on the ceiling or high on the wall.

              Antenna Effects (RCWL-0506) - might work if mounted close enough. Perhaps multiple devices. Worth considering. (These are NOT radar despite advertising, but do detect local movement).

              One thing which might also work is a camera near the ceiling, attached to some image processing (NOT to a recorder!). Upside - it might be able to guess about movements of two people. In our case, we'd need to filter out cats who come and go all night (smaller areas?).

              1 Reply Last reply
              0
              • NeverDieN Offline
                NeverDieN Offline
                NeverDie
                Hero Member
                wrote on last edited by
                #17

                Well, it sounds like Alowhum is getting good results with PIR sensors. Right now it's the summer though. I just wonder whether they will work as well in the winter if a lot of blankets get piled on?

                1 Reply Last reply
                0
                • alowhumA Offline
                  alowhumA Offline
                  alowhum
                  Plugin Developer
                  wrote on last edited by alowhum
                  #18

                  @zeph: that RCWL-0506 exactly the sensor I used, as mentioned in my posts. And yes, I know this isn't really officially radar, but they are colloquially called that amongst makers.

                  I also mentioned that, indeed, oxygen level and heart pulse are indicators the professionals use. I have those in my arsenal, as well as gyro sensors. However, in my case on of the parameters for the alarm clock is that it doesn't require the user to wear anything.

                  Why not? Well, because I am working on devices that should offer high levels of privacy protection I could not support any current commercial devices. They all use bluetooth, which sends out signals all day, making the user trackable through space. (and yes, bluetooth 5 supports mac address randomization, but it is rarely implemented. For example, the Samsung Galaxy phones do not support it, while iPhones predictably do.)

                  1 Reply Last reply
                  0
                  • NeverDieN Offline
                    NeverDieN Offline
                    NeverDie
                    Hero Member
                    wrote on last edited by NeverDie
                    #19

                    On the humorous side of things, you can apparently somehow (?) make an erection detector as a way of detecting REM sleep. There was actually a kickstarter to do exactly that. Funding was unsuccessful: https://www.kickstarter.com/projects/nptdreamer/npt-lucid-dreamer?ref=nav_search
                    but the science is sound: https://en.wikipedia.org/wiki/Nocturnal_penile_tumescence
                    Obviously, they should have made it work using bluetooth instead of using wires. Looks as though it was a simple closed circuit held together with magnets that would open during REM. Not clear whether it worked only once or whether the circuit would close again between REMs. Probably a simple strain gauge would work just as well.

                    1 Reply Last reply
                    0
                    • nagelcN Offline
                      nagelcN Offline
                      nagelc
                      wrote on last edited by
                      #20

                      : ) Masters & Johnson had some creative sensor designs, but I hadn't really considered the possibility of MySensors applications.

                      1 Reply Last reply
                      0
                      • alowhumA Offline
                        alowhumA Offline
                        alowhum
                        Plugin Developer
                        wrote on last edited by
                        #21

                        Getting closer.. I received a much better 'radar' sensor (the directional one). The only downside is that it has a bright green LED that turns on whenever it detects motion.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        18

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.1k

                        Posts


                        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular