Tide Clock

27 Dec, 2020, updated 28 Dec, 2020 micropython tideclock docker

Never written up the few technical projects I’ve done on here, so here’s an old project, a clock to show the next sea tides. I got it on hackaday, which I’m very pleased with.

A photo frame containing a map of Walton-on-the-Naze and an electric ink display indicating the next high tide
A tide clock, complete

There’s a set of journal posts on the project page for it and source code.

This uses the embedded WiPy that I’d got the very first version of in their Kickstarter. It’s a small microcontroller that runs an embedded version of Python and can perform general-purpose IO, connect to Wi-Fi, and is battery-powered.

So perfect for those small Internet of Things projects!

I bought an e-Paper Display (EPD) which was the most expensive single component, and eventually got images rendering to it.

A circuit board connected to a display showing stripes
A circuit board connected to a display showing stripes

Pretty much the rest of the client code is:

  1. Boot up and configure the hardware
  2. Load settings from an SD card
  3. Connect to Wi-Fi
  4. Download the current image to show on the EPD
  5. Upload some logs
  6. Check what time to wake up next
  7. Go to sleep
  8. Handle all the errors I can think of

The server is written in Python and PHP and fetches:

EasyTide is mangled in BeautifulSoup to get machine-parseable information. Happily DataPoint returns XML (although the service isn’t quite as reliable).

A circuit board connected to a display showing the time of the next tide
A circuit board connected to a display showing the time of the next tide

And Bob’s your uncle! I stuffed it all into a nice frame and tethered a USB cable in the back (the WiPy can charge a Li-ion battery from USB, very useful again).

A circuit board mounted inside a picture frame
Slips of card hold things in place

And then I discovered timezones are a bitch.

Despite learning about Unicode and the importance of knowing the encoding of incoming data, I had never extended this to times. The pytz library helped me a lot at this point as I could mark up what time zone the data was using and then convert to UTC and to my timezone as appropriate. But I had a few funnies on timezone change that first year.

Then the Met Office changed their setup slightly.

Then I hit an end-of-year bug.

Also turns out the Wi-Fi at my stepmother’s house wasn’t great and the connection was poor. BT had to fix things (and the router would keep interrupting connections to offer to set up some Net Nanny type thing).

And I’ve been relatively scared to touch it for the last year or so. Debugging is a pain when you need to wait six hours to see if it works.

This year I wanted to upgrade off some old stuff, so I have:

Screenshot of the tide clock showing the time
The actual tide clock image
comments powered by Disqus