Friday, November 6, 2015

26: A More Secure Breadboard Setup for Particle Photon or Arduino Nano
-- revised: Nov 25, 2015 --

I hate 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, 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 spring clip -- Sorry, not reliable (and not very useful, otherwise)!

I'll probably mount the whole setup on an about 8" square of 1/2" plywood, screwing the breadboard and connectors to the board. There should be room left for a 4-switch relay.

Monday, November 2, 2015

25: Particle Cloud vs. Daylight Savings Time

Clock time is important to my "live" Photon system (see posts 20, 23). Imagine my surprise in finding the time off by an hour on Nov. 1. Sloppy me. Particle Docs is explicit that the 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 (value 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/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.

Friday, October 9, 2015

24: More Photons

I received 2 more Particle Photons this week. Seems like a bargain: $19 each plus $6 shipping, 12 day USPS delivery.

I had no trouble getting them setup using the iPhone App. I now have a total of 5 Particle devices: 1 Core and 4 Photons.

I succeeded in remote updating my live system without a hitch. Why not. Even when the Photon was 2 feet away the recompile/download was going through the cloud. So what's a hundred miles?

But this doesn't mean I have no complaints. Software development is a bear. Compiler error messages only mean that you have made a mistake. They rarely, if ever, point out where the mistake was. My advice: write your programs a bit at a time.

Luckily, source programs for "smart controllers" are generally short.

Wednesday, October 7, 2015

23: About My "Live" Photon System

I've had a blogspot "comment" (question) about how I implemented the Photon control system at my granddaughter's farm (see post 21). Well, it's kind of complicated.

The program on the Photon is written in C++. It was initially only 80 lines of code but has grown to over 200 lines. It will probably get longer still. It has 2 main parts: 1) In the "loop()" all of the sensors are recorded in a Particle.variable, and time readings from the "cloud" control the electric fence and make sure that the water is not on for too long; b) a Particle.function can be called to change relays or override timed events.

I wrote a PHP program for the Internet interface. It is fairly complicated and only works because my hosting service is Linux-based and permits execution of the "curl" command to communicate with the Photon. Many servers would not allow this.

I also have a Raspberry Pi running Linux. I use the "crontab" scheduling program to check the status of the Photon. It is this Pi that can send e-mails or text messages if something goes wrong (hoop house too hot or cold, power failure, etc.).

Of course, the Photon's location has to have reliable wifi/Internet service. I had to add a wifi amplifier for my "live" system.

Sunday, October 4, 2015

22: Name Change

I'm going to change the name of this blog to--

dicks-Photon-Arduino.blogspot.com

-- because it's mostly about my Particle Photons. Duh.

Friday, September 18, 2015

21: Battery Backup, Revised Again
updated 9/26

After my failures with the Adafruit Powerboost 1000 (post 16), I complained at an Adafruit forum. Their response as  that I should have used a Powerboost 1000C instead. Note the subtly added letter "C". So, gritting my teeth, I paid $19.99 (plus their pricey shipping) and tried again.


I let this setup run for over 24 hours powering either a Raspberry Pi (drawing about .4 amps) or a Particle Photon (drawing 1/8th as much) and both worked fine. I could disconnect external USB without the computers noticing but pulling the battery plug caused both processors to restart. Not nice but not a deal killer.

Note the input power LED in the image. If you aimed a photo sensor at it, your program could detect external power failure. You would  then have time to send out a text message and shut down "gracefully" whatever that means.

Update: The setup ran a Raspberry Pi for over 2 weeks.