Home is Where the Heart Is

Home is Where the Heart Is

By: Lasse Jespersen

In home automation, individual controller units that respond to infrared control, light changes, temperature, motion, PIN entry or NFC/RFID scans are perfectly fine. These light-weight DIY projects are compact, simple and easily scalable. But in the interest of convenience, they should all be connected to a central hub. Home is where the heart is, so let’s call it the HEART.

Home is Where the Heart IsThere are a lot of tiny single board computers (SBCs) on the market today, and perhaps the most suitable for a hub is a Raspberry Pi. These are marketed as an education platform, and are extremely well documented. Other SBCs are perhaps more cleverly made, or more powerful, but I have yet to see one which is so easily accessible to *ANYONE*, not just people with an above average technical inclination. If the reader fancies +PLUS+ performance, it is worth also looking into the Cubieboards, Cubietruck, Odroid, Pandaboards and many others. This is not an advertisement for Raspberry Pi in particular, and anything that has USB ports + GPIO/I2C/UART/SPI and a solid set of libraries for easy access to the hardware will do. The Pi certainly qualifies.

The Pi is JUST a tiny computer, which runs off 5V/2A, either through microUSB or a VCC pin. That means a generic tablet USB charger would be sufficient. Note that the Pi3 may require 2.5A at peak load, but has built-in Wi-Fi and bluetooth. The Pi has no built-in flash memory, like the Beaglebone Black does, which is completely fine for us – instead it uses a microSD card for storage of the operating system. Recent Pis have a CPU speed of 900MHz on 4 cores and 1GB of memory, but less will do, and older versions can be had for pennies. They can be overclocked without heatsinking, though it is recommended.

Overall it is fairly stable if you don’t exceed its memory capacity of 1GB and start swapping to microSD. And it will run as fast as a modern cellphone. It has 40 GPIO pins, and both 3V3 and 5V can be supplied at low currents. You cannot drive a micro linear actuator from these pins, but you can switch a transistor on/off and use that to drive a micro linear actuator – or other servo motor. The most important thing about the Pi is that the GPIO pins can be controlled with a sleek, easy-to-learn, easy-to-read programming language called “Python“.

That’s not to say that you can’t do it all manually if you prefer; the hardware is exposed in the filesystem as individual sets of files, and each pin can be read and written to from a command prompt. This is not a method I would recommend, though it lets a user use any method for controlling simple pin I/O, even simple Bourne shell scripts.

For the intrepidly curious, the pinout of the GPIO header can be seen at https://pinout.xyz/pinout , along with description of the capabilities of the pins.

What Makes a Hearty Hub?

Home is where the heart is

A sleek case to prevent spousal complaints

Google “nethomeserver raspberry pi” and you’ll see. Firstly, however, you must get Raspbian and flash it to a microSD card. It is best to use one that has a capacity of 8GB or more, and I recommend at a class 10 microSD, from a decent brand like Samsung. Not because they cost more, but because they’ve are of decent quality. Super cheap microSDs fail hard, and you will not like rebuilding your system every three months. Do not buy one of the “preloaded” microSDs for Pis either – spend a little extra on a good blank microSD card, and then visit the following page: https://www.raspberrypi.org/downloads/raspbian It is sufficient to download Rasbian Lite here, since the Pi is not very suitable for a memory-heavy GUI (many do not use it with a GUI at all) You can get by with only an 8GB microSD this way, though more is better. The RAM that would normally be wasted on a GUI can instead be used for services and file storage.

The image must be unzipped, and then written “RAW” to your microSD.

Use Etcher from:

https://www.etcher.io – it will work on Windows, Mac OSX and GNU/Linux.

Alternately, on a Windows PC, try Win32DiskImager from:

http://sourceforge.net/projects/win32diskimager/

or flashnul from:

http://shounen.ru/soft/flashnul/index.html – it’s a Russian site, so use google translate.

On Mac OSX you can use ‘dd’ in the Terminal, but that can end badly for Mac OSX and you, so instead try Pi Filler from:

http://ivanx.com/raspberrypi

or PiWriter2 from:

http://sourceforge.net/projects/piwriter/files/PiWriter-2.x.

Upon boot Raspbian will cleverly resize your partition to 100% of the microSD’s capacity, ignoring the well-known rule that 10-20% of flash memory should be left unallocated for wear-levelling to prolong the of your microSD card.

Start Your Soon-to-Be_Homely_Heart

Once you have imaged the microSD, you simply insert it into your Pi, plug in an HDMI cable and attach a USB keyboard. No mouse is necessary for Raspbian Lite. Last, attach a suitable 5V switching power supply, such as one used to charge an iPad.

You will see a lot of text flash by, which is a good thing. When prompted, enter the username “pi” and the password “raspberry”. Change the password immediately if you are on a public network, by entering “passwd”. Using ssh to login to your Pi is outside the scope of this article, but is encouraged, since typing from your main workstation or laptop is much more convenient when doing lookups for information online.

If you insist on using your TV or DVI monitor, the Pi can be discreetly mounted on the back of most units.

For a user-friendly step-by-step guide to wiring the Pi and a few other things up, see:

https://www.raspberrypi.org/learning/hardware-guide/quickstart/

For an after-boot guide, visit:

https://www.raspberrypi.org/learning/software-guide/update-sd-card/

After the setup and system upgrade, you have a unit which you can assume will use ~5-7.5W under moderate to high load, with WiFi/Ethernet enabled. This may vary, but my own measurements were within this range,
often far below. The Pi will power down the CPU when possible, and use the least possible power under varying conditions. Unless you have a Pi3 I recommend you use a wired connection to your router/switch to provide connectivity – all too often, the WiFi dongles will have problems when loaded too much, and the ethernet port just never fails. Since I had these problems with all recent versions of Raspbian, using a lot of different WiFi dongles (some even on powered USB hubs), it’s better to provide a service over ethernet if at all possible.

What service would serve your family best?

The Pi is fairly reliable when set up correctly, and you should have a look at http://opennethome.org and http://nethomeserver.blogspot.com , which describe a very nice system for home automation. You may feel a rush of blood to the head – it is AWESOME! – It will be covered in more detail in upcoming articles, but for now, it is sufficient to know that it can be an information hub for sensory data gathered from things like thermometers, window switches, NFC control units, and also a control hub for turning things ON and OFF. Things like skylights, which open silently and reliably with a 6″ micro linear actuator from Morai Motion.

home is where the heart is

NetHomeServer Overview – Courtesy of opennethome.org

I will be using 433MHz radio modules for this, but 315 and 860MHz are also available. The important bit is is the price tag. The 433MHz modules cost ~1USD per unit, and with a little care they can be be enhanced in terms of range and receiver sensitivity – and of course they can co-exist with other modules using the same frequency range, using an addressing scheme – unit 1, 2, 3. From the Pi to Arduino clones wired up throughout your home, you can sense the humidity in your cellar, the humidity and temperature in your greenhouse, which doors are open or closed, drive window blinds up and down, or controlling air-conditioner units… And using your tablet, PC, or phone you can access the Pi over your WLAN, view states and control it all.

Perhaps you’ve heard whispers about a certain miraculously expensive system which solves all problems both thought and unthought of? An acquaintance of mine bought one, and received a _Raspberry_Pi_ to use as a control hub. He never really got started using it because he knows he has the ability to build the modular system himself, exactly tailored to his house – just the same, minus the nightmarish dollar overhead.

Nethomeserver on a Raspberry Pi + 5 433MHz TX/RX modules… A rough estimate: no more than 42USD. Assuming you buy a _new_ Pi, which is a big assumption, given the prices for used “Raspberry Pi 1 B+” go for around 15USD. Allow me to correct the previous rough estimate from 42USD to 20USD.

Doesn’t THAT sound _good_?

Leave a Comment