Tuesday, November 10, 2015

92: Stamp Out Loose Breadboard Wires
-- revised: Nov 25, 2015 --

I hate pulled-loose wires, also not fond of soldering. So, browsing Aliexpress I found 2 possibly useful devices: 8-wire screw terminal strips (I got 4) and a bunch of 2-wire spring clips.

Terminal Strip, Photon (imagine this with a T-cable from a Pi), Spring Clips

Anyway, I like both connectors. The screw strip is a tad over-kill. I probably won't run 220v through it. I particularly like the spring clips -- they are pretty strong. And flexible in number. And cheap: $1.30 for 10 pair.  REVISED: I tried getting more than 1 wire clamped in a single spring clip -- Sorry, not reliable (and not very useful, otherwise)!

Wednesday, November 4, 2015

91: Daylight Savings Time for "Smart Controllers"
(and why you should study cron)

Clock time is important to my "live" Particle Photon system. Imagine my surprise in finding the time off by an hour on Nov. 1. Sloppy me. Particle Docs is explicit that the provided Time.zone() function does not adjust for Daylight Savings.

Lucky for me, I have a Linux/Raspberry Pi to back me up. Here's a little shell script that can correct the time in my Photon program:

thisF=your-function-name
photon=1234... # your Photon's ID
accessT=5678... # your access_token
a=`date | sed -n 's/.* .\([DS]T\).*/\1/p'`
if [ "$a" != "ST" ] ; # previous WAS "DT"
then
  v=-5  # Standard Time (hours less than GMT)
 else
  v=-4  # Daylight Time
fi
# This can tell the Photon 
curl https://api.particle.io/v1/devices/$photon/$thisF \
 -d access_token=$accessT -d "args=$v"

Unix and Linux have a scheduling program called cron. And each user can have a personal set of scheduled programs accessed by the crontab app.. If the above shell code is in a file called "set-tz" then this crontab entry will execute it every Sunday in October, November and March:

# min hr dom mo dow command
...
0 3 * 3,10,11 0 sh set-tz

Read it as: 
"at zero minutes after the hour, 
3am, 
any day-of-month, 
March, October, November, 
Sunday,
Then execute set-tz."

Ugly, but looks isn't everything.