Using WyzeCam & IFTTT to Monitor Sleep Patterns

Anthony Tippy @Tibbbbz
5 min readMar 25, 2020
me every day

Background

I suffer from persistent adult night terrors as well as moderate sleep apnea. I’ve consistently struggled with constantly feeling fairly fatigued throughout the day as a result of this. I’ve worked with two different doctors, had four sleep studies, and have done a substantial amount of personal research in search of a solution. Unfortunately, all of this effort has not amounted to more than being put on a C-PAP with little results from the doctors regarding night terrors.

C-PAP Visual from Wikipedia

I am currently using a C-PAP system nightly as well as taking melatonin, however, it doesn’t seem to address my night terrors. If anything, usually my night terrors disrupt my C-PAP usage, as I will often rip off my mask. This project details my attempts to better understand what is happening when I sleep and hopefully find a solution. It should be noted that this research is still ongoing.

WyzeCam

WyzeCam from Wyze.com

Recently, I’ve outfitted my house with cheap security cameras /sensors from Wyze. These little cameras are very cheap, jam-packed with features, and do not require a recurring monthly subscription.

Wyzecam accepts local storage, records footage based on motion/sound, and even has impressive night vision capabilities. I’ve really enjoyed using them to protect my house but I wonder if I can do more with them.

WyzeCam Sleep Sensor?

Pic from “Smart Home Solver”

As aforementioned, WyzeCam offers impressive night vision capabilities; especially indoors. With this in mind, I set up an extra camera in the bedroom and pointed it at the bed so I could monitor motion during the night. Every time the camera detects motion it will start recording so I can get an accurate view of exactly what I’m doing during sleep. Note: for the duration of this study, I am the only one sleeping in the bed being monitored. Additionally, in an effort to reduce false positives and increase study accuracy, I’ve set the WyzeCam to only record events/motion from 10:30 pm — 6:30 am (the average time that I am in bed/waking up). After testing this for a couple of days, I was impressed with the results. I captured multiple night terrors, which while humorous at first, were rather concerning. I would get up out of bed, remove my C-PAP mask, and start walking around the room as if I was fully awake. I have no recollection of these events at all. Additionally, I discovered I am moving around A LOT at night. So maybe that's why I’m so tired…

Drilling Down Further — IFTTT & Google Sheets

Ok, so now that we have a reliable sensor to detect motion each night, how can we export this data to a more tangible format. Currently, I can just see entries within the Wyze app, which makes long term analysis rather limited. Additionally, Wyze has not made their API public or given an option for data exfiltration. Luckily IFTTT exists to solve problems like this. IFTTT, or “If This Then That”, is a service that allows automation of applications and sensors. “[IFTTT is the] easiest way to do more with your favorite apps and devices for free. Make your home more relaxing. Make your work more productive.

Google Sheets IFTTT Wyze Output

With IFTTT, we can use a user-generated applet to automagically populate a Google Sheets document for every motion detection event.

Now we can get a better understanding of exactly how many events per night are occurring and at what time in an easy to read /analyze format.

But it can still be better…

Google Data Studio — Gods Gift to Nerds

Data Studio (GDS) is Google’s reporting solution for power users who want to go beyond the data and dashboards of Google Analytics”

I’ve used GDS in the past for other research projects such as creating reports for Insecure Audio Visual Devices. GDS is a great tool for quickly generating reports/graphs from data sets such as google sheets and other data sources so it was perfect for this application. All we have to do is link the Google Sheet that IFTTT is writing to, and with some quick chart creation, we have an automatically updating live Sleep Study Dashboard.

Final Results of the study (03/19/20–04/07/20)

I am blown away at how many times I’ve been waking up in the middle of the night, even over such a small period of time. I’ll be continuing this study to learn more about exactly what is happening at night.

Presently, I’ve been working on expanding the detailed reporting aspect of this study. My goal is to achieve automatic reporting of exact hours slept per night as well as creating pre/post-sleep google forms to collect stress and fatigue level information each day. Each google form automatically exports results to a Google Sheets document that can be fed into GDS for further detail. The only question is whether I’ll be able to continue completing the daily forms long term.

To Be Continued…

I’m still working out the kinks of this project, but I’ve been able to create a rather detailed dashboard in mere hours that I can use to monitor various tests. Going forward I intend to try different methods to treat my night terrors such as melatonin, limiting caffeine, limiting screen time, and any others that I can think of.

Future Points of Study

  • Effects of screentime before bed /limitations
  • Effects of caffeine before bed /limitations
  • Effects of Melatonin or other natural sleep aids

You can find the latest live dashboard for the study here: https://datastudio.google.com/s/oskOwc_q2Tc

Update: Sleep Study Concluded

We’ve finally got around to purchasing a new bed (a helix mattress) which has been extremely beneficial for my sleep, so I haven’t been able to capture sleep data since we installed the new bed. For now, this will conclude the sleep study. I wanted to do a longer study but I’m just happy to be sleeping on a real bed instead of a futon again. I might revisit this idea in the future if I my sleep issues get really bad again.

Thanks for reading!

--

--

Anthony Tippy @Tibbbbz

Audio Visual Tech guy gone InfoSec. Tinkerer, breaker of things, fan of sloths. Opinions expressed are solely my own