It’s email time – Make an “email clock”…. the more kb you get the more the clock ticks!

Technology
It’s email time – Make an “email clock”…. the more kb you get the more the clock ticks!

EmailMachine01.jpg
IT’S EMAIL TIME – Innocent-looking “clock” monitors the unread-message pileup in your inbox – by Tom Igoe.

I have a lot of anxiety about email. Every kilobyte in my Inbox destroys another minute of my life, but I can’t stop checking it. So I decided to embody my anxiety in a device that would worry about my incoming mail for me. I’ve always liked clockwork mechanisms, so I made my email fetish object in the form of a clock. For each kilobyte of new mail I receive, the clock ticks relentlessly forward.

Here’s the basic design I came up with. The clock itself is driven by a microcontroller, which connects to the internet and queries a program that checks my email accounts. The program reports back the number of kilobytes, and the microcontroller moves the clock forward a tick for each kilobyte. Simple!

To build this yourself, you need to know how to program a microcontroller and how to do some basic web programming. For microcontroller programming, see the Primer article in MAKE, Volume 04 (page 158), or my book Physical Computing: Sensing and Controlling the Physical World with Computers. For the web component, I used a Common Gateway Interface (CGI) script written in Perl, but you can also write CGI scripts in PHP, Python, Ruby, and other languages.

EmailMachine02.jpg

  1. Wires soldered to solenoid contacts. Note crystal at bottom and “mystery chip” under blob in center (Figure 1).
  2. Cheap battery clocks all generally work the same way (Figure 2).
  3. Rear view of clock, showing holes drilled in housing for Ethernet, power, and the USB-B port for programming the Arduino microcontroller board (Figure 3).
  4. Front view of clock, face removed (Figure 4).

MATERIALS

Here’s what I chose for the basic building blocks of my email clock.

Microcontroller I used the Arduino module (arduino.berlios.de), a small I/O board and development environment that’s built around Atmel’s ATMega8 microcontroller. Arduino is based on Wiring, another open and easy development environment, which uses the ATMega128 chip. I opted for Arduino because I knew I wanted to eventually make my own custom circuit board, and the ATMega8 is easier to solder than the ATMega128.

Serial-to-Ethernet Converter Instead of bothering to write my own TCP/IP stack for the Arduino board, I used some handy hardware: Lantronix’s XPort serial-to-Ethernet module. These modules can route data between an Ethernet connection and a serial port that feeds a microcontroller. To avoid some soldering, I also recommend the Cobox Micro, which has the same programming interface as the XPort (you simply telnet in) but a simpler physical interface.

Clock I would have loved to build a mechanical clock but didn’t have time, so I took the guts out of a cheap battery clock and connected its drive shaft into the hub of a clock-like antique test gauge.

EmailMachine03.jpg

System diagram. A CGI script queries my mail accounts and returns new mail volume. A microcontroller calls the script, and moves the clock’s hands forward accordingly.

Building It

I started by looking for the simplest way to drive the clock. I carefully took the clock apart and examined the circuit board inside. There was a mystery chip in the middle, sealed in plastic but I found that the main gear of the clock, which drives all the other gears, is controlled by a solenoid. The two solenoid terminals were pretty easy to spot, and I figured that all I’d have to do was send a pulse through these connections, and the clock would tick happily away.

I soldered a couple of leads onto the solenoid contacts and put the clock back together. Then I pulsed the solenoid directly with 5VDC power, bypassing the mystery chip. The motor jumped, but the clock didn’t tick. Clearly, there was more to learn, so I put the clock’s battery back in and connected the leads to an oscilloscope to see how the voltage changed as it ticked. The pattern was more complex than I expected. Each second, the pulse would alternate: high-low-zero one second, and low-high-zero the next.

I programmed the microcontroller to duplicate this pattern, and fed its output into the clock. This took some experimentation, but eventually I got the microcontroller to control the clock pretty well. Each tick it generated moved the clock forward about two seconds. Since I wasn’t concerned with keeping actual time, this was fine.

The next step was to get the microcontroller to check mail. The XPort needed only three wires connected from the microcontroller side: serial receive, serial transmit, and a reset connection to allow the microprocessor to restart the port. Making a circuit board for the XPort was a challenge because its pins don’t follow a 1/10" grid, the hobbyist perfboard standard. So I used CadSoft’s Eagle software to design a custom board to mount the module into. You can find the layout file at tigoe.net/emailclock.

Then I configured the XPort from my laptop through a USB-to-serial converter cable. Following Lantronix’ instructions, I gave it an IP address, gateway address, and subnet mask. I also configured the serial port settings.

I opened a terminal window, telnetted into the XPort, and entered “Hello World!” to confirm that messages were passing through. Then I quit telnet and tried connecting to my web server by entering its numerical address (port 80) in the serial window:

C82.165.199.37/80.

The XPort confirmed by returning a “C”. I responded with an HTTP request for a web page on my server, http://tigoe.net/pcomp/index.shtml:

GET /pcomp/index.shtml HTTP/1.1
HOST: tigoe.net

The server returned the HTTP header and contents of the requested page:

HTTP/1.1 200 OK
Date: Tue, 13 Dec 2005 20:50: 27 GMT
Server: Apache/1.3.33 (Unix)
Transfer-Encoding: chunked
Content-Type: text/html
<html>
<head>
... and so forth.

Success! Seeing this exchange of HTTP (Hyper Text Transport Protocol), the normally hidden language of web browsers and servers, meant that I had gotten the XPort to perform as a browser. Now I just had to get the microcontroller to do the same: open a net connection, request a page, and read the results. You can find my code to do this at tigoe.net/emailclock. I uploaded the compiled firmware from my laptop via the Arduino’s onboard serial-to-USB converter.

The microcontroller isn’t requesting an HTML page — it’s calling a common gateway interface (CGI) script, also available at the link above, that checks all of my mail accounts, queries for the volume of new messages, adds the numbers up, and sends the total back to whoever’s asking. Since this script isn’t expecting to be called from a browser, it doesn’t format its results as HTML. To minimize the programming needed on the microcontroller side, it keeps things simple, returning just the HTTP header and one line of text:

<KB: 1234>.

Once the whole system was working, I found a housing for the clock: a nice, antique piece of electronic test equipment with a hole behind its clock-like face that could accommodate a drive-shaft. The clock shaft screwed in easily, and the Arduino module and the XPort fit snugly inside. I drilled a couple of holes in the back for the power and Ethernet cables, and the clock was done.

How well does it work? I still check my email compulsively, but for the couple of hours it took to build this clock, I didn’t open my mail program at all!


Tom Igoe heads the physical computing area at the Interactive Telecommunications Program at New York University.

References:

http://arduino.berlios.de

http://tigoe.net/emailclock

http://tigoe.net/pcomp/index.shtml

make06sma.jpg

From MAKE 6 – Page 117. To get MAKE, subscribe or purchase single volumes.

Discuss this article with the rest of the community on our Discord server!
Tagged

current: @adafruit - previous: MAKE, popular science, hackaday, engadget, fallon, braincraft ... howtoons, 2600...

View more articles by Phillip Torrone

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK