Internet Alarm Clock Front Panel

After completing my clinical engineering internship hours while simultaneously working on my research, followed by a three-month research sprint and thesis draft, it’s time for a catch-up post.

An early sketch of the front panel design (Jan 7, 2017).

I started the ball rolling on the Internet Alarm Clock in early 2017 by designing a front panel PCB that implements the alarm clock’s physical user interface (UI).

The front panel is intended to connect to another PCB (to be designed) via a single 6 pin, 0.1″ pitch IDC connector for the I2C (data) bus, power, and button interrupt signal.

Here’s a rundown of the UI elements:

  • Classic red seven-segment display for displaying the time.
  • Character LCD screen for displaying additional information. Transflective with RGB backlight.
  • Four directional buttons (up, down, left, right) for setting the time.
  • Three buttons at the top, each colour-coded for association with a specific functionality:
    • Red, associated with the clock (to match the red seven segment display)
    • Green, associated with the weather reporting functionality (to match the colour of… grass I guess!)
    • Blue, associated with the next arriving bus (inspired by the blue lights on TTC buses)
Alarm clock front panel PCB schematics (Jan 24, 2017)

The front panel electronic design is fairly straightforward. An as1115 does the heavy lifting by doing three things:

  1. Driving the four-digit, seven-segment clock display
  2. Controlling the Newhaven character LCD (NHD-C0220BIZ-FS(RGB)-FBW-3VM
    ) backlight via three switching BJTs (to accommodate the different rated voltages of each of the red, green, and blue backlight LEDs).
  3. Reading the button input from the seven buttons.
Finalized front panel layout (Jan 24, 2017)

For the final layout I decided to move the up/down/left/right buttons alongside the seven-segment display, hoping to make setting the alarm (or, in the absence of Wi-Fi, setting the time) more intuitive.

Unpopulated front panel PCBs (Feb 9, 2017)

I decided to use an Adafruit ESP8266 Wi-Fi module breakout board (2471) as the Wi-Fi module, due to its wide use among hobbyists for their projects, which I can refer to for help. Adafruit’s version comes with the NodeMCU firmware, which implements a Lua-based scripting engine. As I wrote routines in Lua to exercise the displays and read the buttons on the front panel PCB via the I2C bus, I gradually built up a prototype firmware throughout 2017.

Front panel PCB under control of the Adafruit Huzzah ESP8266 breakout board (assembled Mar 2017, photo taken Apr 2018)

I was able to implement the following features using Lua scripting and appropriate selection of modules for a custom NodeMCU build (built using

  • Automatic syncronization of time over Wi-Fi using NodeMCU’s Network Time Protocol (NTP) module
  • Wi-Fi connection and alarm status icons
  • Automatic dimming of seven segment display at night
  • Setting the alarm time
  • Setting date and time if no Wi-Fi found (could not fully implement due to memory constraints)
  • Visual portion of the alarm, signified by colour-cycling the LCD backlight

The last feature is pretty cool:

Rise and shine!

But, after a certain point, my scripts ran out of memory. Despite there being 4 MB of flash (less 0.5 MB for the firmware) on the underlying module in which to store the scripts, it seems that the Lua interpreter has to load these text files to RAM to execute, and then the variables (of which many are strings) take additional memory, on top of the interpreter’s RAM footprint. Though I’m not entirely sure how NodeMCU partitions and manages the ESP8266 memory space, it appears that RAM is limited to the order of tens of kilobytes. So I may have to use an external microcontroller and program the user interface in C, where it can execute directly from the micro’s flash memory, and reserve the Lua scripting for the high-level network interfacing (e.g. parsing XML or JSON to get the weather and next bus).

Bill of materials, KiCad design files, and Lua scripts are available in this post’s commit.

New Project: Internet Alarm Clock

The goal for this project is to replace my old alarm clock (pictured above) with something that shows the key information I need to know in the morning. That information is:

  • The time
  • The weather
  • When the next bus is coming

Sure, my phone can do all those things. But it takes time to touch and thumb through the various interfaces, beginning with entering a pattern to unlock the screen. And of course apps exist to put the weather and next bus on my phone’s unlock screen, but this information is still not available at a glance because it requires a button press. Having all the key information – time, weather, next bus – always visible on a dedicated display is convenient because it takes next to no effort to access the information; all I have to do is turn my head.

What I want this alarm clock to have:

  • Ability to get the time from the internet
  • A classic red seven segment clock display visible from across the room. (Red so that it doesn’t interfere with my sleep.)
  • A small transflective character LCD screen to provide additional or clarifying information
  • Alarm functionality so it can wake me up in the morning
  • Ability to function as a classic alarm clock in the absence of a wireless internet connection

Here’s what I don’t want this alarm clock to have:

  • An FM radio, internet audio streaming, or any advanced audio capability beyond having an audible alarm. I don’t use the radio functionality of my existing alarm clock anyways so I might as well reduce the complexity of the design by not including this.
  • A graphic display or touchscreen functionality. Just old fashioned tactile buttons please!
  • The classic digital alarm clock interface that required holding down a “time set” or “alarm set” button while tapping a separate minute or hour advancing button.

In addition to solving a practical need, I am using this project to gain experience in the following technical areas:

  • PCB design – for the internal electronics
  • I2C bus – for the displays and buttons
  • State machines – for writing deterministic and easy-to-modify code
  • Wi-Fi modules – for time synchronization, as well as downloading weather and bus times
  • 3D printing – for the case/enclosure
  • Design for usability – I don’t want to frustrate my future self by creating a difficult to use device

This is a project I’ve actually been working on the past few months, so the next few posts will be to catch up with what I’ve done so far.