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.
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.
Pretty much the rest of the client code is:
- Boot up and configure the hardware
- Load settings from an SD card
- Connect to Wi-Fi
- Download the current image to show on the EPD
- Upload some logs
- Check what time to wake up next
- Go to sleep
- Handle all the errors I can think of
The server is written in Python and PHP and fetches:
- Tide information from the UK Hydrographic Office EasyTide service
- Weather information from the Met Office DataPoint service
EasyTide is mangled in BeautifulSoup to get machine-parseable information. Happily DataPoint returns XML (although the service isn’t quite as reliable).
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).
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:
- Removed the PHP and replaced it with Flask. Except the upload URL is fixed at
upload.php
so that’s annoying - Left Flask in Docker (as it’s cool, right?) and put the updater script in docker as well
- Apache now reverse-proxies the container
- Actually run some lint checks over the code
- Updated the dependencies