Anth's Computer Cave

Use QuickFloor Base to control lights

16th April 2015

Today I'll show you how to import a simple module into QuickFloor Base and use the system to control lights.

The module we will import is called, and it is in the Quickfloor setup folder. The main QuickFloor file,, already has the code to import and use the relay module, you just need to uncomment a few lines to make it work.

On line 25 in, uncomment the line that reads import relay.

Picture: Anthony Hartup

Then, on lines 142 and 146, uncomment relay.on(i) and

Picture: Anthony Hartup

Next you'll need to connect some relays and relay-drivers to your Raspberry Pi and configure the file. If you are new to relays click here for a complete guide on using relays and then here for a guide on relay-driver circuits.

The relay module has the option to run six lights, but I am only using two during testing so I have commented the other four relays out.

In the image below you can see I am using GPIO pins 4 and 17 to run the relays.

Picture: Anthony Hartup
Raspberry Pi relay connections. Picture: Anthony Hartup

To use a third relay you would uncomment line 13 ("light3 = 21") in and connect the relay to GPIO 21.

Picture: Anthony Hartup
Enable third relay.

You would also need to uncomment lines 24 and 25 to enable light3.

Picture: Anthony Hartup

The relay modules is set to work with the floor plan we used in the previous article. It uses the same device names I gave the lights in that plan.

You'll need to change the names on lines 36 and 38 ('loungeLight', 'kitchenLight') to match the device names you used in your QuickFloor plan.

Picture: Anthony Hartup

To use a third relay you would uncomment lines 40 and 41 and change "hall1" to the device name of your third light.

Run QuickFloor

To use the relay module you will need to run QuickFloor Base with root privileges. To do this, open a terminal on your Raspberry Pi and type:

sudo idle3

Once Idle loads click File and Open. Navigate to the quick_floor folder and select

When the code window opens click Run and select Run Module.

Picture: Anthony Hartup

Enter the save name you used for your QuickFloor plan.

Here is my plan from the last article.

Picture: Anthony Hartup

When I click on the light symbol in the Lounge the lamp in my lounge switches on.

Picture: Anthony Hartup

The light symbol on the floor plan turns orange to show that the lamp is currently on.

Click the light again and the lamp turns off, and the light symbol turns gray again. Please note that this can be addictive, and you may need someone to tell you to stop turning that f#*!ing light on and off!

Picture: Anthony Hartup

Because I only have two relays connected I can only switch the kitchen and lounge lamps. If I click the light symbol in any of the other rooms the symbol will turn orange but nothing else will happen.

So there you go. I have created an extra simple relay script and, using Quickfloor, I have turned it into a powerful light-control system.

Next for QuickFloor

I am aiming for a frequent release-cycle for new versions of QuickFloor Base.

Each new version will provide support for new devices such as light and temperature sensors, smoke and gas detectors, as well as occupancy sensors.

I'll also build on the sample program we have used today to provide usage examples for these devices.

Soon after the next release, QuickFloor Base 0.2, the AAIMI Project will release their first home-automation program using the QuickFloor GUI system.

Stay tuned for more QuickFloor news.



Previous article:QuickFloor Base, a ready-made home-automation GUI




Leave a comment on this article

Leave a comment on this article