Author Archives: hpeyerl

The Snap! environment

By   February 14, 2015

I thought it might be useful to explain how Snap! works in my device control scenario. I’ve ever so slightly modified Snap! to be able to query my server and get an inventory of inputs and outputs available. These are known as “Phrob Ins” and “Phrob Outs” for lack of a better name.

snapshot1

On the left is a list of all inputs that were discovered during the inventory process.

In the center are the logic blocks I’m currently working with. There are 4 logic blocks there. Two of them are outlined in Green. These two are presently executing. The other two are not. The smallest logic block on the bottom has a speech bubble next to it. I simply clicked on the “Office:temperature” input and the speech bubble popped up and said “2214” which is DegreesC multiplied by 100. I’m currently experimenting on whether to transmit data as integers or floating point decimals. The jury is out. There is a logic block on the middle right that is not executing. I can simply click on a logic block to start or stop the block.

On the right top is a white canvas which presently displays some temporary variables that my logic blocks use. It’s handy to see those variables displayed because it makes debugging easier.

The top running logic block is responsible for collecting some statistics and transmitting a single text message out to the APRS IS network. On this network, I can remotely see what’s happening at the cottage:

2015-02-14 13:40:28 UTC: VF9ABC-9>VF9ABC: T=70.0,OA=32.0,SP=70.0,H1A=0,C1A=0,LRT=21.86,LRH=33.83
2015-02-14 13:45:28 UTC: VF9ABC-9>VF9ABC: T=70.0,OA=32.0,SP=70.0,H1A=0,C1A=0,LRT=22.01,LRH=33.4
2015-02-14 13:56:02 UTC: VF9ABC-9>VF9ABC: T=70.0,OA=32.0,SP=70.0,H1A=0,C1A=0,LRT=22.14,LRH=32.88
2015-02-14 14:06:42 UTC: VF9ABC-9>VF9ABC: T=69.0,OA=32.4,SP=70.0,H1A=1,C1A=0,LRT=22.49,LRH=32.76
2015-02-14 14:12:00 UTC: VF9ABC-9>VF9ABC: T=70.0,OA=32.0,SP=70.0,H1A=0,C1A=0,LRT=22.57,LRH=32.45

While it is somewhat soothing to see the raw data, sometimes it’s nice to see a graph:

graph

Cottage Automation

By   February 13, 2015

My journey had several goals. One of these was to learn Python. I’ve been able to do all the programming I’ve ever needed using “C” and Assembly language with a bit of shell scripting on the side. None of these languages was going to suit me well for this project. I liked the speed with which a person can prototype an idea in a higher level language. My friend Kurt http://www.burgundywall.com is a huge proponent of Python and also a lot more up on current intarwebs technologies than I. So I dove into Python. Kurt thinks of me as a quaint old man so his assistance comes with a small amount of mocking and irreverance. No matter. I know how to code, but I occasionally need realignment as to which direction is correct when it comes to REST, object oriented design, etc.

After some prototyping, and some prototype AVR based hardware from Jeff, I was able to read from an I2C temperature/humidity sensor, turn relays on/off, and read from an SPI Thermocouple amplifier. Already this had many potential applications! A person could conceivably smoke meat on a BBQ with a motorized vent, or roast coffee in a repurposed breadmaker. It was certainly possible to write Arduino code to do these things but it was quicker and easier to just drag&drop some logic elements from Snap! and quickly debug the process. Here’s a simple Snap! program to control a linear motor hooked up to a BBQ with a thermocouple to sense the temperature inside the bbq as well as a thermocouple to sense the meat temperature.

One of the reasons I chose Snap! over something like Blockly was that Snap! logic blocks run in the browser. One of the nice side effects of this is that you can interactively debug your code and even click on an input or output and have an action occur immediately. For example, I can click on the icon of one of my temperature sensors and read the temperature interactively:

inside_temp

Now came the next step. There is some hardware that is just easier to buy than it is to build:

The Etherrain has a rain sensor and 8 valve outputs:

etherrain8

The TR60 thermostat has lots of goodies:

tr60

I can see what the indoor temperature is, outdoor temperature, how long the furnace has run in the last 5 minutes, what the current setpoint is, whether the fan is on, and I can set the current temperature setpoint (for either heat or cool).

Since my cottage is out in the woods, cellphone reception is not always awesome. Since I have an amateur radio license, I can legally transmit APRS packets. So I have an APRS transceiver connected to my server as well. I wrote a plugin for that as well, so I can send/receive messages from Snap!:

mttt4

With the above, I am able to do some interesting things fairly simply:

dr1

 

There are two logic blocks there. The upper one collects the humidity and temperature from a piece of Jeff’s hardware that lives in the Office out at the cottage. It also queries the TR60 thermostat for various bits of information and builds a string that is sent out as an APRS packet to the APRS-IS network where I can monitor it remotely. The lower logic block queries the TR60 thermostat to see what the current setpoint is and takes some action depending on whether the temperature is set to warm or cold. I am using the thermostat as a sort of occupancy sensor. When we set the temperature to 70F, I also want to have the hot-water recirculation pump turned on.

Device Automation

By   February 13, 2015

My friends say I’m a control freak and detail oriented. I’m not sure whether to be insulted or not but whatever.

We have a cottage in the woods that we bought in early 2010 and spent the next 4 years essentially rebuilding the house. We knew we would have to renovate it when we bought it but the further I dug into it, the further I discovered I was going to have to go. Now that I’ve learned a lot about building science, I won’t waste money on a house inspection in the future. But that’s for a separate article.

While working on the renovations, we also lived in the building on weekends.. This was a valuable time to learn about the building during the various seasons and gain an understanding of how we wanted to use it. The bright sunny places to sit at various times of the day, the oppressive heat in the summer, and biting cold of winter. Bug ingress season, Bug egress season. What I also learned was the various things that I needed to keep an eye on. When you put as much money into a place, you want to do whatever possible to protect that investment. But there’s also an opportunity to reduce maintenance and weekend effort. It is, after all, a retreat, not a gulag.

During my day job, I do embedded firmware. This means I write software for small microcontrollers in various applications; specifically interfacing them to the real world. So while working on the cottage, I saw many opportunities for automation and data gathering. When you own a home that you live in, you’re able to take care of things in the home because you’re always there (or you have neighbors who can do things while you’re on holidays)… Things like watering the grass or flowers, fixing leaky pipes, fixing the furnace, fixing windows. When you live in the city, many things are taken care of. Fresh water comes in under pressure for you, sewage leaves automatically, and your furnace turns on/off at the whim of your thermostat. You likely find out pretty quickly when something goes wrong. Not so much when you have a building a couple hours away that you don’t visit during the week, or might not visit for weeks at a time.

Out in the country, there are frequent power failures, or someone can notice that your driveway isn’t plowed and so decide to break in, leaving doors or windows open. Pipes can freeze or burst and before you know it, your basement is full of water. It’s easy to turn off the water when you’re not there but then you can’t automatically water the plants in the garden.

There are also some nice-to-haves… In the winter, it’s nice to be able to set the thermostat before you head out so when you arrive, everything is nice and warm. There’s a lot of heat mass in a building. So your furnace might get the air temperature up to 70F fairly quick, but all the walls, dishes, tiles, appliances, bedding, etc, are all still cold. It can take a few hours before the whole house is at a comfortable temperature. Same goes for summer. There’s nothing quite like driving out after work to discover the inside of the house is over 90F and you have to wait until after midnight before it’s comfortable enough to sleep.

There’s plenty of home automation stuff but was simultaneously horribly expensive while also not offering me the flexibility that I wanted. I know that I can buy a bunch of cheap Arduino hardware and build a whole shwack of custom sensor and control modules, each of them having custom firmware to do a single task. But coordinating them all can be a lot of work. Then the overriding logic is also higher effort than I wanted.

Around the same time as this, my buddy Jeff was wanting some generic sensor/control hardware to control his greenhouse. We quickly realized there’s a need for people to automate their hobbies. My building was my hobby.

My feeling is that the easier you make it for people to write code the more they’re able to accomplish. My dad can hookup relays, thermocouples, and that sort of thing but he can barely program a VCR.

When my son was in Grade 5, he was taught how to use “Scratch” https://scratch.mit.edu/ and that was the first thing that came to mind when I thought of simplifying device automation. After some research and experimentation, I found the reimplementation called “Snap!” http://snap.berkeley.edu. Thus my idea was born.

In the next article, I will go into some detail about what I’ve been working on.

Drobo Sucks

By   November 8, 2014

Drobo Sucks

As I get older, I find my desire to do sysadmining is waning. I just want stuff that works; I already have plenty of hobbies. I got tired of dealing with disk failures on my Plex server and my distaste for sysadmining overrode my tendency towards thriftyness. I decided spending $500-$600 on a NAS was a worthwhile purchase. A friend mentioned that a friend of his had a Drobo that he was happy with and I looked there. I compared features with the QNap and Synology units available at the local retailer and decided a Drobo-5N was just the thing.

I was attracted to:

  • no tools disk install
  • no real need to do administration. Just slide disks in and it figures everything out on its own.
  • availability of plugins
  • industrial design (magnets are what hold the front panel in place)

But mostly, I wanted something that would ‘just work’ and not turn into a hobby. So I bought it, and a couple of 4TB disks and brought it home.

I installed 2 4TB disks, 2 2TB disks and a 1.5TB disk. The lights flashed and all kinds of stuff happened and after installing the Drobo Dashboard software, it all looked cool.

So I went to droboports.com and selected a few packages. Since I wanted NFS for my Plex server, I installed it, along with ssh, vim, and a couple others. In order to install ssh, there’s some jumping through hoops you have to do with /etc/group, /etc/passwd, and so forth. This is where the problems started.

In short, I bricked the Drobo 5N. I followed the instructions on droboports to the letter but it was dead. I realized I’d screwed up so went with a ‘Factory Reset’ but that didn’t solve the problem. I tried the reset button on the back but all I managed to do was clear out my settings but still it was unhappy and I couldn’t use it. I should mention in all of this that my previously created mountable volume became erased as well. Good thing I’d only copied about 4TB onto it that I still had stored elsewhere. But the act of hitting the ‘Factory Reset’ button causes all of your setup to go away, including your disk volumes.

After a bit of back and forth with front-line tech support wherein all the stuff I’d already tried was suggested, I was referred to second tier support who immediately came back with “reflash your firmware, here’s a link to the image and instructions”… After reflashing the firmware, all was well again.

I rebuilt my volume and got NFS installed. I also tried to install Crashplan by clicking the checkbox in Drobo Dashboard but the installation failed. After some googling, it turns out you have to use Droboports again to install Locale and Java. The side question is: why provide a checkbox to install a package when you still have to do all kinds of commandline installs of dependancies? A bit of false advertising there.

I got my Plex media server to stream off the NFS mounted Drobo volume and everything looked great. I settled in for some well earned TV viewing. About an hour in, the NFS mount stalled and the Drobo seemed to hang. Rebooted the Drobo as well as the Plex media server and tried again. It hung again. I punted and went with an SMB mount. That worked well enough. A little sub-optimal but whatever. I guess this Drobo ports thing isn’t all it’s cracked up to be.

I went away for a 4 day weekend, and when I came back, the Drobo was bricked again. In short, I couldn’t get it to respond to the Drobo Dashboard app. After starting another tech-support ticket and going through 7 days of back and forth with frontline support, (one exchange per 24 hour period) I was finally referred to second tier support. By this time, I had discovered that if I removed all the disks, I could talk to the Drobo but of course couldn’t do anything. If I re-inserted the disks one by one, I could talk to it until I put the 5th disk in; then it went unresponsive. The love affair was over. It seems as though I lost a disk (the 1.5TB). The disturbing thing is that this is exactly the scenario that prompted me to buy the Drobo. However, even with the 4 original disks, the Drobo was unable to mount the volume. The message was “there are not enough disks to mount the volume – mount failed”… This is not how a NAS is supposed to work. While messing around, I’m still waiting to deal with Tech Support. All of my exchanges with them told me that they’re not capable of reading the ticket so I was asked to try things I’d already tried and itemized in the first message. Remember, each exchange is about 24 hours. After a few days of this, it came down to “Do a Factory Reset and start over”.. In other words, throw away all of my data and recreate the volume. I asked “is there no useful diagnostic information to be gleaned here as to what happened?” … The answer, “maybe. Let me transfer you to second tier support. After a couple of useless exchanges, wherein we were running out of things to try, tech-support went dark. Over 48 hours with no response and a couple of “Hello? Is there anyone there?”, I decided enough was enough, I went back to my retailer to return the unit. They have a 7 day exchange policy but after reading through a transcript of my tech-support tickets, they refunded my money. I got the impression they weren’t surprised, as in this had happened before. I think it’s likely they’re going to drop Drobo.

After some googling, I decided upon a Synology DS414. I brought it home, installed the 4 disks that were previously in my Drobo 5N (leaving out the 1.5TB that conceivably failed) and it’s been trouble free for over a month. In fact, I’ve started migrating services over to the Synology including DNS forwarding, DHCP, and Asterisk. I’ll move my Subversion repository over to it as well, and then I’ll be able to turn off one of the machines in my rack and realize some power savings. The best part is there’s been a relatively steady stream of free firmware updates which address linux security vulnerabilities and a major upgrade with new features. All free!

I did finally hear back from Drobo tech support with a “Sorry about the silence. I was sick and out of the office”. So apparently there’s nobody managing tech-support. Tech support is ‘a guy who responds to tickets’, not a department with a manager who makes sure all tickets get timely responses. When I responded “Too late, I already returned the Drobo and bought a Synology”, the response (the next day) was “Great!” and the ticket was closed with “Solved”.. I was then sent a Support Survey link where I unloaded my mental baggage itemizing my poor experience with their product. Either nobody reads the surveys or they don’t care because nobody ever contacted me. If I was running a small company in a highly competitive consumer electronics vertical market, I’d be right on top of bad survey returns.

Don’t buy a Drobo!

  • Your data is not safe
  • Support sucks

Pretty much the two things you want out of a NAS.

How to auto start Wifi hotspot on Android 4.4.4

By   October 24, 2014

How to auto start Wifi hotspot on Android 4.4.4

I got a broken Nexus-7 and wanted to use it as a router up at DebtRidge. I wanted it to come up as a wifi hotspot automatically when booted. This means the ‘hostapd’ daemon needs to be started automatically. So here’s what I did.

  • Unlock the bootloader
  • Root the tablet and install SuperSU
  • install busybox
  • install init.d

The above is outside the scope of this article. There’s already lots of fine articles that tell you how to do all that.

Once you can get a terminal prompt or adb shell and su, you can proceed.

  • setup the Wifi hotspot in Settings. This will generate a file called /data/misc/wifi/hostapd.conf. It looks something like this:
interface=wlan0
driver=nl80211
ctrl_interface=/data/misc/wifi/hostapd
ssid=drgate
channel=6
ieee80211n=1
hw_mode=g
ignore_broadcast_ssid=0
wpa=2
rsn_pairwise=CCMP
wpa_psk=115dfdf3a3c63c3692b5cfaf0ad73234e89a1e7b70037fd5cfcdcd2d608a6bc9

Since init.d is run in /data/install-recovery-2.sh, it runs too early in the boot process for hostapd to start. Another issue is that hostapd won’t run if Wifi is enabled. However, if Wifi hasn’t been enabled, the wlan driver isn’t loaded and hostapd isn’t able to bind to wlan0 because it doesn’t exist. So I had to find a way to load the wifi drivers so that hostapd would come up.

I discovered that I can run “svc wifi enable” to install the drivers and bring up the wlan0 interface. Then “svc wifi disable” would bring down the wlan0 interface but leave the drivers installed. At this point, hostapd was perfectly happy.

So to bring this all together, I needed a script that could be launched at boot time that would delay the starting to hostapd until later in the boot process. Here’s what I did.

su
mount -o rw,remount /system
cd /system/etc/init.d
cat > 50hostapd
#!/system/bin/sh
/data/start_hostapd.sh &
^D
chmod 755 50hostapd

Now install the following script as /data/start_hostapd.sh:

#!/system/bin/sh
while true; do
    su -c svc wifi enable
    sleep 1
    netcfg | grep wlan0 && break
    sleep 10
done
su -c svc wifi disable
sleep 2
/system/bin/hostapd -e /data/misc/wifi/entropy.bin /data/misc/wifi/hostapd.conf &

Then:

chmod 755 /data/start_hostapd.sh

and you should be good to go.

root@deb:/ # ps | grep hostapd
wifi      1282  1     2416   1000  c0138fe4 b6ee46d8 S /system/bin/hostapd

San Juan 21 #2453

By   May 16, 2010

Dad and I – 1981

015

Jakob and I – 2010

IMG_7192

 

In the summer of 1979, dad and I took our 16′ Matilda on a road trip… We didn’t know where we’d end up if I remember correctly. We had some adventures like running out of wind on Kootenay Lake and then pouring rain… So we paddled for hours to get to Nelson, where we were headed… Just before we got to Nelson, the wind picked up and started howling just as we try to pull into the dock. Inexperienced sailors that we were, we ended up coming in on a run, then having to jibe to make the dock. Come up head to wind but still too much momentum and smack the mast/forestay into the ramp. Did some damage to the coach roof but it was all good. Rather than have to possibly paddle all the way back to the campground, dad bought a used 4hp Evinrude. Our travels eventually took us to Vancouver and we spent a couple of days walking the docks looking at all the boats. We ended up at a San Juan 21 dealer and after a quick phone call to mom, we ordered a brand new SJ-21. With pin stripes to match our Ford Econoline 150; which I guess is something you did back in the 80s.

Next spring, our boat was ready for delivery. We drove out to Vancouver to pick it up. SJ-21, #2453. It was our first brand new boat. That summer, we added lots of stuff; a VHF marine radio, spinnaker, auto-helm, cooking aparatus, lots of storage a genoa, etc etc. We had a lot of adventures in that boat. Pictured here is us launching the boat again that summer under the Burrard Street Bridge. That’s a 14 year old me standing in the hatch, and my dad grabbing the bow line and telling me how to start the motor (this is all from hazy memory).

We sold the boat a few years later and bought a C&C-25. I don’t know who we sold the SJ-21 to but my dad recalls it was a family in the kootenays.

I’m 43 now, and have a family of my own. I’d been through a Laser and then a Fireball; each of which being boats that I had in my youth. As a 43 year old I realized I wasn’t too into sitting in a wet cockpit or hanging my ass out on a trapeze anymore. My son Jakob enjoys sailing immensely so I figured something in a 20 foot cabin cruiser was a good size to transition to. A SJ-21 was high up on the list but I’d consider a 23 or a Santana 23 or something in that range that I could afford. I looked at a SJ-21 up at Sylvan lake in the spring of 2009 but the guy selling it was a scam artist. The ad read “awesome boat, recently faired keel and hull. Great condition. Overbuilt trailer – $4000” but upon arriving, the boat was half full of water, due to the many holes on the deck, cockpit floor, and transom no doubt; it was on flat tires (due to the water I’m sure), and one of the trailer bunk supports had rusted and broken leaving a rusty shard of steel poking into the hull. I gave up on my search after that realizing that if that’s what $4000 buys, I couldn’t afford a SJ-21.

Fast forward to spring 2010; I’m looking for SJ-21’s again. Missed out on one up in Lacombe (sold before I arrived), looked at another one out at Ghost Lake (deck rot), and then an immaculate specimen that was sold to someone over the phone while I was sitting inside of it… Mightily discouraged, I resigned to give up for another year. After an aborted camping trip, I found myself hitting reload on Kijiji and lo-behold, was a for-sale ad for a 1980 SJ-21 with the same pin-stripes as our old one. I drove up to Caroline AB to take a look. It was our old boat! It had aged not too badly over the years. Still had our original sails and there was evidence a plenty that it had had lots of adventures in the intervening 30 years; but the deck was solid and the rest was stuff I can fix. I made an offer; the offer was accepted; and the next day after procuring a bank draft I met the seller in Red Deer to exchange boat for bank draft.

I went through the boat, found a few fiberglass repairs, a few new additions, and began itemizing all the things that needed repair:

  • rudder seperating
  • port bulkhead is rotted
  • windows leaking
  • wiring is a mess
  • extra useless or inappropriate fittings, some installed with steel bolts
  • broken cheek blocks
  • an owie on the starboard bow
  • too much silicon
  • broken instruments
  • trailer guides
  • new halyards
  • re-rig spinnaker
  • replace steel mast step
  • remove anti-fouling
  • new motor mount plate
  • some sort ‘wow’ in the pulpit

So now the adventure begins.

While sorting through untold numbers of previous owners worth of stuff, I found some interesting things:

  • some child’s rock collection
  • a broken gooseneck fitting that I remember breaking at a regatta in 1981 or 1982.
  • bundles of department store wire with generic crimp fittings with thimbles. I wonder if someone replaced the stays at one point using home depot grade crap?

I forgot about these awards but Dad kept them. Looks like we got 1st place in the 1983 GYC Frostbite regatta.. There used to be a good 6 or 8 SJ21’s in the fleet at that time.