longwave clock: decode or simulate longwave clock signals with a flipper zero
The field of radio engineering is one which eluded me until the Flipper Zero made me acutely aware of how much is there to learn and how many different radio waves pass us by completely unnoticed.
On the subject of radio waves, longwaves (LW) are extra fun since they really do carry over enormous distances, with the DCF77 signal at 77.5 kHz reaching a distance of more than 2000 km from its sender in Frankfurt, Germany (and even synchronizing clocks more than 7000km away).
Longwave clocks use longwaves to carry a time signal synchronized with an atomic clock near the sender antenna.
To receive these signals, a small ferrite antenna is used as well as a noise filter, as the received power is in the orders of μV/m.
Used protocols and LW frequencies are:
- DCF77 (77.5 kHz): receivable in and around Europe
- MSF (60.0 kHz): receivable in northwestern Europe only
- WWVB (60.0 kHz): receivable in the Americas, not in Europe
- JJY (40.0/60.0 kHz): receivable in East Asia
As I looked into the protocols I realized they wouldn't be too hard to decode, so I implemented a Flipper Zero application to decode the input from a receiver module, or just simulate their reception.
Writing the flipper app
Writing the flipper application was a challenge, as I possessed very little knowledge of C programming and the documentation for writing Flipper apps is somewhat fragmented.
Lessons learned along the way:
- I started developing the app alongside Momentum. Only later I did realize that the custom firmware has some more advanced features and UI interfaces that the original Flipper project lacks, so I had to #ifdef them out when building against the original Flipper Zero firmware.
- Unit tests are virtually nonexisting in the firmware and app development. This meant way too much costly debugging and error solving, which I would have addressed otherwise.
- UI/graphics is dirty work. Making an app "pop" is really an art. I can't claiming having mastered the basics, but I'm at least contented with the result that shows how the different signals are made up (in a stream of bits).
By the way, the GIF above is made by imagemagicking a Flipper Zero image with a hand-drawn time module and screenshots from the actual running app, it turned out better than I thought. - Implementing a good error correction (i.e. expecting a bit to come every 1000ms and ignoring out of sync jitter) would require multithreading, which I couldn't implement on short notice. In effect there is some multithreading magic going on, but either the flipper is too slow or I'm just wasting CPU cycles on drawing bits on the screen.
- I tried once debugging using the blackmagic firmware on the Wifi Devboard and thought I had just bricked the flipper, as it shut off. Instead, I think it was just stopped on a debugging instruction, and the debugger on the computer hadn't picked up on it.
A hard reset fixed this.
Making a DCF77/MSF module
Making a GPIO module that would incorporate both a 77.5 kHz (DCF77) as well as a 60.0 kHz (MSF/WWVB) module was a bit of a challenge as I needed to cram two modules in a little space and not burn anything whilst soldering the circuits together.
In the process I learned that both modules really can't stand radiation from nearby electronics, and even the flipper can make the signal very flaky, in case the ferrite antenna is closer than 10 cm from it.
The best reception is found either outside or by putting the ferrite andenna close to a window (parallel to it), and during the night is best (as the sun might also cause some interference).
All in all a working module that keeps the antennas away from any interference from the flipper, I had some trouble cramming the necessary hardware in a small space but I'm happy with the results.
And yes, in hindsight using less glue would have resulted in less crystals forming within the transparent caps. Oh well.
If you wish to connect a module to your Flipper zero as well (multiple modules are available on your favourite online electronics shop) look into the module and pinout in Github. I'd love to see modules and 3d printed shells pop up on Tindie.
Installation and sources
You can install the app via the Flipper Zero App on your phone, or by following the links below.
Type | Domain | Link |
---|---|---|
Flipper app | lab.flipper.net | Longwave Clock |
Github sources | github.com | flipper_longwave_clock |
This Flipper Zero app is released under the terms of the AGPLv3 or any later version. See the details.
Credits and mentions
- Thanks to the creators behind the Flipper Zero for making a fun little device which really gave me the input to start learning more about all sorts of stuff radio and LF/NFC RFID.
- Thanks to the flipper community and especially the developers behind the original as well as unleashed and Momentum firmwares for pushing the Flipper Zero to the limit in terms of features and keeping the community alive.
- Thanks to the guys behind Blinkyparts for organizing the "Ewiger Lötworkshop" at the 38C3... I learned a lot!
- The font "HaxrCorp 4089" by "sahwar" is licensed under a CC-BY-SA license.
- Credits for the flipper image to the Flipper Zero Docs