Sitemap

Building the UQBAR Clock

--

Press enter or click to view image in full size
The UQBAR clock, opened up so you can see the innards

Last year, the owners of UQBAR Café in West Berkeley invited me to build a metric clock for their restaurant. I’ve been preoccupied with metric and solar time and clock building for quite a while now. I’ve even written an iPhone app that keeps civil and solar time in both metric and conventional formats. If you want to speed-run all that without reading a bunch of blog posts, you can watch a five-minute lightning talk I did for the Long Now Foundation (my section starts at about 6:30 into the stream).

I was excited at the chance to build a larger-format device than my normal desktop-sized projects, and to create a piece that would be on display in public. I agreed.

For all my previous clock builds, I’d been able to purchase the components I needed, including the display components, at reasonable prices from online distributors. The restaurant clock, though, would need to be readable from way across the room. I’d need each digit to be eight or so inches tall. There aren’t many components like that available, and all the ones I could find were really expensive. This time, I was going to have to design and fabricate some key clock components, in addition to writing the software to control them.

And because the clock would be hung on a wall in a nice restaurant, it needed to be attractive. I’m a software guy. I enjoy building physical objects, but I’m not great at it, and I’m certainly not a designer.

So I wasn’t sure exactly how I was going to build the clock. I planned to figure it out as I went.

I started thinking about the design and trying out different ideas in the summertime. Life got kind of hectic for a while, and I didn’t feel a lot of schedule pressure from the owners, so I didn’t really have much figured out and working as summer faded into autumn. Then they made a bunch of progress with the licensing and permitting agencies in the city and state, and had a firm opening date. I was all of a sudden, so to speak, on the clock!

I pushed through, working pretty long and hard to get a reliable design in a box that didn’t look awful. In the end I was a week or so late for their opening, but hung the clock in November. It’s run reliably for them for the ensuing five months.

A bunch of things about that initial build bugged me, though. I didn’t do anything about it for a bit, but by February of this year, I’d thought of a bunch of stuff I would do differently if I were to start over.

My maker projects are generally like that. I don’t really know how I’m going to finish a project when I start it. Much of the joy of building is in encountering a problem, thinking up a solution, trying it out, discovering what’s wrong with it, tweaking and refining and getting things working. I learn a lot from actually making things. I get a deep pleasure from understanding deeply how a thing works, and going from idea to physical object is an excellent way to develop that understanding!

I call the original clock I built “Build 0.” I talked to the café’s owners and proposed Build 1, fixing some design flaws in Build 0 and adding different features that they, and I, thought of once we could see the clock hanging on the wall. They agreed.

Build 1 went much faster than Build 0, because I mostly knew what I was doing this time around. I finished it a few weeks back and ran it at home for a while to be sure that none of the components failed early. That testing passed perfectly, so I took down Build 0 over the past weekend and installed Build 1. It’s hanging there now if you want to see it in person.

In the rest of this post, I’m going to describe Build 1 in enough detail that other makers could start from my design and build their own. Along the way, I’ll talk some about what I learned while making Build 0, and how my design and implementation evolved as a result.

What Build 1 shows you

Here’s a photo of the new build on the wall of the café:

Press enter or click to view image in full size
Build 1 on the wall at UQBAR

Current time

This is a clock! It has to tell people the correct time. The top line of the display shows the time in conventional hh:mm format. In the photo, it’s 5:07pm.

Current metric time

Metric time is my obsession, and was one of the features that the cafe owners asked me to include. The second line of the display shows the current time in metric format. In the photo, that’s 7131.

The way to think about metric time is that the clock divides the day into 10,000 equal-sized parts. A microday is one millionth of a day, so one ten-thousandth of a day is 100 microdays long. The day starts at 0000 at midnight, and ends just after 9999, right before midnight of the following day.

“One hundred microdays” is cumbersome to say in ordinary conversation, so I’ve named this unit of time a “mike.” There are 8.64 seconds in a mike, and a hundred mikes is about 14 and a half minutes long.

Another useful way to think about metric time is that at 7131, as in the clock, 71.31% of the day has passed. It’s an interesting way to situate yourself in time.

Sound level

Benji, one of the owners of the cafe, had seen a live decibel display in another cafe that he visited. It continually monitored the sound level in the space and displayed it. He wanted the UQBAR clock to include a sound level meter like that.

I have moderate hearing loss and wear hearing aids. When I’m at a sports venue or a concert hall or restaurant, the ambient noise is a big issue for me. I can adjust my hearing aids on the fly to compensate for a lot of background noise, high-frequency noise from air conditioning, and so on. So I liked the idea of an SLM on the clock.

The third line on the clock in the photo above is the decibel level at the moment the picture was taken — 57.6 dB. An empty and very quiet cafe still clocks in at about 40 dB; 60 dB is pretty quiet, 80 dB is getting loud and 100 dB is close to cacaphony.

Key components of the clock

The case

I had to build a case to hold all the clock components. I wanted this to look nice.

For Build 0, I’d fabricated a box out of sheets of polycarbonate panels with a wooden front panel I cut from plywood and then painted. The face of the clock was a semi-transparent polycarbonate sheet so that the display digits would shine through it, but the clock’s innards would be hidden from view. It looked just okay, and mounting parts on the polycarbonate box was a pain.

For Build 1, one of the key improvements I wanted to make was that you should be able to open the front face of the clock and look inside it to see all the parts in action. That meant building something like the medicine cabinet in a bathroom. The front panel would still have to be semitransparent polycarbonate, but the box front would have to be hinged. And I wanted to make it out of an attractive wood, nicely stained.

I’m not much of a woodworker, so I asked my friend Darryl to help me with the box. He’s a really good woodworker and has a shop with the precision tools needed to do a super nice job. Here’s a picture of him at his table saw as we prepare to cut the walnut lumber he donated to the project to make the sides of the box. The front of the clock, with the polycarbonate sheet covered in brown paper and blue tape holding it away from the sides, is on the ground behind him:

Press enter or click to view image in full size
Measuring the walnut boards for the box sides and face

We used a piece of nice half-inch plywood for the back of the box, cut grooves in the sides to attach it, and fastened everything with wood glue. At Darryl’s recommendation I bought a kind of “invisible” hinge that could be mounted inside the box. The result is that when you walk up to the clock, it’s not obvious that it can be opened. It’s a surprise when you show people!

I’m not going to go into a lot more detail on the construction of the box. If you undertake this project or one like it, you’ll need to size the box you make to fit the display and other components you choose to include, and you’ll make choices on materials that appeal to you.

I’ll have more to say on the depth of the box below.

When we were done, we had a really lovely stained walnut box with a hinged front 29 inches wide and 36 inches tall. The polycarbonate panel was set into grooves in the boards making up the face. I think it came out great!

Digits for the display

When I was working on Build 0, I tried out lots of different ideas for components to show the various numbers the clock needed to display. Video screens worked okay but were heavy, expensive and not very artisanal-looking. E-ink paper displays were painfully slow to update, and flashed repeatedly in a super distracting way. I found plenty of things that didn’t work for this project!

In the end, I decided to custom-fabricate large seven-segment displays, and to string them with LED strands that I could drive from a computer in the clock to show different numbers. Seven-segment displays are really common and people are used to reading them.

Here’s how they work:

Press enter or click to view image in full size
The seven segments of a seven-segment display, labeled A through G

In order to display a particular number, we choose the segments we want turned on. For zero, A through F are on, and G is off. For the number 1, we turn on segments B and C and leave all the others off. To show a two, we turn on A, B, G, E and D. And so on.

I designed and 3D-printed the digits for my clock. They’re carefully sized for the LED strands I chose to use (WS2812B RGB strands with 60 LEDs per meter, 5 meters long). My Bambu Lab X-1 Carbon 3D printer can print two of these in about three hours and forty minutes. The three lines of my clock display are four digits each, so I needed 12 of these.

The sound level display includes a decimal point so we can show accuracy to tenths of a decibel. The hh:mm display needs a colon. I designed and 3D-printed these as well.

In Build 0, I printed the twelve digits and the punctuation, and I bolted each piece to the back of the box individually. Of course my free-hand electric drill drifted a little bit, so all the digits were a little cattywampus to each other. It looked charming, if you’re being nice, and amateurish, if you’re being honest. I wanted to fix that in Build 1.

For the new clock I designed the digits, the colon and the decimal point so that they’d snap together like puzzle pieces. I added bolt holes to each piece so I could screw them together, making each line of the display a single unit.

Once I had the digits and punctuation puzzle pieces assembled into the lines that appear on my display, I wanted to string them with the LED strands. When I went to do that, however, I discovered that even though they were bolted together, they flexed at the joints. That was no good! Sometimes they’d flex enough that they’d break. Even if they didn’t break, the digits need to press up against the polycarbonate sheet at the front of the clock so that they shine through sharply. That sheet is flat, so the rows of digits need to be flat as well. No flex, no bends allowed.

I solved that problem by buying some half-inch-wide flat metal bars, an eighth of an inch thick, and cutting them so that they were as long as the row of digits was wide. Then I 3D-printed some clamps and, where each of the digits connects to the next, bolted on a clamp that held the metal bar. That gave me a nice flat, strong backing for very little additional weight. I spray-painted the bars black so they look good with the black digits.

Placing the display elements in the box

At this point, I had three lines of digits and punctuation assembled for my clock — a line for the hh:mm time, consisting of two digits, a colon, and two more digits; one for metric time, consisting just of four digits; and one for the sound level in the café, consisting of three digits, a decimal point and one more digit.

I wanted these to be laid out nicely in the box that Darryl and I had built. Before I bolted each of the lines together, I laid out prototypes in the box and custom-printed some spacers to separate the lines from the sides and from each other. I marked the outermost pair of bolt holes on each side of each row and drilled holes to screw each row in place. Here’s what that looked like while I was doing it:

Press enter or click to view image in full size
Laying out the digit displays in the box

Up in the top left corner, by the tape measure, you can see an extra chunk of PVA print. That was a prototype for the status bar for the clock. I wound up not putting it there — I moved it to the lower right corner for the final build. I’ll talk later about what I use it for.

Securing each row in place

Before stringing the rows with LEDs, I screwed them down where they needed to be. The horizontal and vertical positioning are important, but when you screw them onto the back, you need to worry about how tall they are, too.

Each digit should be flush up against the polycarbonate sheet that is the front of the clock. If you have a gap between the top of the digit and the sheet, then the outlines of the segments will be blurry. If the digits are too tall, the sheet will bow out, stressing the pieces and creating fuzzy spots elsewhere.

I carefully measured the depth of the box. I added the distance from the top of the box to the polycarbonate sheet (it was set into the boards that make up the front panel, so was a bit higher than the top of the box). I then added up the heights of all the components of each row — the height of a digit and the height of the clamp holding the steel rod. I subtracted the total digit height from the total polycarbonate height, and 3D-printed custom standoffs that were exactly that tall. I used those to space the digits up off the back of the box.

I verified that the front panel fit properly, with the digits flush, then screwed each of the rows down where it was supposed to be.

Stringing the LED strands for each line of the display

Remember how the seven-segment displays are laid out:

Press enter or click to view image in full size

I needed to take my ribbon of LEDs and string them through each of the digits. here’s the pattern I used to do that:

Press enter or click to view image in full size
Stringing the LED strand onto a 3D-printed digit

The strand enters from the left. It first crosses segment G, across the middle, then turns up to pass through segment B. It then makes a left turn to pass through segment A, turns down to pass through segment F, continues straight through segment E, turns right to pass through D and then up again to pass through segment C.

Each of the segments can hold exactly four LEDs on the 60-LEDs-per-meter strands that I bought. Turning the corners seems like it’d be tricky, but it turns out to be easy if you’re willing to waste LEDs. Whenever I had to turn a corner, I bent the strand down and made the turn, leaving two LEDS in between the segments at both sides of the turn. Between segments F and E, there’s no turn, but there’s still a short gap — I used one LED to span that gap.

Those LEDs in the turns, and the one in the gap, will never be turned on. Engineers generally don’t like to waste stuff, but even with the Trump tariffs (the strands come from China), a single LED on the strand cost me just under four cents. Wasting a few of them to save myself a ton of soldering and simplify the build enormously is totally worth it!

It may be hard to visualize what I’m talking about at the corners and the gap, so here’s what one of my prototype digits looked like after I strung it:

Press enter or click to view image in full size
Stringing the LEDs onto a digit, 4 LEDs per segment, wasting two at the turns and one at the straight connection between F and E.

It’s absolutely critical that you use the same layout — cover the segments in the same order, burn the same number of LEDs on the turns and straightaway — for every digit! Every LED on the strand has an address — a number — starting and zero and counting up. In the code that runs the clock, we hard-code the address of the first LED for every digit, and then rely on all the digits having the same layout to turn on the right segments for whatever we want to display. You can vary the number of LEDs between digits and between lines of the display, but every digit must have exactly the same layout.

The LED strand has a tape backing that sticks pretty nicely to the 3D-printed digit. If you mess up the layout on a digit, you’ll have a tedious job of ripping up the taped-down strand and fixing your error. That’s not impossible (as I have learned the hard way!), but it’s a pain.

Here are a couple of pictures I took of a visual aid that I used for a talk I gave on the clock. This shows two digits with a colon in between them. They’re bolted to a steel bar for strength and rigidity. They’re strung with LEDs already, and I’ve added the segment “cups” that keep the light inside the segment when it lights up.

Press enter or click to view image in full size
Front. The LED strand enters from the left, then follows the pattern described above through the first digit. It loops up and then down the colon, and continues to the second digit.
Press enter or click to view image in full size
Back. Note the clamps holding the metal bar in place.

In the actual Build 0, I cut the metal bars so that they were just as wide as they needed to be to back the entire row. For this visual aid, I left it long so folks could use them as handles while passing the digits around.

On the front photo, you can also see the segment cups in place. First I bolted the digits to the bar, then I strung the LEDs, then I attached the cups. This example took me about 20 minutes to put together.

A separate LED strand for each row

Build 1 of the clock has a total of 590 LEDs. There are 300 of them on each of the strands that I bought (five meters long, 60 LEDs per meter). The strands have a really nice design feature: You can cut them anywhere, and solder wires to them from those cut points to connect them to other strands.

That means, if I’d been willing to do some extra cutting and soldering, I’d have been able to use just two strands for the entire build. I’m lazy, though, and a mediocre solderer. Each strand cost me $23. I chose to buy three of them, and to use a separate one for each row of digits in the display.

They come with a connector at the front, so for each row, I started stringing in segment G right after that connector. I carefully followed the four-per-segment, two-per-turn rule, spanned the gaps between digits and punctuation, and strung each row as a single unbroken string of LEDs as received from the manufacturer.

At the end of each row, I measured out some extra to be sure I had room to reach the next segment, then cut the strand and soldered in a connector that would plug into the next row.

Long strings of LEDs introduce a fair amount of resistance, so after a couple hundred of them, the LEDs that are meant to be white start fading to a sickly yellow. The manufacturer knows about that, and the connectors I soldered onto the ends of each row include some extra wires that I could connect to the 5V power supply for the clock to inject electrons into the middle of the display at each junction.

This worked great! Kept all the LEDs nice and bright and true to the color I wanted.

Some final notes on making the digits

The three rows of digits (and punctuation) in the display are really the key element of the clock. If you’re building one of your own, here are a few key things to keep in mind. Some of this is recap from above, but I want all these notes in one place.

The geometry of the LED strands you buy and the digits you make on your 3D printer are completely interdependent. I used WS2812B strands that are 5 meters long and have 60 LEDs per meter. The space between individual LEDs determines how long each of the segments is on the digits I designed (I use four LEDs for each segment), and the space I leave for making turns when threading the digits (recall that I leave two LEDs unused at each turn).

So if you buy LED strands with LEDs closer together or further apart, you need to change the digits you print to accommodate them.

After you’ve assembled your rows and strung them with LEDs, you need to figure out the address of the first LED on each digit. Each of my digits uses 39 LEDs (4 per segment times 7 segments, plus two per turn for 5 turns, plus one for the straight gap between F and E). After each digit, you will spend a few LEDs in the gap to the next digit or punctuation mark.

You can count LEDs and get reasonably accurate addresses, but nothing beats writing a little test program to draw “8888” on each display and use your eyeballs to be sure you got your addresses right. I also guessed the addresses of the LEDs for the colon and the decimal point, and used the test program to see how bad my guess was. I adjusted the LED addresses based on what I saw.

When I did that, I also discovered one error I’d made in stringing digits with LEDs. One one of the turns, I messed up and used 3, not 2, LEDs. I wanted my code to treat all the digits exactly the same, so I had to go back, pull up the strand on that digit and fix my error. Be careful when you string the digits the first time — that’s the best way to avoid extra work!

At the end of each row, I cut the LED strand, with enough spare to allow me to add the plug-in connector and reach the next row. The strand has solder pads that allow you to connect the data, power and ground lines. The strand is directional, so you need to be sure you string it in the correct direction (the electrons move in the direction of the arrows!) and you need to be precise when you solder the wires to the pads. I used some heat-shrink tubing to add strain relief and insulation after making those connections.

I also needed to add connections to the power and ground lines from the power supply at each joint. The LED strands come with a plug-in connector that includes those extra lines, but you need to do that wiring. If you don’t, the strands won’t be uniformly bright and colorful — they’ll get dimmer the further you go from the LED at address zero.

The manufacturer recommends adding a capacitor between ground and 5V on the power line, and a resistor on the data line, for conditioning of both. I followed those instructions on my build.

One final note: The LED strands I bought operate at 5 volts and draw considerable amperage. I used a 5V, 40A power supply to feed the clock. The compute board I chose uses a 3.3V logic level and requires at least 6V for its voltage supply. I had to add a logic-level shifter to the design to step the signal voltage from the computer up from 3.3V to 5V to feed the LED data line, and a boost converter to turn the 5V supply into 6V to feed the compute board power input. You need to be sure you get the logic and power voltages right!

The compute platform

The three rows of digits that make up the display are the main component of the clock. The second most important component is the compute board that controls the whole clock.

I chose the Arduino Giga R1 Wifi board for this project. This is a really powerful board. It’s a dual-core board, so I could run an entirely separate thread of control on the second one. In fact, I don’t use the second core at all.

I chose the board because it it has three key features built in that save me time and trouble in the build:

  • A built-in wifi radio allows my code to connect to the NOAA ntpd time server to get the current time. I use the Arduino-supplied WifiNINA library to interact with the network. My code connects to ntpd at startup, and then every night at 3am to resync the clock.
  • A built-in Bluetooth radio lets me use the Bluetooth LE (for “low energy”) standard to configure the clock via a custom app I built for my iPhone. With the app, I can provide the wifi SSID and password and change the display color and brightness. There’s an excellent Bluetooth library for the board.
  • It’s got a built-in real-time clock. This was a big deal when I made my choice — without an RTC, clocks tend to drift over time, so my previous projects have all relied on a special RTC board that I added to keep them accurate. In fact, though, the Arduino RTC is unreliable out of the box. You can do some measurement and tuning to get it much more accurate, and I was forced to do that in my code.

Besides all of that, the board has digital input and output pins, and analog inputs that I can use for various signals. I drive the LED strand with one of the digital outputs. I use a button connected to an input pin to interrupt the board when the user wants to connect via Bluetooth. And the sound level meter I chose (see below) drifts a bit over time, so I added a potentiometer that allows users to adjust the displayed sound level up or down so that it matches a reference SLM (I use an iPhone app from the National Institute for Occupational Safety and Health as the source of truth, here).

One hassle with the Giga for this build is that the LEDs operate at 5V power and logic levels, and the Giga needs at least 6V on its Vin pin. Besides that, the Giga uses 3.3V logic levels, so you need to step the data line to the LED strand up from 3.3V to 5V with a logic level shifter. I’d rather not have to deal with three different power voltages, and two different logic voltages, but all the integrated features listed above carried the day. And a single boost converter, plus a single logic level shifter, weren’t that big a hassle to add to the build.

You can certainly find cheaper boards, and boards with better voltage compatibility, than the one I chose. On balance, though, I’m satisfied with the Giga.

Sound level meter

One of the UQBAR owners, Benji, specifically requested that I add a sound level meter to the clock, to display the current decibel level in the café. I planned at first just to use a simple microphone (and maybe op-amp) for that, and to code up whatever I needed to turn air molecules hitting the diaphragm into decibels.

Then I found the DFRobot Gravity analog sound level meter. This is a really nice component! It operates at whatever voltage level you like, interfaces nicely with the Arduino family of boards, and includes a bunch of sample code for getting decibel levels into your app. As I generally do in this project, I chose to spend a bit of extra money to save myself time and trouble in the build.

One caution, though: I used the Gravity in Build 0, and when I hung the clock, the displayed decibel level matched the level shown on the NIOSH sound level app on my iPhone with freakish accuracy. Over time, though, the sound level displayed on the clock drifted up. I had no easy way to address that in Build 0 — I’d have had to pull the clock off the wall, open it up, change the code and upload a new version in order to make any adjustment.

One of the motivations behind Build 1 was to improve serviceability of the clock. For this build, I added a potentiometer that the user can twist to shift the displayed sound level up or down. I’d prefer that the Gravity deliver results with its original accuracy for the long term, but this is a reasonable work-around for the time being. I’m especially pleased that it doesn’t require and code changes to adjust the level.

Controls

Another component (or set of components, really) of the clock are controls that allow the user to change the clock’s behavior. I’ve mentioned these in the text above, but just to call them out expressly:

There’s a pushbutton that, when pressed, puts the clock in “Bluetooth connection” mode. It waits fifteen seconds to get a connection from the companion iPhone app. If no connection happens, it returns to normal operation after that 15-second delay. If the user connects, though, he or she can adjust display properties and change the wifi network credentials.

And there’s the potentiometer, a dial that lets the user adjust the displayed sound level so that it matches whatever they’re seeing on their reference device.

Status bar

In addition to the three rows of digit displays, I added a status bar at the bottom of the clock. I just left some extra LEDs at the end of the strand for the sound level display, and 3D-printed a display component that uses four LEDs in each of three different status lights.

I only use one of those status lights in the current code. If the clock has trouble powering up its Bluetooth radio, or can’t connect to the wifi network, it lights that status light up in yellow. When it’s trying to connect to wifi or Bluetooth, that light turns white. When it’s connected to wifi, the light is purple, and when it’s connected to Bluetooth, the light is blue. Under normal operation, the light is off.

That way, any trouble the clock is having is apparent from looking at it, and I can debug the issue easily (about which, more below).

The extra two status lights are simply spare capacity — I have some ideas for ways I might use them in the future, and it was easy to string some extras now.

Power supply

All of those clock components, of course, require electricity to run.

Because there’s a sound level meter in the case, I wanted a silent supply — no fan. My case includes ventilation at the top and bottom for passive cooling.

I needed to provide sufficient amperage to drive the whole LED strand.

I chose a very nice, slim power supply that met my requirements and bought it from Amazon. The link in this paragraph, at the time of this writing, allows you to buy a pack of ten (!!!) of those power supplies, but when I got mine, I was able to buy just one at a time.

You don’t need to choose the same one that I did; you just need to be sure you’re delivering enough power to run the components you put into your build.

I bought a power cord, cut it to the right length to reach the nearest outlet from the clock when mounted on the wall at UQBAR, and wired it up in place.

Here’s a photograph of Build 1 on the floor at my house, before I mounted it on the wall. All of the components are in place; the build is complete except for a few power cable hold-downs and a couple of labels I added later.

Press enter or click to view image in full size
Build 1, complete, before mounting on the wall at UQBAR

Design philosophy

Whew! Seven-segment digits and punctuation that make up three rows of the display, strung with LEDs, driven by an Arduino Giga R1 wifi board, using a DFRobot Gravity SLM to get the decibel level, with controls for Bluetooth and sound level and a status bar to signal trouble, powered by a 5V/40A 200W power supply. All of it is mounted in a nicely-stained, custom-built walnut case with a front panel that swings open to show off the clock innards.

That’s a lot!

Coolness and beauty

One key design goal for Build 1 was that it should be nice to look at. The walnut case is a big part of that. Then, when you swing the front panel open, the interior is pretty, too. You’ll see that the wiring harnesses all nicely laid out, with each of the clock components clearly labeled. You can trace the wiring around and see how it’s all connected up.

Making it cool, making it beautiful, was really important to me. I want people to talk about the UQBAR clock! I want regular patrons to drag their pals over to the clock when they bring them to the café for the first time, and swing it open, and marvel at it with them.

I may be vain, but I think I pulled that off.

Serviceability

A key flaw with Build 0 was that it was super hard to do any troubleshooting or repair on the clock. If the trouble light came on, I could guess at causes, but in order to test my hypotheses I had to pull the clock off the wall, unscrew the front panel and manually move wires around so that I could connect my computer to the Arduino board for debugging.

Besides that, Build 0 soldered all the pieces in place. If I wanted to replace a part, I would have had to cut wires, install new printed circuit boards, solder connections inside the case. That’s a ton of hassle!

So for Build 1, I wanted to be able to diagnose and fix problems easily with the clock mounted on the wall.

I made three key implementation choices to let me do that.

Maintenance switch

Build 1 includes a maintenance switch in the lower left-hand corner inside the case. When that switch is in the “RUN” position (normal operation), the Arduino is powered by the 5V/40A power supply, and doesn’t try to talk to an external computer.

When the switch is moved to “DBG” (debug), I can plug my laptop into the USB port on the Arduino Giga board. Then the Arduino draws power from USB and is able to communicate with the computer over USB.

I wrote extra code for Build 1 that implements a debug console. I can type commands from my laptop that examine the clock’s state. I can upload new versions of the app that runs the clock, with any changes I want to make.

When I’m done, I pull the USB cable, switch back to RUN, and let the clock do its normal thing.

Best of all, I can do all of this with the clock mounted on the wall. I don’t need to take it off the wall in order to diagnose or fix software problems.

Persistent logging

The Arduino has on-board non-volatile RAM storage and a good software library that lets you save information there. You can retrieve it after the power has been turned off and back on.

Even in Build 0, I used that storage. We need the user to be able to set the wifi network name and password, and change the color and brightness of the display, over Bluetooth (or the maintenance console!). Those changes have to survive power failures or reboots of the clock.

At one point, Build 0 reported a problem by turning on the “trouble” status light. I knew something had gone wrong — either a wifi or Bluetooth issue, most likely — but I didn’t have any way to determine, after the fact, what it was.

Build 1 stores the last ten log messages in non-volatile memory. From the debug console, I can dump that log and see what’s happened lately. I mean to improve the Bluetooth iPhone app to show those messages as well, but haven’t done so yet.

Saving messages in this way makes it much easier to troubleshoot and diagnose problems! When I sit down to debug, I can look at all the recent activity and issues.

Easily-swappable components

In Build 0, I spent a lot of time soldering components in place. I even went to the trouble of mounting the resistor and capacitor components for LED line conditioning on circuit boards and soldering them.

After hanging Build 0, though, I decided that making a lot of permanent, hard-to-undo connections was a mistake. If any component on the clock failed, not only would I have to pull the clock off the wall to diagnose the problem, but I’d have to cut wires and solder new parts in place inside the body of the clock. That’s a real problem — lots of sensitive components and plastic in there, and a little slip might disfigure or destroy other stuff. As I said above, I’m a mediocre solderer. I have the fine motor control of your average guy in his mid-sixties. It’s best if I don’t need to use that skill very often.

Build 1 takes a very different approach. Instead of soldered connections, I insert wires into the jacks on the boards everywhere. I even put a breadboard — a common tool for electronic prototyping, that lets me plug in wires, resistors, capacitors and chips without having to solder them in place. Aside from the case itself, there’s not a single part of the clock that I couldn’t test in situ and pull and replace easily without soldering in the clock.

The decision to use a breadboard also makes it clearer what’s connected where. I was able to use the power rails on the two sides of the board for the 5V (left) and 3.3V (right) power lines throughout the clock. Other electrical engineers can look at the build and see how the components are connected.

I think that makes it even cooler and more beautiful! And it means the clock is likely to live longer. I can fix software and hardware problems right on the wall, with no need to bring the clock into my shop.

Code, circuit design and CAD files

I’ve published all of the intellectual property that I created for the clock under permissive open source licenses. You’re free to grab them, use them as they are, modify and share them.

The source code that runs on the clock and the source code for the iPhone app that configures the clock are on my Google Drive. Both of these applications are published under the 3-clause BSD license. In the past I’d have put these up on my github, but Microsoft is flogging AI features furiously there, even turning off search on the site until you opt into AI. I don’t need that hassle, and I don’t expect to get any pull requests, so you can just download the files manually.

The STL files for 3D printing and the circuit design are also available via Google drive. They’re under a Creative Commons CC-0 license. No need even to acknowledge me if you use them.

If you do do something interesting with this project, though, I hope you’ll leave a comment here and tell me about it!

Parts and tools

This is a fairly comprehensive parts list for the build. It’s not exhaustive — I made custom wire clamps for the wiring harness inside the clock, for example, and custom stand-offs for mounting the digits above the back wall of the clock case, for another example. Also screws, solder, etc. I don’t include any of the parts or tools needed to build the case.

But those depend on your particular build, and you can figure that stuff out yourself.

  • Arduino Giga R1 WiFi board
  • 5-meter WS2812B LED strand, 60 LEDs/meter (3 of these)
  • DFRobot Gravity sound level meter
  • 5V power supply (40A is plenty). As above, this link is to buy ten of them. You only need one. Shop around.
  • PLA filament for your 3D printer. I went through a bit more than one spool of black for the digits, punctuation, segment covers, labels and miscellaneous prints, and a small amount of a spool of white for lettering on the labels.
  • Six flat four-foot-long steel bars, half an inch wide, an eighth of an inch thick. These are to bolt to the back of each line of the display, to give the line of digits strength and rigidity, and to hold the line flat against the polycarbonate sheet that is the face of the clock. You’ll cut these bars with a hacksaw to the length required by each line. Each line has two bars.
  • Single-pole momentary pushbutton to initiate Bluetooth connection (the Amazon link is for six of them, but you just need one).
  • SPST toggle switch to switch between RUN and DEBUG mode (again, you just need one).
  • Logic shifter to turn the Arduino’s 3.3V data signal into a 5V signal for the LED strand
  • Tunable voltage step-up (you’ll want to tune to someplace between 6V and 24V, input levels accepted by the Arduino on the Vin pin)
  • 330-ohm resistors for LED data line conditioning and wiring up the button (link is to a pack of assorted resistors, but substitute any source you like)
  • 470uF capacitor for LED power line conditioning
  • Hookup wire
  • M3 20mm screws, nuts, washers for bolting the lines of digits together
  • Semi-transparent polycarbonate sheet for the face of the clock. You want to be able to see the lit-up LEDs through this, but not the components inside the clock. Before you buy a big expensive sheet, test a few small pieces to be sure you buy the right amount of transparency.

I also used a breadboard to connect the resistors, capacitors and logic shifter, and to provide 5V and 3.3V power rails.

Here are the tools I used:

  • Bambu Lab X-1 Carbon 3D printer (I love this machine!)
  • Digital multi-meter
  • Drill with assorted bits
  • Wire clipper and stripper
  • Needle-nose pliers
  • A hacksaw, to cut the steel backing bars for each line of the display to the right length
  • Soldering iron for connecting the modular plugs to the cut-to-size LED strands coming out of each row of digits
  • Assortment of screwdrivers
  • Hex wrench for the M3 bolts (one was included in the package of bolts I bought)

--

--

Mike Olson
Mike Olson

Written by Mike Olson

Berkeley-based techie with an interest in business. Worried about the world.