Thursday, 20 October 2016

Hacking an analog clock to sync with NTP - Part 3

Most battery-operated analog quartz clock on the market today are quite similarly internally. They are usually based on an oscillator driving a Lavet type stepper motor, Movement is made by alternating the current running through a copper coil in every step, followed by an interval without current so as to provide time for the magnetic gear to turn to its new position.

I am going to disassemble the Ikea clock and connect two jumper wires to the clock mechanism. These two wires will then be connected to the GPIO pins of the ESP-12 for ours to control.

To remove the plastic cover over the clock face, turn the clock over and disengage the 3 plastic tabs holding the cover using a flathead screwdriver.

Once that is done, pull out the second hand, followed by the minute then the hour hands.

With a butter knife (I used a plastic pry bar), gently pry the clock mechanism out of its holding cavity.

There are tabs on both sides of the clock mechanism holding the front and back halves together, which is easy to take apart.

When pulling the front and back halves apart, it is best to do it with the spindle always facing up to minimize the gears falling out all over the place and having to spend time fitting them back together. Also, take photos every step of the way to make it easier to fit the parts back later if needed.

The cluster on the right containing the copper coil is what we are interested in. If you look closely, the coil is actually connected to the two solder points at the front. When powered by a battery, alternating pulses will be applied by the osciallator (the metal tube) at those points, powering the copper coil and causing the tiny magnetic gear to rotate in steps.

What we want to do is to solder two jumper wires at those points so that we can power the copper coil at will.

I also used the soldering iron to create a small hole in the casing for one of the jumper wires to pass through.

Now it is time to put everything back together.I find it easier to place the magnetic gear upside down with the other gears:

then carefully invert the other half containing the coil onto this half, after carefully lining up all the holes and connectors.

At this point, it is best to check if everything has been assembled properly by fitting the second hand into the spindle and inserting an AA battery. If the second hand starts to tick as normal, the operation is a success!

Once the testing has been done, I can insert the clock mechanism back into the holding cavity. In order to accommodate for the new wires, I used the soldering iron to melt two holes at the side:

Then reinsert the plastic cover over the clock face, and we are done!

To be continued...

Hacking an analog clock to sync with NTP - Part 2

Since I am more familiar with C/C++, it makes sense for me to use the Arduino IDE (rather than Lua, the other alternative).

Everything was surprisingly easy to setup. I first installed the Arduino IDE, Then I followed the instructions here to setup the board manager within the IDE. I really wanted to base the WiFi configuration part of the project on WiFi Manager, so I added that to the IDE using the library manager.

I also setup the board type under "Tools". There is no entry for ESP-12F, so I went with the ESP-12E since the two should be virtually identical as mentioned previously.

With all the setup done, I went with the simplest possible WiFi Manager sample code, which looks like this:

#include <DNSServer.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>

void setup() {
  WiFiManager wifiManager;

void loop() {

Then I click on "Sketch, Upload" and let the magic happen...

Lo and behold, a new WiFi network appears!

Connecting to it automagically brings me to the front page of the captive portal.

To be continued...

Wednesday, 19 October 2016

Hacking an analog clock to sync with NTP - Part 1

Inspired by this blog post detailing how to control the ticking mechanism on an analog clock with an Arduino, and having recently come across this gem of a WIFI-enabled micro-controller called ESP8266,  I decided to try and see if I can tether an analog clock to the ESP8266 and make it sync with a time server so that it is always on time (and is able to deal with daylight saving as well).

Not being much of a hardware geek myself, I opted to get the dev board for the ESP8266, the ESP-12E. That way, I can connect it straightaway with my laptop via a USB cable and start coding right away. Cost: ~$6.

Note: What I received turns out to be the ESP-12F, which appears to be virtually identical to ESP-12E.

For the analog clock, I chose to use the $2 RUSCH wall clock from Ikea. Now this is a cheap and nasty clock, made using the cheapest possible material. The second hand doesn't even line up with some of the tick marks as it makes its rounds. But cheap is good for experimentation, and an Ikea clock is useful as a reference point since everyone has access to Ikea.

To be continued...

Sunday, 24 July 2016

Cheaper to salvage 2TB laptop HDD from Seagate portable HDD

As widely discussed since 2014, this trick still works in 2016, which is insane price arbitrage if you ask me.

Bought a 2TB Seagate Expansion Portable HDD for $117. The 2.5" SATA HDD inside, if purchased as a stand-alone unit, costs upwards of $165.

Prying this open requires a thin sturdy Swiss army knife blade (or something equivalent). A guitar pick was not rigid enough to do the job for me.

The way these newer casings are designed, the plastics catches on the end that you start prying are bound to break.

The other end should be OK if you are careful enough.

I didn't need the casing anyway, so I didn't care. But you can always put it together with a little creative application of black electrical tape, so I don't think it's too much of a problem, unless you are really picky about cosmetics.

After putting it into my laptop, SeaTools detects the HDD as ST2000LM007. Not much of a surprise here.


  • $50 savings for 5 minutes' work
  • You can never be 100% sure which brand/model HDD you are getting inside
  • You void the warranty
This approach is not for everyone, but the bang-for-buck ratio is really high for the adventurous to take a dive.

Wednesday, 25 May 2016

Lossless concatenation of MP4 video files


ffmpeg -i myfile1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts int1.ts
ffmpeg -i myfile2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts int2.ts
ffmpeg -i "concat:int1.ts|int2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

Monday, 23 May 2016

RIP - QY8 Bluetooth Earpiece

Purchased: Sep 2015

From: GearBest

Died: May 2016

Issue: No audio in right earpiece. Suspect break in connecting wire between the two earpieces.

While it lasted: Good reception, audio and battery life. Comfortable wear (not too heavy). A little disappointed with the durability because I have always handled it gently.