Ice Tube Clock: Sync Clock with Router

by hkmaverick on Fri Nov 18, 2011 7:04 am

I have a tp-link 1043 router flashed with dd-wrt that runs 24/7. The Ice Tube clock is sitting infront of the router and I figured why not use the router to sync the clock since the router's time is already ntp sync'd.

The drivers and modded firmware are in the attachments. Do this at your own risk, I'll not be responsible for any damages!

What you'll need:
1. usb-to-serial TTL cable that uses the Prolific PL2303 chip
2. tp-link 1043 dd-wrt drivers for the usb-to-serial cable (usbserial.ko and pl2303.ko)
3. modded firmware of the Ice Tube clock (iv.hex)
4. Solder 2 wires to the clock, one to pin 2 (Rx) of the atmega168 and one to gnd
5. a bit of linux knowledge

Steps:
1. Plug the usb-to-serial cable to the router
2. load the router drivers, ssh to router then run insmod usbserial.ko then insmod pl2303.ko. if drives loaded ok, you'll see /dev/usb/tts/0
3. program the modded firmware (iv.hex) to the atmega168
4. connect the wire from pin 2 of m168 to tx (green wire on my cable) of usb cable. connect the wire from gnd to gnd (black wire) of the usb cable
5. ssh to the router, use stty to set baud rate to 19200, then run echo "T$(date + %H%M%S%d%m%Y)E" > /dev/usb/tts/0
6. the time+date of the clock should be changed to the router's
7. create a cron job on router to do the above periodically, i.e. daily etc.

Make sure the usb-to-serial cable outputs TTL levels and not RS232. If you connect RS232 levels directly to the m168 it will damage the chip. If you use RS232 levels you will need to use a level shifter (a MAX232 or similar).

The modded firmware accepts time+date data in the format "TXXXXXXXXXXXXE" at 19200 baud. So you can substitute the router for anything that outputs serial data in that format.

You can expand the mod by grabbing weather/financial data from the internet and then displaying it on the clock.

Enjoy!
Attachments
pl2303_for_1043nd_atheros.tar
drivers
(74 KiB) Downloaded 84 times
iv.hex
modded firmware
(26.3 KiB) Downloaded 138 times
hkmaverick
 
Posts: 4
Joined: Fri Nov 18, 2011 6:13 am

Re: Ice Tube Clock: Sync Clock with Router

by adafruit_support_bill on Fri Nov 18, 2011 8:01 am

Great hack! Thanks for posting :D
User avatar
adafruit_support_bill
 
Posts: 25416
Joined: Sat Feb 07, 2009 9:11 am

Re: Ice Tube Clock: Sync Clock with Router

by adafruit on Fri Nov 18, 2011 5:36 pm

Cool can you post a photo? We'd like to blog it but a photo with it on top of the router would make it really clear :)
User avatar
adafruit
 
Posts: 11506
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Ice Tube Clock: Sync Clock with Router

by hkmaverick on Fri Nov 18, 2011 11:01 pm

ok, there you go....
DSCI0589.JPG
DSCI0589.JPG (180.21 KiB) Viewed 2466 times
DSCI0587.JPG
DSCI0587.JPG (174.73 KiB) Viewed 2466 times


DSCI0586.JPG
DSCI0586.JPG (198.04 KiB) Viewed 2466 times
hkmaverick
 
Posts: 4
Joined: Fri Nov 18, 2011 6:13 am

Re: Ice Tube Clock: Sync Clock with Router

by hkmaverick on Thu Nov 24, 2011 10:57 am

oops, a typo in the "echo ...." command, should be %y lowercase instead of %Y:
Code: Select all
>echo "T$(/bin/date +%H%M%S%d%m%y)E" > /dev/usb/tts/0


here's the script i run on the router as a cron job:
Code: Select all
#!/bin/sh
echo "TE" > /dev/usb/tts/0
echo "TE" > /dev/usb/tts/0
sleep 2
echo "T$(/bin/date +%H%M%S%d%m%y)E" > /dev/usb/tts/0
echo "sync done" > /tmp/sync.txt


would it be useful if i add a bootloader to the clock, so you don't have to disassemble the case to flash a firmware?
hkmaverick
 
Posts: 4
Joined: Fri Nov 18, 2011 6:13 am

Re: Ice Tube Clock: Sync Clock with Router

by revnull on Thu Dec 15, 2011 10:03 pm

Is the source available for this mod? If possible, I'd like to see "under the hood". :D

Thanks!
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 9:06 pm

Re: Ice Tube Clock: Sync Clock with Router

by hkmaverick on Sat Dec 17, 2011 1:11 pm

source code? ok, everything you need to get it working is in the attached *.c file.

just add its contents to iv.c and place the function inside the main loop.
Attachments
synctime.c
(1.87 KiB) Downloaded 98 times
hkmaverick
 
Posts: 4
Joined: Fri Nov 18, 2011 6:13 am

Re: Ice Tube Clock: Sync Clock with Router

by revnull on Sun Dec 18, 2011 1:31 pm

Great, thanks!
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 9:06 pm