Introduction: BookClock - Arduino-based Clock in a Cardboard Box

Picture of BookClock - Arduino-based Clock in a Cardboard Box

This is the most recent (and cheapest yet) member of the Wise Clock family.



(As a quick recap, the other members of the Wise Clock family are, so far, the glass-domed Wise Clock and Wise Clock 2. They are "wise" because, along with the time, they also display quotations.)

This clock is made with just three major elements:
1. Wiseduino (with RTC and EEPROM on board);
2. 8x32 LED matrix display from Sure Electronics;
3. cardboard box as enclosure.

A few other required components are:
- a tilt sensor (or tilt ball switch);
- a USB cable, to power the clock.

Step 1: Assembling Wiseduino

Picture of Assembling Wiseduino

Wiseduino is an Arduino clone with an on-board real time clock (DS1307) and EEPROM (24LC256).

Wiseduino can be bought as a kit here. The kit contains the following components:
- PCB (black);
- ATmega328P microcontroller programmed with the bootloader;
- 28-pin socket for the ATmega328P chip;
- 16MHz resonator for the microcontroller;
- DS1307 real time clock, with 8-pin socket;
- 24LC256 EEPROM, with 8-pin socket;
- 32768Hz crystal for the RTC;
- CR1220 coin battery and battery holder;
- 6-pin right angled male header (FTDI connector);
- 40-pin female header;
- 4 resistors 10K;
- 4 decoupling capacitors 100nF;
- 2N2222 transistor;
- power micro switch;
- 2-pin polarized male header (power connector);
- power jack with cable.

To assemble Wiseduino, follow these mini-steps:

1. Solder the IC (integrated circuits) sockets first. Place them correctly, so their notches match those in the silkscreen.
(This will be helpful later, when the ICs are to be inserted into their respective sockets; their notches should match those in the sockets, which match those in the silkscreen, got it?)
2. Solder in place the battery holder. (photo 1)
3. Solder the power connector, then the FTDI connector. (photo 2)
4. Solder the micro switch on the pads. Since this is an SMD (surface mounted device), use this technique: put some solder on one of the pads; place the switch over the pads, then solder the pin which is over the "loaded" pad. Once in place, solder the remaining pins.
5. Solder the four identical (10K) resistors in their places. These are the only resistors on the board.
6. Solder the four decoupling capacitors. Again, they are the only capacitors on the board.
7. Solder the 15MHz resonator.
8. Bend 90 degrees the 2 pins of the small cylindrical crystal (32768Hz), then solder it so it is parallel and close to the board. (photo 3)

At this point, we would have a few more steps to a complete assembling. But, for this project, we don't solder the female headers and neither the transistor.

What is left to be done is:

9. Insert the integrated circuits in their respective sockets, matching the notches (as mentioned above).
10. Insert the coin battery in its holder.

Next, we need to "hack" Wiseduino a bit, to install the tilt switch and to solder the ribbon cable for the display.

Step 2: Modifying Wiseduino

Picture of Modifying Wiseduino

At this point we need to modify Wiseduino to include the tilt switch, and also to accommodate the ribbon cable that goes to the display.

Let's start with the ribbon cable.
First, we need to cut the traces to D0 and D1, close to the header. The position of the cuts is indicated with a yellow arrow in photo 2. (These two traces are the first two from the top of the board.) Once D0 and D1 in the connector are disconnected from the microcontroller, we will re-connect them to Vcc (5V) and GND, respectively, by soldering two wires as shown in photo 3.

Next we will solder the ribbon wires themselves, in the holes intended for the female (extension) headers.
These are the wires that need to be soldered (the red wire of the ribbon is numbered as 1):
- wire 1 to D8;
- wire 5 to D7;
- wire 7 to D6;
- wire 15 to D1 (which became connected to GND earlier);
- wire 16 to D0 (which became connected to Vcc earlier).


For the tilt switch, two mini-steps are required:
a. Solder a 10K resistor between A0 (analog 0) and Vcc. In my case, the closest Vcc was pin 8 of the DS1307;
b. Solder the tilt switch between the same A0 (analog 0) and GND, making sure the cylinder is at a 45 degree angle to the board. Thus, when the board is laying, the ball in the tilt switch makes contact between the 2 pins. When the board is standing, the ball drops to the other end of the cylinder (that does not have wires), leaving the switch's contact open.
This is illustrated in photo 4.

At the end of this step, the board should look like the one in photo 1.

You can now insert the connector of the ribbon cable into the LED display. Make sure that on the display, the switch no. 2 is in the ON position and the three others are in the OFF position.

Step 3: Programing Wiseduino

Picture of Programing Wiseduino

The code library, tested with Arduino IDE 18, can be downloaded from here.
The content of the zip file is shown in the photo 1.

NOTE: An FTDI cable (or FTDI breakout) is required to upload sketches to Wiseduino.

There are three mini-steps to program the clock.

1. First, we need to set up the real time clock. (photo 2)
Load ds1307_test.pde and, in setup(), modify the lines that send the "set time" command.
Compile, then upload the sketch. The first time thisk sketch runs, it will set the real time clock to with the given hour, minute etc.

2. Second, we need to load the quotation file to the external on-board EEPROM. (photo 3)
Next, load eeprom_quotes.pde sketch, compile it and upload it. At this point Wiseduino is waiting to receive characters on the serial port. To send the characters, run (double click on) WriteFileToCom.vbs. This is a VB script that reads the content of the quotes.txt file (provided in the zip) and sends it over the serial port. Make sure that the line referring to quortes.txt specifies the correct absolut path. At a baud rate of 9600, it will take about 10 minutes to transfer the whole file (and write it to EEPROM).

NOTE: The VB script is intended to be used on Windows.

3. Third, upload the main sketch that reads the status of the tilt switch and displays the time and the quotations. (photo 4)
Load the BookClock.pde, compile and upload. This sketch contains the actual code that reads the EEPROM and RTC and displays the quotations and the time.

Test the sketch by tilting the switch one way or the other and notice how the display changes based on the orientation.

Step 4: Building the Cardboard Enclosure

Picture of Building the Cardboard Enclosure

Find a cardboard box that fits the LED display on the "spine" side (as if the box would be a book standing).

The box I used is one from adafruit, used for shipping kits/components.

Cardboard is easy to cut with an xacto knife. Draw the contour of the LED display (photo 1), then cut along the lines (photo 2). The opening should fit the display snuggly (photo 3 and 4). Then use some tape (I used electrical tape) to stick it to the inside of the box (photo 5).

Step 5: Encasing the Electronics and Powering Up

Picture of Encasing the Electronics and Powering Up

With the LED display in place, we need to stick the Wiseduino board to the bottom of the box somehow. For this purpose I used velcro with sticky tape on the other side (can be bought at dollar stores).

We will power BookClock through a USB cable, preferably at least 5 feet long (so I power socket is always within reach).
Cut the "type B" or "type miniB" end of the cable, leaving the cable with the "type A" connector (that gets inserted into the computer's USB port).

Now cut (using the same xacto knife) a small opening for the cable, on the side opposite to the display, as shown in photo 1. Insert the cable through the hole.

Separate the inside wires so that the red and black ones are accessible, then solder each one to the corresponding red and black wires of power cable coming with Wiseduino (photo 2). Insulate the soldered connections with electrical tape.

To secure the cable, place a wire-tie around the cable and on the inside, close to the hole, as shown in photo 3 (bottom left corner).

To power up, plug the USB cable in either the computer's USB port or in a USB power adapter, the kind used for charging iPhones/iPods (can be bought on ebay for less than US$2), shown in photo 4.

The BookClock is now ready to use and show.

Comments

iskandarz (author)2013-05-05

hai florinc, i try the first step, but there are too many erors :
http://www.mediafire.com/view/?i3wwnxzi4nktv5j

In file included from ds1307_test.pde:3:
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:51: error: 'boolean' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:52: error: 'boolean' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:53: error: 'boolean' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:57: error: 'byte' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:58: error: 'byte' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:59: error: 'byte' does not name a type
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:60: error: 'byte' has not been declared
C:\Users\bejad\Documents\PA Andre\arduino-1.0.4\libraries\ds1307/DS1307.h:63: error: 'byte' does not name a type
ds1307_test.pde: In function 'void setup()':
ds1307_test:13: error: expected `;' before 'RTC'
ds1307_test.pde: In function 'void loop()':
ds1307_test:50: error: 'class DS1307' has no member named 'get_sram_byte'

what should i do ?

Conflagration (author)2012-12-28

Thanks, that solved it! I was having issues with a faulty arduino software installation as well.

I do have another question though, in that the VBS script is giving me a "permission denied" error, on line 12, despite having the correct COM port and quote file location specified. The serial monitor is closed as well. Do you have any suggestions? Sorry to plague you with questions.

florinc (author)Conflagration2013-01-13

Sorry for the late reply, I just saw your question now.
If you did not solve that yet: if the COM port is higher than 9, you need to address it like "\\:\\COM10" (if I remember correctly; google microsoft site for this naming convention).

Conflagration (author)florinc2013-01-13

I'm using com3, so that shouldn't be any issue. the line of code I'm using is:
"Set com = fso.OpenTextFile("COM3:9600,N,8,1", ForWriting)"
Any obvious issues there?

florinc (author)Conflagration2013-01-14

Nothing obvious. It should work on Windows XP. What OS are you using?

Conflagration (author)florinc2013-01-22

I'm using Windows 7, maybe that's what's causing the issue? Thanks for your help.

florinc (author)Conflagration2013-01-22

Maybe. Windows 7 requires admin rights when accessing stuff (even to copy files to the root of C:\, from what I saw).

Conflagration (author)florinc2013-01-22

I do have an administrator's account, would there be anything more required to enable it?

florinc (author)Conflagration2013-01-22

Honestly I don't know, since I don't use Windows 7. Did you google the issue on Microsoft site?

Conflagration (author)2012-12-26

For step #1, assuming you mean before "#include ," what exactly should I add? I am a little confused.

florinc (author)Conflagration2012-12-27

Sorry, I thought I revisited what I wrote before hitting "Save" (the editor may have removed the angular brackets). #include Arduino.h, that's what I meant, with arduino.h between angular brackets (less then, greater then).

Oh, I think the issue is that the code doesn't show up on instructables. What I meant to ask was what to include before the include "wire.h" where the quotes are the include symbols.

Conflagration (author)2012-12-26

I'm trying it with a windows partition on my mac, except I think the latest version of the arduino software is giving me issues. I'm not able to upload the eeprom_quotes files, I get errors saying "'Wire' was was not declared in this scope," and "as of Arduino 1.0, the "byte" keyword is no longer accepted, please use Serial.write instead"

Any idea how to get around this? Thanks for your help!

florinc (author)Conflagration2012-12-26

That sketch was written for Arduino 18. To make it work with Arduino 1.0, here are the changes you have to make (I tested them):
1. Add the line #include before #include
2. change all "Wire.receive" to "Wire.read"
3. change all "Wire.send" to "Wire.write"
4. delete the second argument in function "Serial.print" (e.g. BYTE, DEC).
I hope this helps. Let me know how it goes.

Conflagration (author)2012-12-23

Is there a workaround for uploading the quotes file on a mac?

florinc (author)Conflagration2012-12-24

I never used a mac. If you don't have access to a Windows machine, please contact me and I will get one EEPROM written for you.

florinc (author)2010-12-04

girino2n,
You are right, a header file (ht1632.h) is missing from the zip. It worked for me because I had it somewhere else, and the compiler picked it up from there.
Please send me an email (you find the address on my blog: http://timewitharduino.blogspot.com/) and I will send it to you. I will also upload it to my source code repository.

Sidney Floyd (author)2010-12-02

when I try to upload the main BookClock sketch i get a compile error

'HT1632_ID_CMD' was not declared in this scope

This error occurs on line 160 of BookClock.pde
Any idea what gives?

girino2n (author)2010-10-19

BookClock.cpp: In function 'void ht1632_sendcmd(byte)':
BookClock:159: error: 'HT1632_ID_CMD' was not declared in this scope
BookClock.cpp: In function 'void ht1632_clear()':
BookClock:178: error: 'HT1632_ID_WR' was not declared in this scope
BookClock.cpp: In function 'void ht1632_senddata(byte, byte)':
BookClock:201: error: 'HT1632_ID_WR' was not declared in this scope
BookClock.cpp: In function 'void ht1632_setup()':
BookClock:214: error: 'HT1632_CMD_SYSDIS' was not declared in this scope
BookClock:220: error: 'HT1632_CMD_COMS10' was not declared in this scope
BookClock:223: error: 'HT1632_CMD_MSTMD' was not declared in this scope
BookClock:224: error: 'HT1632_CMD_SYSON' was not declared in this scope
BookClock:225: error: 'HT1632_CMD_LEDON' was not declared in this scope