Building a Tide Clock Weather Thing

I built this thing! It’s a device for showing current temperature and weather conditions, as well as high temp, low temp, hourly forecast, and the low tides for the day.

Mostly-finished tide clock, doing its top-of-the-hour full rotation of the big wheel. I believe a game of Pokémon Monopoly is happening in the background.

I made this as a gift for my in-laws, who are watching the kids a ton this summer at their cottage in Maine. Up in Maine, one is only approximately interested in the weather: “Is it a good day to take the kids to the beach?” “When is the best time to take a kayak out?” “Can we have dinner at the picnic table or will it rain?”

So, this kinda shows the temperature, kinda what the weather will be, and kinda when the tides will happen. Which is perfect for summer vacation.

Sunny all day, with highs in the upper 80s.

What am I looking at exactly?

I purposely didn’t include any instructions on the case. I’ll leave it to the reader to decide if that’s delightfully enigmatic or frustratingly inscrutable.

The large wheel is showing the current weather conditions on top. As they change, it rotates to bring a new icon to the top. The icon gears themselves rotate as they move. It looks cool. Watch the video.

The middle of that wheel has lights along the top to show the forecasted temperature range for the day. It runs in 5° increments from 30° to 90°, with 60° in the middle. The pointer points at the current temperature.

The five lights below the temperature gauge light up blue for impending rain, filling up to show when it’s 60, 45, 30, 15, or 5 minutes away.

Along the front are LEDs for each hour of the day, from midnight to 11pm. They show the forecast for each hour, with a color that’s equivalent to one of the “current conditions” icons. (Sunny is bright yellow, rain is blue. Partially sunny is sort of less yellow, and cloudy is dim white. Snow is kind of pink? The night ones are a bit dim blue and hopefully don’t get confused with rain. Windy is green, because what are even the options at that point.)

The bar right above the hours is pointing at when the two low tides of the day will occur.

Building the device

Video clips from the building and testing process.

Planetary gears

The current conditions wheel is what’s known as a “planetary gear” arrangement. There is a center, “sun” gear, eight “planet” gears (with the icons), and an outer ring. When the ring gear rotates, the planet gears rotate and “orbit” the sun.

You can read my forum post about how I put this together and get the instructions and SVG file for printing it yourself.

I first stumbled upon planetary gears when putting together some Magic: the Gathering life trackers. There’s something really appealing about how the planets spin around and come back to line up. Ever since doing the counters I’ve been looking for more ways I could use these gears, and the weather icons seemed like a great chance.

All the weather data for this device comes from the Dark Sky API, which specifies a representative icon for the current conditions and each of its forecasts. There are actually ten different icons in the API, but I was worried that ten planets would be too small relative to the rest of the wheel. I therefore collapsed “sleet” into “snow” and “fog” into “cloudy” to bring the count down to eight.

Those weather icons are by Austin Condiff from the Noun Project, used under a Creative Commons CCBY license.

Prototype to figure out how the planets need to be oriented so that they’re right-side-up when they reach the top.

The site (“an engineer’s approach to woodworking”) has a very useful guide for calculating the right planetary gear ratios. The outer ring has to have as many teeth as the sun gear plus two planet gears.

Since we also want the planet positions to line up consistently as they rotate, the ring teeth must be divisible by the number of planets.

That led me to use 64, 32, and 16 teeth for the ring, sun, and planets, respectively.

With the Magic counters, the ring gear is fixed (because you’re holding it) and the sun gear rotates with the pointer. For the tide clock, I decided to fix the sun—so that I could use it to show temperature information—and rotate the outer gear. To do that, I chose a stepper motor.

Stepper motor, mount, and gear.

Stepper motors are motors—meaning they have a bit that spins around using electricity—but, unlike a traditional, two-wire brush motor, their electromagnetic coils are directly controlled from the outside. You move the motor forward and backward by powering them on and off in a specific sequence. With each of these steps the motor moves a very specific distance, which makes them very precise. You always know exactly how far you’re rotating in either direction.

Steppers share some similarities with servo motors, as both are used for accurate positioning, but servo motors can only position within a 180° arc. They can’t go around and around. (“Continuous rotation” servo motors can go around and around, but you only have control over their speed, not their position.)

The stepper motor I used takes 1024 four-sequence steps for a revolution, so if I know what the current icon is, I can move exactly to any other icon just by going a certain number of steps. 384 per icon, it turns out; consistently using powers of two in the gears helped out.

My biggest regret with the design of this device is that you don’t actually see the wheel moving all that often. Weather conditions just aren’t that fluid. I ended up adding a feature to rotate the wheel all the way around (back to the same icon) at the top of every hour just to show it off.

In retrospect, I also wish that I had kept the spokes behind the wheel. You can see them one of the prototypes in the development video. They highlight how the ring and icons are moving at different rates. I axed them because they were getting in the way of the back of the temperature display mechanism, but they did look cool.

The tide indicator

Showing accurate tides was the impetus for making this device. I had it in mind to replace a flaky, hard-to-set, hard-to-read tide clock I had given as a present a few years ago. I initially started out with very ambitious goals on this front.

MDF prototype of the final tide indicator mechanism.

I wanted to not only visualize both low and high tides for a day, but to control those four indicators independently. On the East coast, tides only average a 12h 25m cycle. The actual time between tides can be up to a half an hour in either direction. I could one-up that other tide clock by having per-tide precision, based on up-to-date tide forecasts from the NOAA.

Unfortunately, as I worked through the design, I ran into trouble getting everything to fit, given my materials and constraints. Not only would the servos and their gears take up a lot of space, it was a challenge to devise a system so the gear racks wouldn’t bump into each other or stick off the side. Every surface having a fixed thickness of 3.3mm didn’t make it any easier.

In the end, I pared the tides down to the bare minimum. As fun as a servo party would be, it would also be fragile. And really, at this scale, and at the vague way the hours are marked, there was no way someone could notice a 15 minute difference in where the arrow pointed (if the servo could be that accurate anyway). A single servo with a fixed 12h 25m interval was definitely good enough for vacation.

Iterations on driving the gear rack for a tide indicator. Top: an indicator for a 12 hour range. You can imagine how the rack would stick off the edge as the indicator moves to the right. Bottom: Prototype for putting the drive gear on the top of the box. My goal was to have the indicators then dangle over to point at the hour track.

The first thing I had to consider when making this work was that servo motors only give you 180° of motion. Without the added complexity of a gear train, which I was trying to avoid, that meant that the linear distance I could move a gear rack was half the circumference of whatever gear was attached to the motor.

This meant that the drive gear had to be pretty big, with a diameter of almost a third of the width of the hour track (around or about 31.415%, you might say). At the same time, the gear rack had to be driven from the center so that it could have an equal range of motion in each direction without hanging over either edge. I put the drive gear off to the right, to visually balance (and stay out of the way of) the big wheel, then centered a smaller gear that could directly move the rack.

Putting the gear flat on top would have been a neat effect, and I prototyped it, but laser-cut gears don’t mesh well at 90° angles. That would be an interesting problem to try and solve on a future device.

Looking at the end result, I actually did end up with the gear train I was trying to avoid, because I needed to transfer the motion sideways to the center, and then also from the middle of the box to the front. Nevertheless, I like the look of the large drive gear. I still would have liked to have included the high tide, but I ran out of time to figure out how it would fit.

Designing the parts

The case and gears and everything are all made on my Glowforge. I prototyped with Proofgrade Draftboard MDF, and the final project is medium cherry and medium maple plywood.

I made all the plans in Inkscape, a free, open source, SVG-native vector editor. Inkscape has a lot of good tools for manipulating vector shapes, joining paths together, arranging things, and doing precise measurement and positioning.

Inkscape has a built-in plugin to generate spur gears (that’s what I used for the Magic trackers), but for this project I relied on the inkscape-extensions-gears-dev plugin. It has better controls and slightly nicer-looking teeth, and could handle making both the ring gear and the gear rack.

Top-down view shows the TrayLayout dividers supporting the motors.

For the case, I started with a custom “TrayLayout” built with the excellent site. This gave me an outside box and two dividers running from left to right. I took those basic shapes into Inkscape, where I modified them to support the motors and gears by adding holes and extending parts of them upwards.

I did do a little bit of visualization in Fusion 360, and also threw together a scale model in cardboard to get a sense of the size. Laser cutting MDF is fast and fairly cheap, though, so most of my prototyping was done with that.

Technical implementation

Brains of the device

Speaker pHAT with the Raspberry Pi W underneath. To the right is the Darlington array that drives the stepper motor.

Driving this whole thing is a Raspberry Pi Zero W. Raspberry Pis are tiny computers that boot off of micro SD cards and can run Linux. Unlike the flagship Raspberry Pi, the Zero line does not have full-size HDMI or USB ports or any size Ethernet port, and it has a slower chip and half the memory. But by giving those up it can come in at a smaller size and a $10 price point. The Zero W does still have wi-fi, which was necessary.

The software on the Pi is a Python script that runs as a service on startup. It periodically queries for weather and tide data, and then controls the various outputs to display that information.

At my spouse Cait’s suggestion, I added chiming for when the high and low tides happened. The Zero W unfortunately does not have any direct audio out, however. I considered using this guide to get audio from the Pi’s pins, but in the end I bought a Pimoroni Speaker pHAT because I knew it would just work.

Controlling the lights

The Raspberry Pi (back left) connected to the Trinket (right) to control the NeoPixels and servo of a prototype temperature display. Thing on the left of the breadboard is a level shifter to bring the Trinket’s 3.3v output up to the 5v that NeoPixels require.

Because it’s running Linux, a non-realtime operating system, the Raspberry Pi can’t control the NeoPixel LEDs that I’m using. NeoPixels are RGB LEDs that are all chained together with just 3 wires (5v, GND, and data), but you can control the colors of each of them individually. The protocol for communicating those colors has very precise timing requirements that require a microcontroller.

I turned to the Adafruit Trinket M0, a very small and inexpensive microcontroller, to serve as a NeoPixel-driving breakout board for the Pi. I also ended up hooking the servos up to it as well. Using the Wire Arduino library I was able to make the Trinket into an I2C device that the Pi could talk to. I wrote a simple protocol with commands to set pixel colors and servo positions.

If I needed something similar in the future, I would use an Arudino Nano (or cheap knockoff equivalent) instead of the Trinket. Nanos run natively at 5v, eliminating the need for a level shifter.

Data from the cloud

I wanted to be defensive against API changes from the data providers, so I wrote a quick server to go between them and the client running on the device. You can check it out on Glitch, though it’s not a whole lot to look at.

The weather data is from the very nice (and free for the minuscule traffic I’m using) Dark Sky API. Tide data comes from the NOAA’s Tides and Currents site.

This happened a lot during final assembly.

Miscellaneous lessons learned

  • Wander around, but then step back. I had a great time iterating on the design and features of this, going where it led me, but I didn’t always look at where I ended up. For example, when I was going to have five servos I knew I needed a separate servo breakout board. When that went down to two I was still thinking “breakout board” and so I put them on to the Trinket. Nevertheless, the Raspberry Pi can control two servos by itself with hardware PWM. I just didn’t think to go back to it.
  • Wax is really good for gears. I was able to eliminate a lot of friction by waxing the planetary gears and the tide indicator. Thanks to members of the Glowforge community for pointing out that crayons are an excellent source of wax.
  • LEDs take electricity. Right towards the very end, the Raspberry Pi started acting kooky. I thought that I might have fried it by accidentally shorting something when I was doing final wiring, but I swapped it out for another Pi and the problem persisted. My problem ended up being that I had all 48 of the LEDs on full blast to do a wiring test. This was using so much of the power supply’s power that the poor Pi was browning out. When I reduced the LEDs to the reasonable brightness I actually wanted, the problem went away.
  • Save space for the wires. I went by the measurements of my circuit boards to design the case, but didn’t make enough accounting for the wires. I ended up having to custom crimp all of the jumper wires just to fit the lid on. Making it ¾” taller and deeper would have saved a lot of work, and would not have been noticeable.
  • Time is money. Sometimes it makes sense to just buy an off-the-shelf solution that will save not-fun effort. (Fun effort is what hobbies are all about, of course.) For example, my original plan was to use individual NeoPixels for the temperature range. I could get 10 of them for just $6! I got as far as connecting two together before I realized that soldering 5mm jumper cables on to surface-mount components was going to be a giant fragile pain in the ass. Since my goal was to put them in an arc anyway, I swallowed my pride and bought the 24 pixel ring. It worked great, will hold up better, and with more LEDs I was able to go from 10° increments to 5° increments, and add in the rain indicator.
  • Servos are pretty fragile. Especially the cheap micro servos I was using. I think I stripped two of them on the tide indicator, since during testing it kept getting set to a position farther than the gear rack would go. It’s worth tweaking your program to make it move gently.
  • I should learn about tools and stuff. Right now I’m doing everything with the laser, and what I can’t friction-fit I’ve been gluing down. I’d like to consider doing more woodworking in my designs to achieve things that a laser cutter alone can’t do.
  • Hot glue comes off with rubbing alcohol. And Krazy Glue comes off with acetone.
  • Adafruit is the best. Their stuff can be on the pricey side (especially compared with getting generic components directly from China), but what you’re paying for is quality, reliability, documentation, fast delivery (next day UPS Ground to Cambridge!) and supporting a cool small business that supports the creativity and education.

So that’s my thing! It was a ton of fun to make and kept me very busy in the evenings and weekends for a few weeks. I learned a lot about the practical side of putting electronic components together into a project.

I’ve got some more devices planned, so keep an eye out here for future posts.

Oh, and if you want a Glowforge for yourself, you can get a small discount (and send me a kickback) by using my referral link.