[Fatjedi007] recently acquired three programmable boxing gym-type clocks to help his developmentally disabled clients manage their time. The plan was to have timers of varying lengths fire at preset times throughout the day, with the large displays providing a view from anywhere. Unfortunately, the clocks were not nearly as programmable as he needed them to be.
Since he’d spent enough money already, [Fatjedi007] turned to the power of Raspberry Pi to devise an affordable solution. Each clock gets a Pi Zero W and a simple IR transmit/receive circuit that operates using LIRC. The clocks came with remote controls, so it was just a matter of re-programming them. From LIRC, he wrote some scripts with SEND_ONCE and schedules the timers with a cron job. No need to get out the ladder—he can program all of them from his chair over VNC.
He does have one problem, though, and that’s getting the Zeros to set themselves over NTP with static IPs. Do you have any suggestions? Put ’em in the comments and help a Jedi out.
LIRC is pretty handy for anything you want to control remotely, like a stereo system.
I’m all for microsecond precision on wall clocks, just open up port 123 for connections from the local network and rate limit it if you are scared of something, or just fetch the time someother way e.g. http:
curl -sI www.redhat.com google.com microsoft.com|grep Date:
Date: Mon, 23 Apr 2018 07:29:18 GMT
Date: Mon, 23 Apr 2018 07:29:18 GMT
Date: Mon, 23 Apr 2018 07:29:18 GMT
And then
date -s "Mon, 23 Apr 2018 07:29:18 GMT"
Let’s combine those two! :D
“`
#!/bin/bash
date -s “$(curl -sI hackaday.com | grep “Date:” | tr -d ‘Date: ‘ | tr -d ‘\n’ | tr -d ‘\r’)”
“`
Did not work as expected
pi@pi10:~$ curl -sI http://www.redhat.com google.com microsoft.com|grep Date:
Date: Mon, 23 Apr 2018 11:56:34 GMT
Date: Mon, 23 Apr 2018 11:56:35 GMT
Date: Mon, 23 Apr 2018 11:56:33 GMT
I’ve got an ever better one:
curl -sI http://www.redhat.com google.com microsoft.com|grep Date:
Date: Mon, 23 Apr 2018 12:12:40 GMT
Date: Thu, 19 Apr 2018 11:14:01 GMT
Date: Mon, 23 Apr 2018 12:12:39 GMT
Don’t think anybody would want to set their clock after that XD
htpdate does what you want.
*I* don’t want anything, I was just trying out the command from a previous poster ;)
I would to buy, a gps clock , cheap and low consumption of power.
GPS is not known for terribly good reception indoors though. Depending on the surroundings the clocks might never get a good enough lock to sync the time…
I have outdoor termometer and screen inside. why trouble making similar?
And how would that be easier than a clock with ntp sync? At least that wouldn’t require two parts that are either connected with a cable (which could be annoying through a window) or a wireless system (at that point, why not just use the WiFi from the raspberry pi). I fail to see how your solution would be an improvement to the system in the article…
Can we please, officially, put to rest the “easy as pi” pun. It’s played out, IMHO
Why is there thought to be rocket science involved in getting NTP to work with a static IP setup?
I’ve had problems with static IPs on the RaspberryPi as well.
Turns out Raspbian didn’t like me editing /etc/network/interfaces like normal, and I ended up having to add my static IP setup into the file /etc/dhcpcd.conf
Hope this helps!
I usually find that it’s easier to assign fixed IP addresses at my DHCP server, usually my wifi router.
Two cautions. It’s by MAC address, so if you swap the SD card to another Pi, you’ll have to adjust that. Also, if you connect via wifi rather than LAN, that’s another MAC address as well.
There is gotcha built in to the Pi clock-setting. Network time won’t reset if the fake clock too far off from that. Use this to override that limit:
sudo ntpd -q -g