Posted on 1 Comment

#19: Husqvarna Automower basics

Why mow the lawn yourself, when you can have a robot do it for you?

Husqvarna have very kindly supplied me with an Automower 320, which is a mid-range robot lawnmower that’s suitable to mid to large size suburban gardens.

Normally I like to focus on low-cost, DIY home automation projects, but this is just too good to pass up! In this episode I explain how the Automower works, how it’s different to a traditional manual mower, and (most importantly!) how my pets react to it.

In future episodes I’m going to try some creative things with the Automower. I can’t go totally crazy because the mower is supplied by Husqvarna as part of a pilot program and I’m not allowed to open it or modify it (yet!) but there are still some fun things we can do without voiding the warranty or having it repossessed.

The Automower range is listed on the Australian Husqvarna site: www.husqvarna.com/au/products/robotic-lawn-mowers

Disclosure: Husqvarna provided me with this mower as part of the Test Pilot program. www.automowertestpilots.com.au

Posted on 2 Comments

#18: Installing the ANNKE 4-channel CCTV system

Over the years I’ve slowly added individual IP cameras, both inside and outside the house. However, I’ve run into limitations such as how to store footage from the cameras for security purposes, and how to display multiple cameras simultaneously. I’ve used workarounds for these problems but it’s time to try out a proper camera system, rather than a collection of separate cameras.

I installed an ANNKE system a DVR and cameras to replace 4 of my existing IP cameras, to test how well it works. I also installed long video cables and a wireless mouse so I could mount the DVR inside my ceiling and display the camera feed on a couple of LCD TVs, and tested BNC-to-UTP adapters to run Cat-5 cable to a distant camera.

Unfortunately I discovered that the DVR requires Windows for network access, because it relies on a plug-in that doesn’t work on Mac or Linux. That means I had to run long video cables to the TVs that I use to display the live feed from the cameras. The end result is great, but it’s not how I intended to set it up.

This is the particular ANNKE 4-camera system that I installed, which is the Australian version: www.annkestore.com/annke-8ch-1080p-hd-cvi-security-camera-system-with-4-x-2mp-bullet-cameras-c51bp.html

This is the US version of the system: www.annkestore.com/annke-4ch-1080p-hd-tvi-security-camera-system-with-4-x-bullet-cameras-1tb-hdd.html

There are a bunch of other packages as well. The AUD price seems to vary: I think it’s generated by converting from USD at whatever the daily exchange rate is, so it’s different now to when I got mine.

Posted on 72 Comments

#17: Home automation control with Sonoff, Arduino, OpenHAB, and MQTT

The Sonoff from Itead Studio is a fantastic little mains-switching module with a built-in ESP8266 and WiFi. If you want an easy way to control mains devices such as lamps and fans, this could be it!

Sonoff modules are preloaded with firmware that allows them to be controlled by a phone app, so they’re very easy to get started. But that’s just the beginning: using a USB-serial converter and the Arduino IDE, you can load your own software on the Sonoff and make it do your bidding. I used the Arduino IDE to load a sketch with MQTT support and OTA (over the air) updates, allowing it to be controlled by OpenHAB.

Sonoff models mentioned in this video:

Start by adding ESP8266 support to the Arduino IDE by following the instructions at github.com/esp8266/Arduino. I used the simple “Boards Manager” method.

For OTA (over the air) update support you’ll also need to install Python 2.7.

You’ll also need a USB-serial converter with support for 3.3V I/O. I used the Freetronics USB-Serial Converter (of course!), which has a switch that lets you select 3.3V or 5V mode.

The “BasicOTABlink” example shown in the video can be found at github.com/superhouse/BasicOTABlink.

The “BasicOTARelay” example shown in the video can be found at github.com/superhouse/BasicOTARelay.

For more information, a fantastic resource is Pete Scargill’s blog post about Slampher and Sonoff.

If you want to upgrade the FLASH memory on your Sonoff, check out Pete Scargill’s blog post about upgrading ESP8266 memory.

Update 24 Sep 2016: fixed the example links.

Posted on Leave a comment

SuperHouse Vlog #43: SMEE Robot Building Competition 2016

The second annual Society of Monash Electrical Engineers Robot Building Competition saw about 150 competitors spend a weekend building robots to solve a specific challenge. Their robots needed to follow a line down a track, detect when they approached a gate, sense the colour of the gate, transmit that colour to the course control computer using an RF transmitter module, wait for the gate to be opened, proceed to the next gate, and repeat until they reached the finish line. The finish line is a line across the track that matches the colour of the last gate, so they also had to detect multiple cross lines and ignore the ones that were the wrong colour.

The challenge turned out to be too complicated to complete within the time allowed, so it was simplified a little during the competition.

Freetronics was a major sponsor of the competition, providing prize packs for the first 4 place teams plus a bonus prize pack for a “best bling” category judged by me purely on who made the coolest looking robot.

Posted on 3 Comments

#16: Compiling Arduino sketches with Pocket C.H.I.P.

Do you ever find yourself inside your ceiling or under the floor working on your home automation system, and need to SSH to a remote machine or re-flash an Arduino?

Sure, you could drag your laptop under there with you, but I don’t want to have my expensive laptop lying around in the dirt or insulation.

I may have found the answer.

C.H.I.P. and Pocket C.H.I.P. will be available soon from getchip.com.

I used “arduino-mk” running on the Pocket C.H.I.P to compile and upload an Arduino sketch: github.com/sudar/Arduino-Makefile

The following sequence got everything working for me. You may want to do things a little differently, for example by managing the python-serial extension using Pip or storing your sketches in a different location. That’s totally up to you, just make sure you alter the paths shown below as necessary.

Start by making sure your package list is up to date, and that you have the latest packaged Arduino and Python serial extension installed on your C.H.I.P.:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install python-serial arduino arduino-mk

Create a directory inside your home directory to keep all your Arduino sketches organised:

mkdir ~/sketchbook

Now go into your sketchbook and copy an example project out of arduino-mk, so that it includes the example Makefile:

cd ~/sketchbook
cp -a /usr/share/doc/arduino-mk/examples/Blink .

Note the space and the dot at the end of that line!

Now go into the Blink project and see what files it contains:

cd Blink
ls -l

You’ll see that there’s both the sketch itself and a Make file:

-rw-r--r-- 1 chip chip 509 Jul 12 2014 Blink.ino
-rw-r--r-- 1 chip chip 61 Jul 12 2014 Makefile

There’s nothing unusual about the Blink sketch. It’s just standard Arduino code that you could compile with the regular IDE. The magic is invoked through the Make file.

Open the Make file in your favorite text editor, and you’ll see that it looks like this:

BOARD_TAG = uno
ARDUINO_LIBS =
include ../../Arduino.mk

The “BOARD_TAG” value specifies that you want to compile it for an Uno or compatible board. You can change this to match other boards found in the Arduino board hardware definition file, which is located at /usr/share/arduino/hardware/arduino/boards.txt. In that file you’ll find other handy board types that I’ll list at the end. For now, we’ll assume that you’re using an Uno and leave that unchanged.

The “ARDUINO_LIBS” value allows you to specify a path to your own custom libraries in case you need them linked during compilation. We’ll ignore that for now, so leave that line unchanged.

The “include” line is a problem. It assumes the project is still located in the shared location where it was installed by the package, but we’ve made a copy in our local sketchbook. To fix that, change the “include” line to read:

include /usr/share/arduino/Arduino.mk

There are many other options you can add to the Make file to override the default settings within Arduino. For example, you can define the path to a specific version of AVRDUDE if you want to bypass the version that’s bundled with the Arduino environment.

But for a minimal example, you don’t need to change anything else.

Now you can compile the sketch, and upload it to your Arduino. To compile the sketch without attempting to upload it, just type:

make

That’s it! Can’t be much simpler. If there are any compilation errors, you’ll see them in the terminal.

To upload (and automatically compile if necessary) make sure your Arduino is plugged into your Pocket C.H.I.P. using a USB cable, and type:

make upload

You’re all done! Your sketch should now have been uploaded to your Arduino.

There are other commands available as well. Check out the Arduino-MK documentation for more information:

github.com/sudar/Arduino-Makefile

Alternative board types

These are all the board tags list in the standard /usr/share/arduino/hardware/arduino/boards.txt file:

uno: Arduino Uno
atmega328: Arduino Duemilanove w/ ATmega328
diecimila: Arduino Diecimila or Duemilanove w/ ATmega168
nano328: Arduino Nano w/ ATmega328
nano: Arduino Nano w/ ATmega168
mega2560: Arduino Mega 2560 or Mega ADK
mega: Arduino Mega (ATmega1280)
leonardo: Arduino Leonardo
esplora: Arduino Esplora
micro: Arduino Micro
mini328: Arduino Mini w/ ATmega328
mini: Arduino Mini w/ ATmega168
ethernet: Arduino Ethernet
fio: Arduino Fio
bt328: Arduino BT w/ ATmega328
bt: Arduino BT w/ ATmega168
LilyPadUSB: LilyPad Arduino USB
lilypad328: LilyPad Arduino w/ ATmega328
lilypad: LilyPad Arduino w/ ATmega168
pro5v328: Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
pro5v: Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
pro328: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
pro: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
atmega168: Arduino NG or older w/ ATmega168
atmega8: Arduino NG or older w/ ATmega8
robotControl: Arduino Robot Control
robotMotor: Arduino Robot Motor

You can also use custom board profiles, but that’s beyond the scope of this post! Most common Arduino compatible boards match something on this list. For example, the Freetronics EtherMega operates just like an Arduino Mega with a 2560 processor, so you’d select “mega2560” as the BOARD_TAG in the Make file.

Update 6 Jan 2017: Quick Setup Script

My friend Alec has written a script to simplify the process of installing the packages I used in the video and also to fix a few things he doesn’t like about the default setup. His script installs the necessary packages, blocks root access to the terminal and SSH, locks the root account, changes the default password, changes the hostname, and forces public key authentication via SSH. Definitely worth a look:

gist.github.com/alecthegeek/434325b6ea261ba84499f4966795073e