Stargate Atlantis inspired Light Switch for Hue Lights!

In a previous post I made a Stargate Atlantis themed light switch, with a proximity sensor to turn lights on and off. Whilst this is pretty cool, it effectively renders my smart bulbs useless when off, so I decided to redo the project.

This time I have made use of a gesture sensor, raspberry pi, a 5v wifi usb strip and some python to bring it all together. The upside of this is that it all runs off a single 3amp 5V feed, negating the need for any mains wiring ūüôā

Dont forget a Memory Card and suitable psu for the pi. you will probably want to use a right angle adapter also as space is tight!

First off you need to print (or have a friend print!) the parts here:

Assemble the main body and thread the LEDs through mounting them as shown.

You will need 5 cables around 6″ long to go from the sensor to the pi. I tried dupont cables but ended up soldering mine as the dupont connectors were a little flakey – its up to you. wiring as below.

and I took the power for the leds from the other side, Pin 2 and Pin 6

Mount the sensor and use a little hot glue to hold it in place, ensuring enough clearance around the hole for the sensor to peek through.

Next you need your pi powered up and an SSH connection (I’m not going into that here, it’s covered here if you really need it)

first off, we need to enable the i2c interface, enter

sudo raspi-config

go to option 5 to enable the i2c interface, once done reboot

next, we need to add the required libraries for the Sensor:

sudo apt-get update
sudo apt-get install python3 python3-pip git
sudo pip3 install adafruit-circuitpython-lis3dh
sudo pip3 install adafruit-circuitpython-apds9960

Now we need the relevant libraries etc for Hue

sudo pip3 install phue

next clone the main script (this is an edited version from )
git clone
cd Hue-Gesture-Control

now edit the script with the IP of your hub on line 41 and the name of the room you are in on line 43. On the first run, also uncomment line 53, press the big button on your hue and run the script within 30 seconds.

To run, simply:

sudo python3

it takes a few seconds to initialise, but you should now be able to move up and down to turn off, and left and right to dim/increase brightness.

it’s not perfect yet, it takes multiple swipes to dim, I’m still trying to figure out a way to do it gradually in one movement

if you want to run the script on boot,

sudo nano /lib/systemd/system/PiHue.service

then enter the following

Description=PiHue Service

ExecStart=/usr/bin/python3 /home/pi/Hue-Gesture-Control/


save the file (ctrl+x)

If you got the LEDs I did, you can have fun creating an IFTTT routing to change the colour depending on the state of your lights.

Have fun, as always I welcome any feedback, suggestions or comments.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.