Anth's Computer Cave

AAIMI Home Automation Tutorial Hub

Use the buttons below to read all of the AAIMI Home Automation tutorials.

Download and set up AAIMI Home Automation 0.9

12th February 2018

In this article we'll download the AAIMI Home Automation setup files and prepare the Raspberry Pi and Arduino. Then we'll run the setup wizard to install and configure AAIMI.


To set up the AAIMI Home system you will need a basic understanding of the Raspberry Pi computer and the Linux operating system it uses. This includes using SSH to access your Pi, and mapping a network drive to load the AAIMI files.

You will need to have some experience using Arduino micro-controllers, and have built or bought some sensors like our prototypes featured on our hardware page. The hardware page has links to tutorials to connect and use all the individual devices.

We also recommend you read the Network section of our Advanced page to configure safe access to AAIMI.


You can find the full AAIMI Home setup folder here. Download and unzip the folder to your home folder on the Raspberry Pi. The extracted folder is called aaimihome, and it needs to be in your home folder. To ensure it is in the correct location, open a terminal and navigate to the aaimihome folder.

Type pwd. The location should be /home/YourName/aaimihome, with your Linux username in place of "YourName". The location is important because this is where the Apache server will expect to find the web folder.

Prepare your Raspberry Pi

First we'll get the Pi ready for AAIMI. You don't connect any home-automation sensors or devices yet, we'll do that after the installer runs.

As usual with Linux, the first thing you do is open a terminal and type:

sudo apt-get update && sudo apt-get upgrade

Install apache2 and PHP

To run AAIMI's web programs we obviously need a web-server. We'll be using Apache2 for this

In the terminal type:

sudo apt-get install apache2 apache2-utils

In a few moments, at the prompt type 'y' to agree to the install.

Next, to install php, type:

sudo apt-get install libapache2-mod-php php php-pear php-curl php-gd

Once again you may have to type 'y' to agree to install.

Configure Python

We'll need to install some Python libraries and for that we'll use pip.

Unless you have installed it in the past, you may need to install pip first. Type:

sudo apt-get install python-pip

Now we'll install the PySerial library. Type:

sudo pip install pyserial

AAIMI uses web requests for some communication. The Python Requests library takes care of that. You may have to install the Requests library. In your Raspberry Pi terminal type:

sudo pip install requests.

Strangely, the system will probably state that the latest version of Requests is already installed, but I have found Requests won't work until you have ran the command anyway.

Follow the prompts to complete the installation.

Next we'll update some libraries for AAIMI's communication. Type:

sudo apt-get install python-dev libffi-dev libssl-dev

This may take a few minutes. When it's finished, type:

sudo pip install --upgrade ndg-httpsclient

You might want to make a cup of coffee while this command runs, especially if you are using an old single-core Raspberry Pi like mine. It took almost ten minutes for me.

DHT temperature sensors

If you plan to use any DHT11 or DHT22 temperature and humidity senors in your devices you'll need to install the DHT Python library from Adrafruit.

I don't have a tutorial on using these, but there is a good DHT how-to over at Circuit Basics. They cover several methods for using DHT. Head over there and install just the Python DHT library using the instructions under 'Programming the DHT with Python', then we'll continue here.

Lastly, we'll install Screen, a Linux utility that will run our Python programs in the background.

sudo apt-get install screen

Configure Arduino

You'll need to upload one of the two Arduino sketches in the aaimihome folder. The basic version is in the folder called sensor_monitor_arduino. The other version, sensor_monitor_arduino_rfid, is the one you use if you wish to include an RFID card reader in your system. Use whatever method you usually employ to upload the relevant sketch to your Arduino.

Next you'll need to configure the serial connection between the Raspberry Pi and the Arduino. We are making this connection using a USB cable.

My Raspberry Pi connects to this over the "ttyUSB0" com port, thus the serial-connect part of my code (, line 910) looks like this:

arduino = serial.Serial('/dev/ttyUSB0', 9600)

Your board may connect on a different tty port. Click here for a guide to set up a serial connection between an Arduino and a Raspberry Pi.

Add people avatars and smoke-and-gas siren


You need to add an avatar image for each member of your household. These images go in the people folder at /home/YourName/aaimihome/aaimiweb/themes/people.

The images should be square, at around 200*200 pixels. The image names must match each person's user name + dot + jpg. For example my usernam is anth, so my avatar image is called anth.jpg.

System sounds

There are five system sounds for the alarm operation in the /home/YourName/aaimihome/aaimi/sounds folder. There is arming.wav, which sounds when a user is arming the system and leaving, and armed.wav, which sounds at the end of the exit-time when the system actually arms. There is intruder.wav, which sounds when an intruder is detected, and allclear.wav, which sounds whenever the alarm is disarmed. You'll also find a siren file called fire.wav, which is the sound the system uses by default if it detects smoke or gas.

You can replace all of these sounds with your own WAV files, just rename the new files the same as the originals. Choose WAV files no more than a few of seconds long. You can also add extra WAV files for custom sounds you can configure to play on events from other general-purpose sensors

Run the AAIMI wizard

Now we'll run AAIMI's setup wizard and installer. This wizard configures the web server for .htaccess password protection and sets your AAIMI password. It also configures paths in several of the other system files.

The setup file is in the aaimihome folder and it is called

Navigate to the aaimihome folder and type:

sudo python

The installer will check the location of the AAIMI folders to make sure they are in the correct place. It will also set ownership and permissions for the aaimihome folder and several of the files it will use during the installation.

If you have the aaimihome folder correctly-positioned AAIMI will prompt for a password for the admin user, which is you. The password should be eight characters long with upper and lower-case characters and numbers. Don't use the same password as your Linux user password. The password will not display as you type.

After that, you'll be asked if you wish to use IP filtering for extra security. Choosing yes will mean you need to manually allow access to each device you plan to use to access AAIMI while you are away. You'll also need to update the settings any time your phone's network details change.

Using AAIMI Home Automation without IP filtering

Unless you live in a bunker and wear a tin-foil hat, choose n.

It will then configure the Apache2 server files to change the Document Root to the aaimiweb folder and create a password-protected access system for AAIMI users. It will also configure IP filtering if you answered yes to the previous question.

That's the setup wizard out of the way, let's move on.


If you wish to use GPS location awareness you'll need to open a browser and go to: yourIP/mapper/aaimi_mapper.html. If you are not running AAIMI on a HTTPS domain you can't use Chrome because it won't allow location sharing with non-HTTPS sites. Firefox, Opera, Safari, Edge and IE should work fine.

Enter your username and password and agree to share your location.

The AAIMI Mapper GUI is completely separate from the AAIMI Home Automation system. You use it only to create areas and add users. After that AAIMI Home uses this data via the module.

There are four images representing the north/south/east/west boundaries of your home, along with some advice for allowing for the orientation of your property.

Walk to each boundary of the property, clicking the corresponding image at each point. Once all boundaries are entered you'll be prompted for a name for the area. Enter home. This is the primary area. You, and other users, can create other areas only outside the primary area.

For a more detailed description of AAIMI GPS Mapper the full article series is here.


In the next article we'll define our rooms sensors and relays, then start AAIMI Room Control.



Previous: Hardware Recap

Next: Configure rooms and devices



Leave a comment on this article