'OK to Wake' Clock for Your Toddler

by thijsv in Living > Kids

8027 Views, 34 Favorites, 0 Comments

'OK to Wake' Clock for Your Toddler

coverPicture.jpg
DSC07330.JPG
prototype on breadboard.jpg
fully mounted.jpg
DSC07489.JPG

3.45 AM, my son is happy and awake. It's time to start his morning routine. He's shouting for some bread with Nutella and wants to go downstairs to play.

3.46 AM I get a punch from my wife, that I have to go out of bed and convince him that it's still the middle of the night. Tough job which results in getting up, going to his room, taking him downstairs to show that it is still dark and that nobody is awake. Starting his bed routine again, ...

3.54 AM I got lucky this night, I'm back in bed within 15 minutes. Next time it's your turn honey.

That's about the story every night since our son moved to his big boys bed. He loved to help assemble the IKEA kit, he doesn't like sleeping in it (too much).

Surfing around the web I found some solutions that promise to help train your kid to stay in bed until it is time to wake, like for example this Wake Childrens Alarm Clock. Since both my son and I love to make stuff, I decided to make one ourselves, which resembles his own bed and has some nice features to it:

  1. a stuffed animal that gets up when he's allowed to get up
  2. a night light that changes colours when it's time to wake up.

Techniques used in this Instructable are: lasercutting parts, spray painting, messing around with Arduino and soldering. Don't be alarmed by the long instructable, the reward in the end will be great: a good nights sleep!

The sleep deprivation didn't help with this project, losing a lot of time when waiting for parts, figuring out how to get the moving parts to work properly, ... If you don't like overly complicated projects or are too tired to do some proper soldering, this Instructable takes another approach to it by changing the face of an existing clock.

The Material List

DSC07327.JPG
DSC07362.JPG
DSC07393.JPG
parts.jpg

You will need quite some materials for this project, due to it's complex nature. It took me quite some iterations, runs to the shop and lost time waiting for parts to arrive to get all the items needed.

To keep it understandable, I split up the materials into two parts, the first part contains all the materials needed to make the bed that resembles my sons bed with enough detail, the second part contains the list of materials needed for the circuit.

For the bed

The goal is to mimic the bed of my kid into detail. When he goes to bed, so does his little friend. When his little friend rises, so can he. Warning: buy a second little friend, because he will probably want to keep his close to him.

Materials

  • 3mm MDF board
  • white primer paint (reduces the amount of glossy pain you need)
  • white glossy finish paint
  • some foam, I used two small sponges for this
  • some extra pieces of fabric for the mattress and the sheets
  • some mecano's and extra cardboard to prototype the lifting mechanism.
  • some pieces of tracing paper (to diffuse the LED light)
  • some stiff 4 mm tubes for the hinges.
  • some toothpicks and nails that fit inside the 4 mm tubes.

Tools

  • cutting knife
  • glue gun
  • woodglue
  • painters tape
  • sanding paper
  • a small ruler
  • needle and thread

The circuit:

One of the disadvantages of an Arduino is the lack of proper internal clock. When the power is unplugged or the Arduino restarted, it will have no clue of what time it is. The internal clock will be reset and start counting from zero again. To solve this, an additional Real Time Clock (RTC) is added which has its own coin cell battery (which will need to be replaced in time).

Parts

  • Arduino Uno
  • Some perfboard or a breadboard
  • 10 LEDs: 3 x red, 2 x yellow, 5 x green
  • Tiny RTC: I bought mine from eBay for € 0.86. When looking for parts, use the sort option 'price + shipping, lowest first'.
  • A 3V coin cell battery for the RTC
  • servo motor (for example the one in the Arduino Starter kit)
  • 10 x 150 Ohm resistors + 2 x 10k Ohm resistors
  • 2 x pushbuttons
  • potentiometer
  • a lot of jumper wires and some flexible bus wire.
  • and old charger which can provide something between 7 and 12 V and a power jack

Tools

  • Soldering iron and solder
  • glue gun
  • photo holders with small alligator clips (which are a useful replacement for a soldering station if you don't have one).

Design Process

DSC07412.JPG
DSC07420.JPG
DSC07421.JPG
drawing.jpg

My son sleeps in an IKEA bed called Brimnes. The shape itself is not that complicated and it has this two distinct drawer faces at the front and on the sides there are two distinct square shapes as well. So the goal is to include a night light in the bed that lights up these four squares. It maybe even change colours when it is time to wake up.

His old night light, a rechargeable LED glower is omitting blue light, which I want to change to a more red light. Because, recent research [1,2,3] showed that due to blue light we are experiencing major problems with our sleep. There is a shift in circadian rhythm and melatonin production is suppressed.

Also, the main goal is to get one of his stuffed animals to get up when it's time to wake up. So the bed frame needs to be able to tilt upwards. If we keep the matrass thin enough, this will be possible.

After measuring up the bed I figured out that I wanted to include a circuit in the frame that turns the bed into one of two possible states:

  1. The SLEEP state: the bed is oriented horizontal and the light is somewhat red/yellow and thus be used as a nightlight.
  2. The AWAKE state: the bed is upricht and the light is green.

The sleep state should be always on between bedtime (in our case 7.30 PM) and the time to get up (in our case 6.30 AM during weekdays, 7.00 AM during weekends). I figured it was easier have it hardcoded into the Arduino then to add a clock face and buttons to change it to the project. As a result, the USB port of the Arduino should stay accessible to change the times if needed.

However, I also wanted to implement an overwrite statement to allow for his short nap in the afternoon. Since this is not at a fixed time, but only has a preferred duration I wanted something to set this duration (a potentiometer) and a start button. Lastly, to save some energy and LED lifetime I also added a button to turn on and of the LED.

Based on the desired options the bed frame should have some extra holes in it:

  • three small holes for the two buttons and the turn button.
  • some mounting holes for the Arduino
  • a larger hole to access the usb and power outlet of the Arduino

This all resulted in a 8 to 1 scaled design included in the pdf below. I chose this scale since it fitted the size of his stuffed animal the best. I also added some extra small parts (squares, bars, ...) in the pdf to use as reinforcements for the frame when glueing it all together. When your design is ready, it's time to run to the lasercutter!

Assemble and Paint the Bed Frame

DSC07330.JPG
DSC07333.JPG
DSC07334.JPG
DSC07343.JPG
DSC07339.JPG
DSC07345.JPG
DSC07353.JPG
DSC07356.JPG
DSC07358.JPG

I was lucky that my university offers free lasercutting time for all its students and staff so I went there and cut out the needed parts. If you don't have a laser cutter at hand, you can always print out your design at 1:1 scale, glue it to the 3mm mdf boards and cut it out with an exacto-knife. It will take some time and blades, but you will get there.

A quick pass with some sanding paper roughened up the edges for the glue to bond well and removed most burn marks from the laser. I used a fine brush and patience to glue up everything nicely and make sure that everything was square and aligned. Masking tape was applied to clamp everything together while drying.

Next step was to mimic the white, glossy finish of the bed. I set up a temporary painting booth on my lawn (just a big cardboad box) and with 4 coats of white glossy paint It looked more or less like my sons own bed. To get the best result, I suggest short sprays that start next to the piece and then move quickly over it (as shown in the video below). I waited till the paint was a bit tacky before applying the next coat.

Last step in the bed-frame build was to add some tracing paper to the empty squares with wood glue. These squares will mimic the bed drawers and side and transmit the LED light from the inside.

Test You Sewing Skills

DSC07368.JPG
DSC07362.JPG
DSC07363.JPG
DSC07364.JPG
DSC07369.JPG
DSC07373.JPG
DSC07378.JPG
DSC07380.JPG
DSC07382.JPG
DSC07385.JPG

Next step is making the sheets for the bed. I found out that the width of the bed matches the width of some sponges we use to do the dishes. Next to that you only need some old sheets, a needle, a thread and a knife for this step.

  1. Cut of the rough parts from the sponges and cut them in half, reducing the thickness.
  2. Lay them out on the bed and cut to size
  3. Trace the outline of the sponges on a piece of fabric, do this very close to the edges.
  4. Fold the fabric in half and start sewing, leaving only a small opening which is about the size of the shortest edge of a sponge.
  5. Turn the fabric inside out, and stuff it with the pieces of sponge.
  6. Sew the last part and put in on the bed.
  7. Your bed is ready and the stuffed animal can go to sleep.

I really love how the project is looking at this step, it is coming together. Our son loves to put the stuffed animal to bed, telling him stories. I'm wondering how he will react once the lights and motor go in.

Mounting the Servo and Moving Mechanism

DSC07393.JPG
DSC07394.JPG
DSC07404.JPG
DSC07407.JPG
fully mounted.jpg

The mechanism: The goal of this step is to transform the limited torque of the servo element in enough power to lift the bed upright. Some cardboard and Meccano prototyping later and a lot of messing around with hot glue, wooden rods and nails I came up with this solution:

The arm of the servo rotates and pushes another rod upwards that in its turn pushes the bedrame upwards. By shifting the servo element to the left and playing with the lengths of the rods I managed to use as much of the 180 degree turn of the servo element possible, making the needed lift for each degree of turn as little as possible.

Mounting the servo motor: Time to mount this mechanism in the bed, there isn't much space and I tried to limit the weight added to the bedframe, making it easier for the servo to lift it all:

  1. Mount a tube of 100mm to the bottom of the bed frame at the pivoting point with some hot glue
  2. Mark the position of this tube on the side of the bed frame and punch through 2 nails in the side to hold the tube in place. The bed frame can now turn up and down.
  3. Glue a short second piece of tubing to the bottom of the bed frame at about 30 mm from the pivoting point.
  4. Push a toothpick through this tube and attach 2 50mm long arms to the toothpick with a dash of hot glue.
  5. Attach two short pieces of tubing with a dash of hot glue to the other side of the 50 mm arms
  6. Push a needle through the servo arm and slide over the two small tubes.

Now comes the difficult part, positioning the servo element:

  1. Put the servo in the 'SLEEP' state.
  2. Fold the mechanism so that the bed is perfectly horizontal.
  3. Put some wedges under the servo element until it is also horizontal. Mark the position of the servo element.
  4. Attach everything with hot glue, this requires some precise work and patience.

Getting the start and stop position: Finally, to make it durable, find the exact start and stop position for the servo element. To do this, make the Arduino tutorial called Knob (also depicted below with 123circuits), and attach it to the servo motor. Run the code with your serial monitor on. Find the exact position for the start and stop conditions of the mechanism and read the values from the serial monitor. In my case, with the dimensions above, this gave 72 degrees for the upright position and 154 degrees for the sleep position.
During this test you can check if everything runs smoothly, if needed you can sand down the edges of the bed support to give it some play.

Remarks: In the end I managed to get the system in. Now that I have an idea of the dimensions and positioning of the system, I think I will design the parts for it next time at the same time as the other parts of the bed, allowing it to be cut on the lasercutter and to be more precise and sturdy.

Designing the Arduino Circuit

projectJoris_overview.png
parts.jpg
helping soldering hands.jpg
prototype on breadboard.jpg

General concept: To allow for the demands I used three actuators (a potentiometer and two push buttons), a tiny RTC to keep track of time, a servo-motor and a bunch of LED. I used an Arduino Uno to take care of the different types of signals from the RTC, potentiometer and push buttons and to actuate the LED and servo motors. If you are new to Arduino programming and circuiting, I suggest the following tutorials before diving into the code and schematics below:

The schematics for this Instructable where made with a Open Source package called Fritzing, a handy tool to figure out the components you need for your project and giving you the opportunity to mess around with it without getting tangled in a lot of jumper wires when prototyping.

Solder some jumper wires to the tinyRTC I never soldered before, so this project was a first. I had some basic tools laying around, checked some Youtube videos and gave it a try. I found it useful to have some helping crocodile clips to hold the pieces while working. Not ideal, but photo holders worked ok. I think my next project will be a third hand for soldering.

Prototype your circuit on a breadboard After designing the circuit in Fritzing it was time to prototype and test it before mounting it in the bed frame. I took a large breadboard and start assembling the circuit. This also helped me to determine the exact amount of wires needed in the next phase and gave an idea how to lay it out so that it would fit inside the bed.
At this point I also decided to solder the negative leads of the LEDs already together and the resistors to the positive leads, to reduce the amount of wiring needed in the bed. I think I'm getting into soldering.

Setting Up the Real Time Clock (RTC)

adding tinyRTC.jpg

With the circuit build it is time to write some code to handle the signals and actuate the lights and servo motor. However, before we start, we have to set the RTC module to the correct time. The workflow is outlined below. For this workflow you will need a RTC library in Arduino. I included the library I used, which already holds the right pin information and is compatible with tinyRTC.

  1. Connect the RTC to the Arduino board, like it would be connected in the finished circuit. All other parts are not needed at this time. Add the battery to the RTC
  2. Add the following sketch to your Arduino program:
    #include <Wire.h>	// used for communication
    #include "RTClib.h"	// library for the RTC module
    RTC_DS1307 RTC;
    void setup () {
        Serial.begin(57600); // make sure to set the terminal also to this baud rate
        Wire.begin();
        RTC.begin();
        RTC.adjust(DateTime(__DATE__, __TIME__));
    }
    void loop () {
        DateTime now = RTC.now();
        Serial.print(now.year(), DEC);
        Serial.print('/');
        Serial.print(now.month(), DEC);
        Serial.print('/');
        Serial.print(now.day(), DEC);
        Serial.print(' ');
        Serial.print(now.hour(), DEC);
        Serial.print(':');
        Serial.print(now.minute(), DEC);
        Serial.print(':');
        Serial.print(now.second(), DEC);
        Serial.println();
        delay(3000);
    }
    
  3. Link your Arduino with USB to your computer.
  4. Check if your computer clock is in sync and press Upload. Don't pre-compile and then upload, this will result in a time delay of your RTC clock by the time difference between compiling and uploading.
  5. Check the serial terminal to see if the RTC returns the correct time. Unlink the Arduino from the computer and thus its power source, wait a while, relink and check if you still get the correct time. If yes, congratulations!

Coding the SLEEP and AWAKE States

IMAG0668.jpg
DSC07474.JPG

If you are suffering from sleep deprivation because of the bad nights, bear with me, we are almost there and sleep is coming your way! This is almost the last hurdle to take. The most important tool for this step is coffee.

If you want to thinker with the logic or want to add different buttons and you are not that fimiliar with Arduino yet that you are confidend to order parts, I suggest you play a bit with the design on 123d circuits by Autodesk. I included a draft of this project below to start from. Note that this draft doesn't include the RTC for timekeeping since the 123d environment doesn't support it. A nice feature is the emulation it provides, so you can play a bit with the buttons.

Back to programming. The general concept is a loop() statement that listens to the RTC and the push buttons every second. If the RTC returns a timestamp which corresponds to bedtime or morning time, we change the state. If the pushbutton for a nap is pushed, we also change the state and get the corresponding length of the nap from the potentiometer.

Link all sensors and libraries and set parameters:This sketch requires quite a lot of parameters to keep track of time and the states of the lights, buttons, ... A hint is to keep track of the pin numbers and double checking them when something isn't working properly.

// libraries
#include <Servo.h>
#include <Wire.h>
#include "RTClib.h"

// pin numbers
const int potentioPin = 0;    // analog A0 pin
const int napPin = 3;         // digital pin
const int lightPin = 4;       // digital pin
const int servoPin = 8;       // digital pin
const int dayLight = 9;       // digital pin
const int nightLight = 10;    // digital pin

//sleep and timer settings
//sleep and timer settings
RTC_DS1307 RTC;          // RTC date
DateTime time;           // time object of the RT
const int wake_h=7; const int wake_m=0;    // time to get up
const int sleep_h=19; const int sleep_m=30; // time to go to bed

// variables for the nap
int napState = 0;       // the state of the button
int napBusy = 0;        // int to indicate if the system is in nap state
int napSec = 1800;      // length of the nap in seconds
DateTime endNap;        // time object holding the calculated endtime of the nap

// variables for the light conditions
int lightState = 0;     // the state of the LED button
int lightsOn = 1;       // int to indicate if the lights are on or off.

// variables for the servo element, determine these while constructing the mechanism
Servo myservo;
int awakePos = 72; 
int sleepPos = 154;

Initialise the buttons and communication signals: Digital pins on the Arduino need to be told if they are input or output to function properly.

void setup() {
  Serial.begin(57600); //adjusted boud rate for the RTC
  Wire.begin();				
  RTC.begin();
  pinMode(napPin, INPUT);           // initialize the input pins
  pinMode(lightPin, INPUT);         // initialize the input pins
  pinMode(dayLight, OUTPUT);        // initialize the output pins 
  pinMode(nightLight, OUTPUT);      // initialize the output pins 
  myservo.attach(servoPin);         // initialize the output pins 
}

Start the continuous loop:This part seems easy due to the use of help functions. The first reads and sets the light state, the second checks if the nap button is pressed and the third one gives the right signals to the LEDs and servo based on the two previous button states and the time.

void loop() {
  time=RTC.now();                         //get current time from the RTC
  lightsOn=listenToLedPin();              //listen to the LED button
  napBusy=listenToNapPin(time,napBusy);   //listen to the nap button
  setState(time,napBusy,lightsOn);        //change the lights and servo 
  delay(1000);                            //wait a second, to avoid bouncing.
}

The helping functions: For the definition of the helping functions, please see the full code attached or the sketch in 123studio. These helping functions consist of a lot of if-tests and some basic signal setting and are fully documented. I also included the version of RTClib that I used for the time control and communication with the tiny RTC.

Fitting the Electronics in the Bed Frame

fittingInWires.jpg
solderingButtons.jpg

Removing the breadboard: Some bad news: we can't mount a breadboard in the project, since the bed frame has a limited size and the position of the buttons, the power inlet and usb port need to be accessible Good luck I got into soldering by now.

  1. Solder the LED circuits with the resistors in series with the leds and the leds in parallel to each other.
  2. Connect the two grounds of the LED circuits to eachother to a single ground pin, which connects to the ground pin on the righthand side of the arduino.
  3. Solder all 5V supplies to the buttons and potentiometer to eachother and to the 5V line
  4. Solder the 10k resistors to the ground side of the switches and link them to the ground of the potentiometer.
  5. Solder the data lines to the buttons.

Since the buttons, servo-motor and RTC need a 5V connection and a ground connection and we only have 1 supply available and two return pins available, I cut off a small part of my breadboard to link them, reducing the amount of soldering required.

Glueing the buttons in place: I carefully unlinked the servo and the moving parts to get better access to the side where the buttons reside and with a dot of hot glue I glued them into place. The hot glue also helps to insulate the electric wires.

Mounting the LEDs: I positioned the two sets of LEDs in the middle of the frame on a distance from the bottom to make sure that the light was blocked as little as possible by the other parts in the bed frame.

Mounting the Arduino and RTC: The holes for the Arduino bolts line up perfectly (thank you open source Arduino design). The RTC is placed above the Arduino with a small piece of cardboard in between to be sure that no components touch each other. I also changed some pins on the Arduino to be able to link the wires more easily. Just remember to change them in the code as well.

From this step I learned that it would have been easier to place the buttons closer to the Arduino (and thus a little less beautiful) which would require shorter wires. Also I noticed that this step would have been a lot easier if I hadn't glued in the pieces of tracing paper yet. I punctured one and had to remove one to be able to glue in the buttons more easily.

Time to Go to Bed and Reflections

DSC07486.JPG
DSC07489.JPG
DSC07492.JPG

Probably the most difficult part of the entire project. Getting your toddler to understand the concept of the clock and the lights.

We closed the curtains, dimmed the lights and showed how it works. Below you can see his reaction. Now let us hope he doesn't wake us in the middle of the night again.

Some reflections on the project:

  • If I would make it again, I would move the buttons closer to the Arduino and use another kind of LED (maybe led strips) to get a more diffused look.
  • To make the inside tidier and maybe even add some functionality, I would love to win the epilog VII contest to have a lasercutter/engraver to speed up the design proces, allow iterations and most of all to be able to engrave custom PCB's. So, if you like this project, please vote.
  • The RTC I used is a DS1307. Not a super exact one, but good enough. After two weeks it is off by about 1 minute compared to my computer clock. If you are very exact with time (which I wouldn't recommend combining with toddler behaviour), I suggest you read into RTCs, because better ones exist.
  • It helped a lot to build it together with our toddler. He really enjoys it. He even enjoys it that much that we had to move it out of reach because he was playing with it and not sleeping. Maybe I would add a rechargeable li-ion battery in it in the future, which makes the positioning less depended of a power socket.
  • With the bed in place I was even wondering if I could include the functionality of the baby monitor as well, allowing for only one device in the room. However, for this I would definitely need some way to make a PCB and some extra time to read all about the technicalities. There is still some room left in the bed frame, so I'm open for other suggestions in the comments below.

An update after the first night with the OK to wake light:

  • It workerd, hurray! The only thing that I didn't foresee was that our toddler was expecting that the stuffed animal would also leave the bed. Version n° 2 will have to include some sort of catapult or any other launching mechanism.