Big poopies, little data; tracking diaper changes with IoT Button

Our pediatrician regularly asks how many times Miles has gone potty in the last 24hrs. It turns out when you’re sleep deprived and up at random times throughout the night its all a bit of a blur.

The Feed/Change/Sleep loop can be super taxing and it becomes hard to recall who did what when…. We decided to set up some tracking so we’d have concrete answers to all the potty related questions.


Tracking the movements

We could have used a trusty pen and paper to record the diaper changes, but what fun would that be?! Instead we grabbed an AWS IoT Button and set it up above Miles’ changing table.

The button has three click typesSINGLE, DOUBLE, and LONG. We mapped them to the following diaper change scenarios:

We’ll use the terms “Number One” and “Number Two” to describe the desired outcomes of the diaper change. Until you become a parent it’s hard to fathom what can go wrong during a diaper change… internally we refer to these as S.O.S. scenarios; here we’ve labeled them as “Unexpected Outcome” (will spare you the gory details).


Data collection

The goal was to have a low cost, low maintenance way of collecting and storing all the diaper change events. The IoT Getting Started walks through the steps of setting up the button and creating rules for storage of data.

We landed on the following data pipeline:

The IoT Button emits the following JSON click data:

{
"serialNumber":"G030MD044084T3P1",
"batteryVoltage":"1610mV",
"clickType":"SINGLE",
}

There were few additional attributes needed to make the data easier to work with (a uniq identifier and UTC timestamp). Luckily the IoT Rule Engine exposes a number of SQL functions that allow us to append additional meta-data before storing to S3.

{
"traceid":"43f875e6-97f5-f91a-6deb-1c6123f250d6",
"serialNumber":"G030MD044084T3P1",
"batteryVoltage":"1610mV",
"clickType":"SINGLE",
"timestamp":"2017-11-02 01:58:58"
}

Data visulalization

With the flat JSON files sitting in S3 we can leverage Amazon Athena to run queries on the data.

First we needed to create a new table in Athena:

Then we can query the dataset using PrestoDB SQL Syntax:

Today has been a good day (so far…)

It’s still early days in the data collection process, but it’s been a fun little project to hack on between nursing, naps, and diaper changes.

Will be interesting to see if any trends emerge over the following weeks.