Introduction: Make Your Own Afero Hub With a Raspberry Pi

Hey everyone!

We've posted a couple of Instructables that showcase how easy it is to use our Afero Modulo board to connect your devices to the cloud to make them wirelessly accessible, wirelessly controllable, and able to talk to other devices online securely and reliably.

Since the Modulo is a Bluetooth device, it needs some slightly-better-connected device to connect to the Internet. In our previous Instructables, we've done projects that only rely on a short-range local connection (like the BoE-bot), or a connection that only needs to be available when you're nearby (like the mousetrap.) In those cases, the Afero mobile app acts as a communication hub between the local Modulo boards and the Afero Cloud.

We have another handful of fun projects to showcase coming up pretty soon, some of which are even handier if your Afero-powered device is online and connected to the cloud all the time, so you can monitor or control them even when you aren't at home.

We recently released a software package that will turn a small ARM-based Debian Linux computer (like a Raspberry Pi) into a standalone Afero Hub. It will keep your local Afero devices online and connected to the cloud so you can access them from anywhere in the world via the mobile app.

You can find more info on the Afero Hub Software from these handy links -

Afero Blog Post announcing Hub Software

Developer Documentation - Afero Hub Software

Setup is quick and easy, we'll run through them here in a short Instructable to show you how to do it!

Step 1: Hardware for the Hub Software

We released the Hub Software as a Debian package for ARM CPU architectures. The easiest and most obtainable hardware platform that can run the software is the Raspberry Pi 3. The Pi 3 has embedded Wifi and Bluetooth support so the Pi 3 will work as a hub without any additional hardware. This is by far the easiest way to get a hub together.

Make sure you have handy:

- Raspberry Pi 3 Model B

- A suitable power supply for it (a wall-power USB power adapter, not a USB port on your PC)

- A MicroSD card at least 8GB in size

You will need a few additional items to get the Hub up and running:

- a MicroSD reader/adapter for your PC to write the SD card image

- a USB keyboard/mouse and an HDMI monitor to configure the Pi

If you don't have a Pi, or want to buy a new one for use as a Hub, you can find a bunch of different Raspberry Pi 3 "Starter Kits" that come with the Pi 3, usually a cute enclosure, a power supply, and a MicroSD card, everything you need to get started. You can find these kinds of Starter Kits on your favorite electronics website or in your local favorite electronics store, or, well, pretty much anywhere else.

You'll need a USB keyboard/mouse and an HDMI monitor to connect to the Pi's console to set up the WiFi network. Once you have the Pi on your local WiFi network, you don't need them anymore - the Hub Software doesn't need a monitor or keyboard at all.

Step 2: Install the OS

We've run into an issue with the last couple of releases of Raspbian not playing nicely with the Bluetooth support we need to run the hub software. We've identified the issue and are working on submitting a fix, but for now we require the Pi to run the Raspbian 2016-03-18 release. (We'll update this Instructable when there's an updated Raspbian that we can make work.)

You can download that older release of Raspbian from the raspberrypi.org archives here.

Once downloaded, write this OS image to a MicroSD card using the nice documentation on raspberrypi.org which will show you how to create that MicroSD card on Windows, mac OS/OS X, or a Linux PC depending on what you have.

Check that documentation out and write your MicroSD card, then check back in here to continue.... we'll wait for you!

Step 3: Configure the Pi

Now let's do some quick setup work to the Pi to get it on your local Wifi network --

- Install the MicroSD card you just made into the Pi 3's SD slot

- Connect a USB keyboard/mouse to the USB ports on the Pi

- Connect an HDMI cable to the Pi and to a computer monitor you can use temporarily

Power on the Pi by plugging a cable into the MicroUSB port attached to a wall power supply (a computer USB port may not be able to provide enough power for the Pi.)

The Pi will boot, and it will launch you into a desktop environment you can use.

Follow the handy instructions at raspberrypi.org to open a terminal window and get your Pi on your local WiFi network.

When you've finished that, in that same terminal window, run "sudo raspi-config" to run the Pi configuration program. We have a few quick things we need to change here.

In raspi-config, select the first menu option to Expand Filesystem. This will allow the Pi to use the entire capacity of the SD card. If you don't do this you won't have very much free space on the Pi's filesystem and the hub won't work properly. If you forget this, installing the Hub software will remind you, so might as well do it now!

Next, take option 5 Internationalisation Options then select option I4 Change Wi-Fi Country. Select the country where you and your Pi are, and then exit raspi-config.

When raspi-config asks you if you want to reboot, select yes and the Pi will restart. You'll return to the desktop after the Pi reboots, and you should be on your local Wifi network.

Open up another Terminal window, and let's make this little Pi a hub!

Step 4: Add the Hub Software Repo

You should be sitting at a Terminal prompt on the Pi's desktop UI. All we need to do now is add the Afero Debian repository to the Pi and do a simple package install. We'll walk through the steps here, but if you've gotten this far, this is the easy part!

If you don't want to use the desktop environment and are familiar with the Pi you could also SSH into the Pi over your network and run these same commands from the ssh session as well, they work the same from anywhere.

First, let's add the Afero Debian repo to the Pi. We provide a simple script for you that will download the Afero APT signing signature to your Pi and add the repo to you /etc/apt/sources.d. Grab the script with the command:

wget https://cdn.afero.io/repo/deb/addrepo.sh

You'll download a small script called addrepo.sh. You're welcome to view this script to ensure it does everything we say it's going to do, if you like, then you'll need to run it as root with the command:

bash ./addrepo.sh

This script will prompt you for your pi user account password (so it can sudo) if it needs it, then it will add the signing key and add the repo to your Pi and then offer to run "sudo apt-get update" for you to update the repo catalog. Go ahead and answer "y" here to let it update, and when it finishes, the hub software is available to install!


Step 5: Install the Hub Software

We're almost done! The Afero Hub Software is just a simple Debian package. Well, two, but you need only install one. For descriptions of the packages and what they do please check out the Official Developer Doc.

Install the packages with the simple command:

sudo apt-get install afero-hub

This package will fetch the Hub software and it's prerequisite packages and install them. You'll be prompted to agree to the Afero Developer Terms of Service, which you can check out at the link here or in the package. If you don't agree with the Terms of Service, the package will not be installed.

After you agree to the terms, the Afero Hub package is installed.

When the hub software is installed, a QR code will be displayed in your terminal window. As with all Afero devices, this Pi Hub will be added to your account when you scan the QR code with your mobile phone. The installation will pause until you add this device to your Afero account, so let's do that now!

Fire up your Afero mobile app, tap the center icon, then tap "Add Device" at the top of the menu. Use your device's camera to scan the QR code in the terminal window. If for some reason the QR code won't scan, you can tap "Manually Add Device" at the bottom of the screen and enter the (long... sorry!) Association ID to your app that way. Fortunately, in testing we've found that these terminal-based QR codes usually scan pretty well!

After you've added the Pi to your account, you'll see a new Hub device in the mobile app, it will be online, and then the package installer will exit back to a terminal prompt.

Congratulations, you've set up your own Afero Hub!

You should locate your new hub anywhere you want always-on access to your Afero devices, just shut down the Pi the usual way ("sudo halt"), and plug it in where you'll want access for your Afero devices. Remember the hub covers a decent area so it doesn't have to be right next to any of your devices.

You can also install the Hub Software on multiple Pis and have hubs to cover a larger area - Afero devices will automatically roam from hub to hub, always connecting with the hub providing the best signal. In my house I have a Pi upstairs and one downstairs and I can see any Afero devices anywhere around my house.

Step 6: Further Information

Again the Hub Software documentation can be found in The Afero Developer Documentation for more details on uninstalling or upgrading the packages.

The Hub Software is designed to launch at boot and restart itself if it quits for any reason. You can check out the processes using the supervisorctl command, and you can manually start or stop them as needed, but typically you won't every need to worry about controlling them manually.

If you have any questions or want any further information please check out the Afero Developer Forums at forum.afero.io and drop us a line!

Comments

About This Instructable

260views

4favorites

License:

Bio: We created Afero with the purpose of designing an easy, secure, and reliable platform that would enhance the way people communicate with each other and ... More »
More by afero:Make Your Own Afero Hub with a Raspberry PiParallax BoE-Bot Remote Control Powered by AferoConnected Sprinkler Controller powered by Afero
Add instructable to: