Close
0%
0%

Improved Okay-to-Wake Clock

Adding more colors to the okay to wake clock

Similar projects worth following
We have a clock for our toddler that turns green when it's an okay time to get out of bed. The problem is that he gets up in the middle of the night wondering how much time is left. This project adds more colors to help him tell time.

After having our son wake us up multiple times in the middle of the night we decided to make the Okay to Wake clock better. My wife had the idea that if there was a color for "Sleep" and an other color one hour before waking up ("Doze") it would help our son know how much longer he had to sleep in.

My goals for this project were to use parts on hand and to not interfere with the normal functionality of this clock. The solution turned out to be quite easy; tap into the incoming USB power inside the clock and use its enclosure as a diffuser but otherwise make no alterations.

You can see there's plenty of room inside of the thing. There are two LEDs pointed upward that make the clock's normal green wake color work. I figured I'd have no problem lighting it up as different colors.

I had an extra Adafruit Huzzah ESP8266 board sitting around (any ESP8266 will work for this). It's programmed via serial cable which is kind of a pain, but since I was going to drop this inside of an enclosure it made sense to use the Over the Air updates method for uploading code wirelessly.

Check out my code on Github. I designed the software to connect to the WiFi at power-on and sync with internet time. WiFi says on for 10 minutes so you have a chance to make a software update, then turns off until the next power cycle since we don't need to waste the power when not using connectivity. So far it keeps great time all by itself.

I used jumper wire to put everything together. The black and white wires connect V+ and GND on the ESP8266 to the USB power coming in the back of the clock.

There was plenty of room for the board to be hot glued to the outside of the battery enclosure on the clock.

I have a handful of these 3-pixel cutoffs from some WS2812 strips which made this a no-brainer. Here I've just hot clued it onto the cable that connects the rear buttons to the front PCB of the clock. When assembled these LEDs will point straight up.

One short night up hacking and we're up and running. The clock comes on red at 19:00 (bedtime), turns blue at 05:30 (doze... you have one hour left to stay in your room), turns green at 06:30 (time to get up), and turns off at 07:30.


So far so good. He's been coming out of his room less, and several times has slept much later than we think he normally would have. Success!

  • Prototyping a Captive Portal

    Mike Szczys09/20/2020 at 16:14 0 comments

    After taking this clock with us to visit family in another timezone I discovered two problems in the way the code works:

    • WiFi credentials are hardcoded and clock can't be set if it can't connect to the AP
    • Timezone is hardcoded so even if clock can set itself it was off by an hour

    I'm looking into the possibiilty of adding a captive portal that will work like this:

    • If clock can't connect to AP after n seconds it will spawn it's own AP and present a settings page
    • Settings page allows:
      • manual setting of the time
      • changing of the WiFi credentials
      • option extras: manually switch the colors, update the sleep/doze/wake/off time settings

    I prototyped a test of the captive portal based on this example:

    /*
       Copyright (c) 2015, Majenko Technologies
       All rights reserved.
       Redistribution and use in source and binary forms, with or without modification,
       are permitted provided that the following conditions are met:
     * * Redistributions of source code must retain the above copyright notice, this
         list of conditions and the following disclaimer.
     * * Redistributions in binary form must reproduce the above copyright notice, this
         list of conditions and the following disclaimer in the documentation and/or
         other materials provided with the distribution.
     * * Neither the name of Majenko Technologies nor the names of its
         contributors may be used to endorse or promote products derived from
         this software without specific prior written permission.
       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
       ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
       ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
       ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    /* Create a WiFi access point and provide a web server on it. */
    
    #include <ESP8266WiFi.h>
    #include <WiFiClient.h>
    #include <ESP8266WebServer.h>
    #include <ESP_EEPROM.h>
    
    // EEPROM structure
      //MAX values are both +1 in size to make room for zero terminator
    #define SSID_MAX  33
    #define PW_MAX    64
    struct MyEEPROMStruct {
      char    ssid[SSID_MAX];
      char    password[PW_MAX];
      
      /* User timer settings: { hours, minutes } */
      byte sleep_time[2];
      byte doze_time[2];
      byte wake_time[2];
      byte day_time[2];
      /* Timezone offset in minutes from UTC */
      signed int tzoffset;
    } eepromVar1, eepromVar2;
    
    #ifndef APSSID
    #define APSSID "ESPap"
    #define APPSK  "thereisnospoon"
    #endif
    
    /* Set these to your desired credentials. */
    const char *ssid = APSSID;
    const char *password = APPSK;
    
    ESP8266WebServer server(80);
    
    String getPage() {
      String page = "<!DOCTYPE html>";
      page += "<html>"
      "<head>"
      "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
      "</head>"
      "<body style=\"width:480px; margin: 0 auto;\">"
      ""
      "<h1>Improved Okay-to-Wake Clock</h1>"
      "<h2>Update now:</h2>"
      "<form action=\"/settime\" method=\"POST\">"
      "  <label for=\"time\">Set current time:</label>"
      "  <input type=\"time\" id=\"time\" name=\"time\">"
      "  <input type=\"submit\"><br />"
      "</form><br /><br />"
      ""
      "<h2>Settings:</h2>"
      "<form action=\"/\">"
      "  <label for=\"ssid\">SSID: </label>"
      "  <input type=\"text\" id=\"fname\" name=\"ssid\" value=\"";
      page += eepromVar1.ssid;
      page += "\"><br /><br />"
      "  <label for=\"pass\">Password: </label>"
      "  <input type=\"password\" id=\"pass\" name=\"pass\" value=\"";
      page += eepromVar1.password;
      page += "\"><br /><br />"
      "  <input type=\"submit\">"
      "</form><br /><br />"
      "<h2>Toggle Onboard LED</h2>"
      "<form action=\"/LED\" method=\"POST\"><input...
    Read more »

  • Tracking down shoddy power

    Mike Szczys09/20/2020 at 01:35 0 comments

    Ever since first doing this hack I've had a real problem with keeping the thing powered. USB power seems to die if you look at the thing wrong.

    At first I thought I was browning-out the incoming power but adding a capacitor didn't fix it. I resoldered the power connections, and even clipped off the pin connectors to make direct solder joints. No dice. If you shake it around the power blinks on and off.

    I think I finally tracked it down to a shoddy power cable that came with the clock. It's USB on one side and barrel jack on the other. I don't have the same size barrel connector on hand so I just unscrewed the port inside the clock and soldered a new USB cable in its place. So far so good.

View all 2 project logs

Enjoy this project?

Share

Discussions

Dan Maloney wrote 05/18/2020 at 20:48 point

I feel your pain. I used to have to sneak out of the house at 4:30 AM to avoid my early-rising toddler daughter, lest I get waylaid by her and trapped playing for the next few hours. I'd get to work while the gates were still closed and the night shift guards were still on duty, go up to my office and play Quake for an hour until the gym opened and I could work out.  

This would have done absolutely nothing to stop her, mind you, but I applaud the effort and wish you the full-night's sleep that's been eluding me for 23 years now.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates