Project: AT89S52+DS1302-based LED Clock Kit (EC1204B-Equivalent)

Since I started along the line of garish LED-adorned kits, I thought I’d order a few other kits built around the AT89S52. In this case, it was a clock based around the AT89S52 80C51 microcontroller and a DS1302 real-time clock. For AU$8.06, it only cost more AU$2.50 more than the RTC chip alone from a local source, so it’s definitely good value. It might even look good, who knows?

That’s what I thought, almost a month ago when I ordered it. Imagine my surprise when it arrived today – the same day the US election results was to be announced? Instead of just being just a clock, it would be the doomsday clock!

The Package


This kit comes in a heat-sealed static-shielding bag. Unfortunately, as the PCB was one of the larger elements inside, and the edges were designed to snap off, damage in shipping resulted in one corner being almost completely snapped off. As a result, this would impact the construction process and the practicality of the final product slightly.


The PCB is a blue-solder-mask double-sided tin-plated board with silkscreening indicating component placement. It is roughly square in shape, with a circular inner, and rounded edges. This arrangement allows for using the outer holes as mounting, or for removing the edges to have a circular clock face. No identifying names are printed on the board, it seems.


The rear of the board has the same finish, which is actually not bad. The board features component mounting on both sides. The word “speaker” is misspelt on the silkscreen. There seems to be a provision for Bluetooth connection to a module, but this was not included in this kit. It appears to be just a 5v TTL-UART connection with Vcc and GND.


While the exterior used a static shielding bag, the components are bagged inside regular resealable bags, and the chips are placed into foam without foil shorting the pins. This is pretty regular for these kits, but isn’t strictly best practice. It is seen that IC-sockets and a simple mini-USB cable are provided, which is a nice touch. Of course, it is missing a CR2032 battery for the RTC, which is probably for cost reduction and shipping liability reasons.

What sets this kit apart from others is that there is a non-negligible amount of SMD components that need to be mounted. This makes the kit a medium-to-high level difficulty kit, rather unsuitable for absolute beginners. It also means that you need to have a set of fine tweezers and a fine tipped iron, in addition to supplying your own solder, side-cutters, soldering iron and desoldering braid. It, like the other LED based kit, is a test of endurance as well with a large number of through-hole components needing to be mounted carefully.

Uh Oh! Where’s the Docs?

At this point, it’s obvious that no documentation had been provided with the kit. As the silkscreen did not have the component values, I was slightly stuck. The kit had two different resistor values and two different capacitor values without any clear way to differentiate which is mounted where.

I contacted the seller, but they didn’t respond in the day, so I decided to do a little digging through similar kits. As it turns out, this seems to be a clone of the EC1204/EC1204B kit with only minor changes. By using this construction manual, and a table listing components, I could eventually work out which components went where.

As it turns out, there are quite a few modifications made by others, which include even replacing the microcontroller with another so other features could be more easily added.

Quick Reverse Engineering

As this kit seems at least a little popular, I didn’t feel the need to fully reverse engineer the board and draw a schematic. However, I will make a few quick notes.

Chip Program


As with the other kit, the chip doesn’t appear to have any code protection lock on it, so it could be reprogrammed and updated. The dump of the program seems to show that the code has the EC1204B model number in it, and occupies about 7015 bytes of the 8192 bytes available. I suppose this might mean that there really isn’t much space remaining for more code.


I’m no expert in code disassembly, but I did load it into IDA Pro just to see that it wasn’t just random data. There’s quite a few blocks in the code, and the flow is a bit haphazard, but that’s what’s there. I can’t really say much more than that!

PCB Connections

This board has a lot of LEDs to drive, and yet, uses a 40-pin chip just like the other kit. So how is this “magic” achieved? As it turns out, quite an elaborate multiplexing scheme is in use.

The LEDs around the edge (60 of them) are connected as an 8×8 matrix with the last set having just four LEDs (LED56-LED59). The anodes of 8-consective LEDs are driven through transistors and current-limiting resistors, whereas the cathodes of each nth (1-8) LED are driven directly from the IC’s pins. This is visible as the ring bus of 8 connections around the outer underside of the PCB. Connections to this bus are made via through-hole-plated-vias, two of them in each case to provide redundancy in case of a hairline crack in the plating. Through this arrangement, the controller (likely) alternates through each anode with the cathode set to the corresponding values in a cycle at a high rate (>50Hz) which appears to the eye as a solid output. This arrangement thus drives up to 64-LEDs (only 60 used) using 16 GPIO pins.

But instead of stopping there, it seems that they got a little more value out of it, by also using a multiplexed 4-digit 7-segment display with its cathodes also connected to this ring bus. Thus, this means another 4 anodes need to be cycled through to make the 7-segment display, bringing the total to just 20 GPIO pins to get the 60 LEDs and 4 x 7-segment displays running.

Such efficiency is required to provide the other features – for example, the broken out SPI interface which costs another four pins, a UART interface for the Bluetooth module, which costs another 2 pins, the buzzer which probably costs one more, and the three push-buttons which cost another three pins. Add to that, the crystal reference for another two pins, the power rails which is another two pins and the pin tally is already up to 34 pins. Of course, I’m not aiming to account for every pin here, as some of them are bound to be special function reserved pins, but we can see it makes a decent effort to use up all of them.

So lets quickly work out just how many solder joints are needed for this kit:

Surface Mount Solder Joints
13 transistors = 39
6 capacitors = 12
31 resistors = 62
Subtotal = 113

Through-Hole Solder Joints
60 LEDs = 120
1 capacitor = 2
1 buzzer = 1
1 header = 6
3 switches = 12
1 temperature sensor = 3
1 display = 12
2 crystals = 4
1 RTC IC = 8
1 battery holder = 2
1 microcontroller = 40
1 USB port = 7
Subtotal = 217

Grand Total = 330 solder joints

Construction Experience

Things are almost always better in the write-up, but in reality, I didn’t discover the construction instructions until after I had finished. Instead, I decided to do things the way I felt was sensible – which did make some things harder for me. However, I was consciously aware that due to the kit having components which covered the solder pads of others, incorrect construction order will make construction impossible.

As I disliked asymmetry, I removed the edge bits leaving me a circular PCB to work with. As the SMD components are a pressure point, I started with them first, as the kit wouldn’t work without that part conquered.


The result is not the neat result you might expect from a production line, and that’s because it was just hand soldered with a single iron and a set of tweezers. No hot air gun was used.


Because of the sketchy information I had, I decided to mount all components of one type first, which allowed me to effectively narrow down the possibilities until they were obvious. The next part is to complete all the through-hole components. The LEDs are probably a good candidate, as the other components within the ring will make access a little difficult, then mounting the sockets, crystals and battery holders is necessary before mounting the 7-segment display. Then it’s just a simple case of mounting the rest.


This is with all the components mounted but not quite finished. In this case, the protective LED display film can be peeled off.


And of course, the chips can be mounted, the protective cover off the buzzer can be removed and a battery can be installed.

At this point, a few comments can be made. The rear LEDs come quite close to the ring bus of traces, and when clipping the leads, you should take extra care not to gouge the tracks. I had nicked the solder resist in a few places, so that definitely needs some care. The RTC crystal has a can “grounding” pad which can be soldered to as mechanical support for the crystal. The LED display is rather difficult to solder into place once the required components are mounted due to restricted access due to battery holders and sockets coming into close proximity – try not to melt them by accident. The 40-pin IC holder provides clearance for the crystal, so needs to be installed, but alternatively the crystal might also fit on the other side of the board. The mini-USB connector protrudes outwards from the rear and looks a little squashed. Its legs are slightly short, so make sure the solder flows through well. Lastly, straighten out the legs of the chips, insert them, and we’re ready to go.

2016110914509149 2016110914509148

For users with the edges still intact, they can install the supplied nylon screws and standoffs to allow for easier mounting or standing on a flat surface. However, as the USB port protrudes vertically from the rear, and the cable connector has some bulk to it, it’s unlikely such a device would stand nicely on a table supported by its edges.

Ultimately, as I was working quickly, the kit took me about two to two-and-a-half hours to complete, again roughly two-solder-joints-per-minute. The kit did not have a single spare component, which indicates perfect packing, but also potential disappointment if you should be so careless as to let a tiny SMD component “fly away”.

Initial Set-up

Getting things going is as simple as plugging it into a USB port for power. The RST button activates a reset which restarts the program on the microcontroller. MODE toggles through each time-setting feature (year, month, day, hour, minute) with PLUS allowing you to increment values when setting. By default, the 5-minute LEDs are constantly lit, and the display cycles between time, temperature, year, date.

2016110914529152 2016110914539154 2016110914539155 2016110914539156

Outside of the setting mode, the PLUS key allows you to toggle the LED ring display modes. Quite a few modes are available, some of which follow the seconds and others are just decorative and potentially seizure inducing effects.

2016110914539157 2016110914539158

There really isn’t much to set, at least not via the included buttons. I did not attempt to see what is available over the Bluetooth/UART interface. Because of the use of the back-up battery for the RTC, the power can be unplugged without losing the time, which is nice.

However, this kit comes with a nasty surprise – an hourly “chime” that isn’t so much a chime but a loud and shrill beeping in the ten-or-so seconds before the hour. It’s very loud, annoying and I couldn’t see any easy way to turn it off, save for desoldering the beeper itself. Maybe a program modification is needed …


This is another low-cost microcontroller-based kit which used a lot of LEDs. It’s quite bright, although its practicality is slightly limited by the shrill hourly beeping. However, it does work as advertised, but requires extreme care during assembly due to the non-trivial number of surface mount components and some close proximity between through-hole components. Construction order also matters, and no spare parts are provided. It is also a fairly substantial effort, like a small endurance test, to solder up so many joints.

However, I did take the challenge, and I ultimately succeeded in the end, surprising myself with the surface mount components. The reward is a clock, a doomsday clock, completed just before the U.S. presidency was announced. Rather unexpectedly … it seems to suggest our time might well be up … and an apocalypse is on the horizon … unless I’m reading it wrong.

About lui_gough

I'm a bit of a nut for electronics, computing, photography, radio, satellite and other technical hobbies. Click for more about me!
This entry was posted in Electronics and tagged , , , , , . Bookmark the permalink.

3 Responses to Project: AT89S52+DS1302-based LED Clock Kit (EC1204B-Equivalent)

  1. zoomx says:

    It seems that bluetooth is uded to sincronyze the clock to a smartphone

  2. dAcson says:

    Thanks a lot for the FW dump. I build my clock yesterday and it always froze during the short blink of all LEDs on power on. The last 4 LEDs stayed on and nothing else happened. No display on the 7-segment display.
    Checked the soldering and all components (shorted quartz, manual multiplexing, DS1302 externally on Arduino, …) and everything was fine. Only option was a problem in the MCU.

    So, now i flashed your FW dump with avrdude and a modified ArduinoISP sketch (for AT89S52) and the problem was solved. It must have either been a problem during the factory programming or the ROM somehow got corrupted.

    However, thanks again for providing the dump! My next best option would have been to write an own firmware for it (which i might still do sometime), but for now i am glad that it works. πŸ™‚

    If someone has the same problem, here is some information on how to flash the AT89S52 with a modified ArduinoISP sketch and avrdude (sketch config for AT89S52 included in link):

    I used avrdude v6.3 (from the ArduinoIDE tools). An older version, that came with WinAVR (v5.1) had syntax problems with the config file.

  3. jayRC says:

    Thanks for the firmware dump. As built, my clock was only partly worked. It showed time on the 4-digit display, and seconds on the 60 leds, but the mode select did not work. Reloading your firmware fixed this (I’ve got the same programmer as you). How difficult would it be to stop the pyrotechnic scrolling of seconds, temperature, date, etc? It could make a useful studio clock if it simply displayed hours and seconds via incrementing leds. You have a great site, by the way, with lots of interesting ideas.

Error: Comment is Missing!