Anth's Computer Cave

AAIMI GPIO Tutorial Hub

AAIMI GPIO is a web-based control interface for the Raspberry Pi and Arduino. Check out the tutorials below.


23rd November 2017

In this article I'll show you how to prepare your Raspberry Pi, then download and configure AAIMI GPIO.


You can download AAIMI GPIO from my aaimi_gpio GitHub page. Click the 'Clone or download' button, then 'Download ZIP'. Unzip the downloaded folder to your home folder on your Raspberry Pi.

You'll need to open a terminal on your Pi over SSH. Once everything is set up you can say goodbye to the terminal, but for this step we need it.

The folder is called aaimi_gpio-master (the -master is appended by GitHub). We'll change that to the standard 'aaimi_gpio'. Navigate to your home folder and type:

mv -R aaimi_gpio-master aaimi_gpio

Prepare Raspberry Pi

The first step, as always, is to update Raspian.

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

Next, install Apache2 and PHP to run the web-interface.

sudo apt-get install apache2 apache2-utils

Type 'y' when prompted to agree to the install.

To install everything we may need for PHP, type:

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

Now you'll need to direct Apache2 to the AAIMI GPIO folder and set the permissions to include the Apache user.

We'll back up the original Apache2 configuration file first. Type:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default_old.conf

Now get the full path to the AAIMI GPIO folder to add to the file. Navigate into the aaimi_gpio folder and type:


The result should look something like '/home/yourName/aaimi_gpio', with your name in place of 'yourName'. Copy the path because you'll need it during the following steps.

Now open the Apache2 config file in Nano.

sudo nano /etc/apache2/sites-available/000-default.conf

Scroll down until you see the line 'DocumentRoot /var/www/html'

Replace '/var/www/html' with the path you copied from the pwd command. The line should now read 'DocumentRoot /home/yourName/aaimi_gpio'.

If you are doing anything important with your Raspberry Pi you should consider adding htaccess password protection while you are here.

I'll try to get a tutorial going for that soon.

Press CONTROL + x then type y and press Enter to save the file and exit Nano.

Apache needs to restart before the changes take effect.

sudo service apache2 restart

Now we'll set the ownership and permissions for the AAIMI GPIO folder and its files. We'll set the owner as you, and the group as www-data, the default Apache user.

Enter the following command, substituting '/path/to/aaimi' with the full path from the pwd command, and your Linux username in place of 'yourName'.

sudo chown -R yourName:www-data /path/to/aaimi

For example, I type 'sudo chown anth:www-data /home/anth/aaimi_gpio'.

Now to change permissons. Again, substituting your full path, type:

sudo chmod 750 /path/to/aaimi

Finally, navigate into the aaimi_gpio folder and type:

sudo chmod 644 *.html *.css *.js *.php *.txt

Prepare Arduino

If you want to use an Arduino with your Pi you'll need to upload the sketch from the sensor_monitor_arduino_08 folder.

After that, connect the Arduino to the Pi via USB. You can't use a GPIO-based serial connection at the moment because the program sets the GPIO pins on the fly. I'll get this feature going soon because USB serial is not really practical for the Raspberry Pi Zero.

You'll also need to enable the Arduino option in

Go to line 43 and change the arduino_enabled variable to "yes".

By default the serial port is '/dev/ttyUSB0'. If your Arduino connects over a different port you'll need to change the port setting on line 166.

Save the code and restart the AAIMI GPIO program.

Test onfiguration

Once you have tested the system you can set the program to start at boot, but for now we'll start it manually via SSH.

To start the main Python program type:

sudo python

The program will start in standby mode. It will not load the pin list and won't define or monitor any pins. Instead it will just listen to a socket waiting for the switch-on command.

To test your web configuration, open a web browser and type the IP address for the Pi. You should see the AAIMI GPIO pin configuration page.

The configuration interface for AAIMI GPIO. Picture: Anthony Hartup.

Click the On/Off tab and you'll see options for starting and stopping the program, and shutting down the pi.

The configuration interface for AAIMI GPIO. Picture: Anthony Hartup.

Click Start AAIMI GPIO

AAIMI will load the default list of GPIO pins. If you've previously set some pins it will configure the pins accordingly. It will then start the main loop to monitor any input pins and pins set to timers or timeout.

That's it, you are ready to configure your GPIO pins.

in the next article I'll show you step-by-step how to use the various features.



Previous: AAIMI GPIO Features

Next: Using AAIMI GPIO



Leave a comment on this article

Leave a comment on this article