Microbit Digital Clock

by Thon321 in Circuits > Microcontrollers

2189 Views, 9 Favorites, 0 Comments

Microbit Digital Clock

IMG_20211031_104239.jpg

This is how we made a digital clock from multiple Microbits. The Microbits can either be powered separately and placed at a distance or powered together as a group and put on a board, which is what we did here. The Microbits communicate the correct digit over the built in wireless. The main Microbit communicates to the Real Time Clock (RTC) over Serial Peripheral Interface (SPI)

Supplies

5x Microbits

25x M4x40 bolts (we used panhead slotted brass bolts)

48x M4 Nuts, or more

1x DS1302 MH RTC clock module

1x AC97 audio connector from pc (or any 5pin connector with wires you can find)

1 2xAA Battery box plus batteries

Piece of plywood around 400x80mm

4mm drill bit

A drill

Something to cut and strip wire

Terminal crimps or pliers

Ring Terminals to suit wire size and minimum 4mm hole

about 1m of wire

duct tape, as what kind of a project doesnt include it

Order the Correct Real Time Clock Module From Ebay

s-l1600.jpg
s-l1600.jpg
IMG_20211013_191825.jpg

So this project didn't go very well to start with. The Microbits run from a 3v power supply. At first i ordered a DS1307 module (tiny RTC) and was going to solder the wires to the terminals make it nice and neat, only to discover that the DS1307 runs at 5v and uses 5v signalling. So without wanting to get in to converting it, i found a DS1302 which is happy to run at 2-5v, perfect. Although as with everything on ebay mine wasn't blue and had the pins at a different angle, oh well.

Wire Up the Microbits

IMG_20211013_191402.jpg

Although we are using radio to send the messages to the receiving microbits, they still need powering. Here we have the microbits wired up to the battery and RTC

Write and Test the Code

reciever.png
master.png
set pins.png

The basics of the the are ask the RTC for the time, Get the hour as HH, split it in to H1 and H2, do the same for MM but to M1 and M2. Broadcast over the radio the current value of of the time and repeat forever, until you want to set the time. Also add a changing image so that you know its working.

If you are writing the code out yourself you need the DS1302 extension for the RTC. You also need to reassign the SPI pins to 0 1 2 from 13 14 15 see the last image

The RTC is contacted over pins 0 1 2 so that the the holes in the Microbit can be used for mounting and communication at the same time. Same goes for the 3v and GND pins. You could if you wanted have the Microbits spread around a bit or have multiple hour and minute digits all over the place as it works over the radio.

Connector for RTC

IMG_20211013_200145.jpg
IMG_20211013_200258.jpg
IMG_20211013_200344.jpg
IMG_20211101_191755.jpg

Now on to the connector for the RTC header. We used a connector for AC97 audio from an old pc case. You need 5 pins in a line on the connector this on had 4 on one side, 3 on the other in a 2x5 configuration. So if you take a pin or small sharp object you can carefully lift the little black tabs and pull out the pins. then its just a matter of putting it in the other side to make a row of 5 cables that we can use. The extra bits of wire were trimmed off.

Mount the Microbits to a Board

IMG_20211013_192023.jpg
IMG_20211013_192916.jpg
IMG_20211013_193546.jpg
IMG_20211013_193833.jpg
IMG_20211013_191700.jpg
IMG_20211013_191704.jpg
IMG_20211013_194316.jpg
IMG_20211013_195303.jpg
IMG_20211013_195254.jpg
IMG_20211013_201125.jpg
IMG_20211013_201031.jpg
IMG_20211013_200037.jpg

First we lined up the Microbits on a piece of plywood and aligned them using a straight line, but it can really be at any position you like. Next take a pencil and carefully mark the holes in the Microbit on the board. cut the board to size, drill the holes and sand back to smooth. Mount the bolts and nuts on the Microbits then carefully insert them in to the holes. We had to loosen some of the nuts as the holes weren't drilled perfectly. We only ended up using 2 nuts to stand the Microbits away from the board as it was too fiddly to get everything tightened up and working. Using some crocodile clips we were able to get power flowing though the bolts to the Microbits. The in the last picture you can see how we wired up the RTC to test it.

Wiring

IMG_20211031_100027.jpg
IMG_20211031_095047.jpg
IMG_20211031_100209.jpg
IMG_20211031_100256.jpg
IMG_20211031_104424.jpg

Using some off cuts of wire and ring terminals we first measured the distance the crimped on the terminals to make a loom to connect the 3V and GND bolts all together. The battery pack and RTC wires got the same treatment. All got bolted down the the nuts. You could probably get away with stripping the wires back and wrapping them around the bolts like in the previous step then testing the connections, but this is a little bit more robust. Duck tape was used to attach the RTC and the battery box as we couldn't find any adhesive foam pads anywhere

Setting the Time and ID

IMG_20211101_205829.jpg
IMG_20211031_104250.jpg

If the RTC hasn't been set a time yet or powered on it will just count from 00:00

First you need to set the Microbits to display the right digit depending on where they are. Each digit has a reference of (H1)(H2):(M1):(M2) so for 09:35 H1 is 0, H2 is 9, M1 is 3 and M2 is 5.

On each receiving Microbit pressing B enters ID mode, it will scroll 'SET ID' press A to cycle through each ID then A+B to set it

To set the time press A+B on the main Microbit, the one with the flashing heart. It will enter set time mode and wont send the time out to the digit microbits. On the digit microbits press A to increase the digit by one then A+B to set it. The main Microbit should scroll the full hour or minute to show that it has updated. Finally press A+B on the main microbit to restart the clock