With this set up you can control any Light Bulb connected to your Philips Hue Bridge. You can toggle the light, change the brightness and change the color temperature. Here you can learn how!
All the componentes you need for realising this project. It's a complete list with amazon affiliate links:
- Raspberry Pi 4 (or 3 or 2 or Zero W)
- Mouse & Keyboard
- Monitor
- Philips Hue Bridge
- Philips Hue Lamp White Ambiance
- Fritz!Box
- Breadboard & Jumper Wires
- 10k Resistors
- Push Buttons
I realise that there are some expensive components included but I already had most of it at home. You may have some equipment already, too.
- Your Rapberry Pi is running the newest version of Raspbian
- Your Router, Hue Bridge and Hue Lamp are connected and set up and it is possible to control the light via the Philips Hue App or your Smart Home App of choide (Apple Home, etc.)
- You have physical access to the Hue Bridge
In order to talk to our Hue Bridge we need its IP address. We can get it from the FRITZ!Box or from our router or DHCP server if we have access to those.
Another easy way to get the IP address with your raspberry pi is this:
Install nmap by opening the terminal and typing
sudo apt install nmap
and then run the command
namp -sP 192.168.178.0/24
Adjust the IP address for your own network.
The output looks something like this:
Starting Nmap 7.80 ( https://nmap.org ) at 2021-12-21 20:34 CET
Nmap scan report for fritz.box (192.168.178.1)
Host is up (0.0089s latency).
Nmap scan report for homebridge.fritz.box (192.168.178.21)
Host is up (0.0072s latency).
Now that you have the IP address of your hue bridge write it down. We're gonna need it for the code.
Here is a wiring diagram. Use 10k resistors and wire up everything like on the schematics.
Just open up a terminal and type:
pip install phue
Now you are good to run the code!
Just clone the repository or download it to your computer. Open a terminal and navigate to the folder where the python file is located and run it with
python hue_control.py
The video in the next sections shows the setup in action. Enjoy!