Monday, November 28, 2016

50: Particle Cloud (Photon) Time Functions

PHP and C programmers, beware: day-of-week numbers start at 1 instead of Sunday==0. Also, there is no provision for Standard vs. Daylight time. At my granddaughter's farm, a Photon turns a powerful deer fence on and off. To keep from zapping workers, it is important that the schedule be reliable. I covered the Linux side of this at my Raspberry Pi blog ( post 91. Currently, (because of power-fail reboots) I execute a crontab statement every night at 4am (the code from post 91). If the UNIX/Linux world can keep the time change straight, then Particle could, too.

Saturday, November 12, 2016

49: IoT* for Farming

As I have mentioned in earlier posts I have put some Particle Photons to real work. Between them, my grandkids have 6 hoop houses (hoop houses are the plastic film version of the old greenhouses). So far I've only worked on one of them. I started out with a single Photon handling both the sensors and the switches. That was a mistake. The long-ish wiring runs were unreliable and the cables cost more ($90) than an extra Photon ($19).

So right now the 2 Photons work as follows:

Sensor-Photon: Connects to 2 soil moisture sensors**, 2 DS18B20 temperature sensors (stuck in ground for soil temperature), 1 DHT22 temperature/humidity sensor*** 3' off the ground.

Control-Photon: Keeps track of time, permits smartphone controls of 2 irrigation valves and a deer fence (enclosing 12 acres around the hoop house; normally on an automatic schedule, but can be overridden).

100 miles away, a Raspberry Pi running Linux keeps track of the Photons. This is mostly handled by tasks scheduled by the cron program. Note that I had planned to use a Raspberry Pi for all of this but the cloud access and Arduino-like ability with analog sensors made me choose Photons for the hoop house computers.

The main link to the Photons is a web page (optimized for smartphone) that reports on the sensors and allows control of the switches.

BTW: Turning things on and off requires login/password.

My next challenge is to provide web control for rolling up the sides of the hoop house. The hoop can be cooled by exhaust fans but that just runs up the electric bill. Rolling up the long sides of the house is effective and cheaper. My trial China-manufactured motors are being a chore to program (instruction manual computer-translated from Chinese?). This will be the main labor saver of my system, since the internal temperature will be controllable from a distance.

* IoT (Internet of Things): This term doesn't really work for me.

** To avoid shorting out, the fork-shaped sensors wiring had to be coated in non-conductive caulk.

*** As mentioned in earlier posts, apparently humidity sensors stop working at 100% RH (I've tried several kinds). I finally had to put the DHT22 in a box with a tiny fan blowing on it. It still quits working at 100% but recovers in a few hours.

Friday, November 11, 2016

48: Cloud Interface for Raspberry Pi

Among my "IoT computers" or "smart controllers"* (needs a better name) are 7 processors from Particle: 1 Core (now superseded by Photons), 5 Photons and 1 Electron.  Particle Photons are rather like souped-up Arduinos with built-in WIFI and cloud services. This cloud provides not only the expected variable/function and publish/subscribe services but other handy UNIX-like functions like date/time. Since the summer of 2015, I have had 2 Photons operating in the real-world in my farmer granddaughter's semi-automated hoop house. I had planned to use Raspberry Pi's for this but the Photon/cloud was just too handy. However, an RPi keeps track of things from 100 miles distance.

Anyway, back in August, I emailed support that they should provide their cloud interface for the Raspberry Pi. I was probably not alone in this. And now, I just signed up for their beta-test RPi cloud interface. It should be very convenient for me and even if 1% of the 10M RPi's sign on, it should be a good deal for Particle.

* I also have 4 Raspberry Pi model B (from earlyish to most recent) and 4 Arduino Nanos. To those not in-the-know, an RPi B is $35 (well, $50 with flash card, etc.); my Nanos cost $7 and Photons are $19. My Particle Electron (Photon with built-in cell modem) was time and $ wasted, for me.