Monday, April 18, 2016

37: Raising an "Exception" in a Particle Photon or Electron

Let's say that that you have a remote Photon that is monitoring a temperature sensor and it reads a value that is out of range (too hot, too cold, whatever). I have a Raspberry Pi Linux system (could be any other Unix or Linux computer) that needs to be notified. One way would be for the Linux system to "ask" (i.e., "poll") the Photon every few minutes for the current temperature value and then to test for out of range for itself. A plausible action would be to send a text message to a (hopefully) responsible human.

A better procedure would be for the Photon to decide what is out of range and to send an alert message directly to the Linux on its own. The Particle programming interface offers a neat way to do this between that Photon and another Particle device. The sending device "publishes" a uniquely named message (up to the "cloud") and the receiving device can "subscribe" to it. Note that Particle has gone and gotten metaphorical on us: overloading the words "publish" and "subscribe" with new specialized meanings.

This is good for Particle Photons or Electrons but the interface to a Linux doesn't seem so straightforward. Linux/Unix systems like to receive this kind of message by reading a named device. So, until Particle provides such an interface, the simple solution is to publish/subscribe between 2 Particle devices and have the receiving computer pass the data on through the USB cable. In Linux shell this statement could record the message;

$ my-pgm </dev/ttyACM0 # program "hangs" waiting for data

Note that the single subscribing device could be used to receive messages from several publishing devices. And these could be either Photons or Electrons. The Photon receiver would cost a negligible $20.

Wednesday, April 6, 2016

36: Early Experiences with the Particle Electron
-- Revised 4/16/2016 --

See https://docs.particle.io/guide/getting-started/intro/electron/ for a full description. But, briefly, the Electron communicates with the cloud via cell service instead of wifi & your Internet connection. Also, it's costs more than the $19 Photon ($80 for the developer setup). In addition, you need to have cell service -- starting at $2.99/mo (initial 1MB).

I hadn't bought in to the Kickstarter campaign so I waited a while for my first unit. See post 32. In a single day I managed to break it twice: first I mangled the tiny brass antenna socket (but I repaired it with the help of a strong magnifying glass). Next, I broke the USB plug off the board -- I was moving the Electron around trying to get it to connect to cell service & pulled too hard on the cord (Warning: not very hard). BTW: Particle did not give me a replacement.

Irksome. But I thought I still needed the cell-connection feature. So I ordered another one. Quick delivery. I'd learned a couple lessons (you can, too): I was patient and got the antenna connected at the cost of only 15 minutes of teeth-gnashing. Then I taped the whole setup to a board and used a USB extension cord so I never have to plug/unplug directly to the Electron's socket.

Programming is nearly the same as the Photon (there are some Electron-only cell service functions). But here's a few differences: I have pretty reliable AT&T cell service (2 or 3 of 5 bars on my phone). But while a Photon connects to my wifi in a couple seconds the Electron can take 1 to 5 minutes (thats what led me to break my unit #1). Also, it appears to me that orientation of the provided antenna matters. When the antenna is lying flat (edge on to the signal) connection is less reliable than if the upright (flat on to the signal). I've written a C++ program to test this & I'll post the results.

REVISION/ADDITION
I haven't had a lot of joy with the Electron. The place I was going to install a few appears to have good FreedomPop cell modem service. Current price is: Modem $0, 1 GB LTE data/month $15. Particle Photons are $19 (plus cell modem), Electrons $69.

My test program was no fun. I wasted most of my month's data just trying to download versions of the code (download often failed but data was used, anyway). Downloading via USB seldom worked.

Also: I sometimes get the blinking red light "hard fault" signal. Hard fault is not explained. Lately I've had a LED signal not described in the online Docs. The usual sequence when you power up a Particle device is--

1. blinking green (looking for signal)
2. blinking blue (signal found, working on logging in, etc. -- this reminds me of dogs sniffing each other's butts)
3. breathing cyan (you are in!)

-- but in my case it's solid cyan (not useable).

Tuesday, April 5, 2016

35: My Arduino Nanos

I currently have 4 fully working Nanos. I recently installed one in a real-life situation for one of my granddaughter-farmers. At the time this left me with only one that I could download new code to. So I ordered 2 more cheap ones ($7 and change each). When they arrived they seemed to be working but the Coolterm app on my Mac couldn't detect their USB ports. I tried downloading a new driver and when that didn't work I send them back (too much trouble for the price). Unfortunately, I'd done the cheap Nano bit before ($3 each that time). Those 2 also didn't play nice. When will I learn? I now have a price point that maybe helps. I replaced the latest non-working pair with 2 from Sainsmart (via Amazon) for $12-ish each. They work fine.

I also have a Nano that Coolterm "sees" but which fails half way through downloading code from the Arduino app. So, essentially broken. And, I have literally burned 2 out through wiring mistakes. Best not to reverse connecting to VIN and GND (right next to each other, 2.5mm apart).

So, I bought 10 Nanos & have 3 working. You could probably do better.

Thursday, March 24, 2016

34: A Real Installation -- Practical matters

Some things I've learned since I first installed a Photon system in My granddaughter's 100' x 30' hoop house last summer:

1. The environment is tough. The temperature swing in a single day can be over 50F. Humidity often approaches 100%. UV attacks plastic, e.g.: the heat-shrink tubing over the wire splices.

2. I have wire runs over 70'. I've learned to use only stranded wire: solid conductor can break -- and it has.

3. I used a single Photon ($19) in the hoop. It's backed by a Raspberry Pi 100 miles away. Attached to the Photon are 3 temperature sensors, 2 soil moisture sensors, plus switches for an outside deer fence and irrigation valves: about $90. But the wiring cost more. I should have used multiple Photons and shorter cable runs. More complicated programming, simpler/cheaper cabling.

The Photon has been reliable. Not the rest. For my initial cabling I ran two Cat5 8-conductor cables (solid copper) to the middle of the hoop house and spliced (solder/heat-shrink/non-conductive caulk) 2 or 3 wire cables to the sensors.  That failed -- not always hard failed, some intermittent. Been replaced with straight (unspliced, more expensive) runs.

Tuesday, March 22, 2016

33: Computer Farming

If you've followed my blogs you'll know that I involved myself in the Raspberry Pi and Arduino initially help grandchildren who insist on farming. See my post 2

I've recently come across the dirtless farming work done at MIT. See--

http://openag.media.mit.edu/

and

http://www.ted.com/talks/caleb_harper_this_computer_will_grow_your_food_in_the_future?utm_source=tedcomshare&utm_medium=email&utm_campaign=tedspread

The MIT system is open source so I visited their github site and downloaded the source code. Interesting. There's a bit of overlap with my much more modest setup. I haven't finished snooping, but it appears that I have used the same sensors as they have -- temperature, humidity, soil temperature, soil moisture, irrigation switching. For testing, I have also programmed a CO2 gas sensor and photo sensor. They also have code for a pH sensor. I've been thinking about that one. There's a big range of prices.

Their system utilizes Arduino Megas and a Raspberry Pi. My system uses Particle.io Photons and a Raspberry Pi. Note: the Photon is as powerful as a Mega. Because of the Photon's "cloud" my Pi is 100 miles away.

Anyway. Their setup is worth studying.

Sunday, March 6, 2016

32: Particle.io Update

My current Particle position is: 1 Core, 5 Photons and as of yesterday, 1 Electron.

nice packaging

I didn't order during their Kickstarter campaign but right after. Today, I went to https://setup.particle.io to get started. Authorizing the SIM card seemed to go fine. My first problem was trying to connect the cell service antenna. Very tiny plug, very difficult, especially with trifocals. Finally seemed to work -- don't know how.


Left to right: USB power cable, battery, Electron, wifi connector (taped down 'cause I don't want to have to do it again), antenna wire and antenna.

Second problem: My phone shows AT&T 2 or 3 bars (probably 4G, but probably 3G as well). But as in above image, the Electron doesn't connect. The green LED just blinks.

Tuesday, January 26, 2016

31: Peltier Cool/Warm Device Experiment

See my discussion on my Raspberry Pi blog: http://dicks-raspberry-pi.blogspot.com (post 94).

I'm interested in comments about wiring the switch.