This is a fun project that shows how to control a smart light bulb (Yeelight Blue) that uses Bluetooth Low Energy (BLE) to change its color with Raspberry Pi! bulb recently at a local store and was intrigued by its Bluetooth-based control and relatively low price (for a ‘smart’ gadget at least). Because the light bulb uses Bluetooth Low Energy (which is a subset of Bluetooth 4.0) it means any BLE device can in theory control the bulb. I bought a Yeelight Blue bulb. To control the light, I used the Raspberry Pi and Bluetooth 4.0 USB Module.
Yeelight Blue is your personal scene lighting. It enables you to create and control light using your smart phone with Bluetooth 4.0. The LED technology inside every yeelight blue can display 500 lumens high quality white light and a wide variety of 16 million colors. And each yeelight blue bulb uses 90% less power than a traditional light bulb.
Requirements :
• Raspberry Pi B/B+/2/3/A/A+/ZERO
1. Install Required Librarie
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
2. Download Bluez
sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.31.tar.xz
3. Unzip and Compile Bluez
sudo unxz bluez-5.31.tar.xz
sudo tar xvf bluez-5.31.tar
cd bluez-5.31
sudo ./configure --disable-systemd
sudo make
sudo make install
4. Insert the USB Module and Reset
Once Bluez has been built, shut down your computer with sudo shutdown -h
now and once its Halted, insert your Bluetooth 4.0 USB Module and then reset the Raspberry Pi so that all of the changes we have made can take effect.
5. Install Bluez’s GATT tool
Manually install bluez’s GATT tool. For some reason bluez does not install its GATT tool anymore as this bug notes, however an easy workaround is to manually install it by executing this command inside the bluez source directory after it has been compiled and installed:
sudo cp attrib/gatttool /usr/bin/
Confirm you can access gatttool by running ‘gatttool –help‘ (without quotes) to see the usage information of the tool. If you see an error that gatttool can’t be found, double check it has been compiled by bluez and it’s in to the /usr/bin/ directory.
For more detail: Control a Bluetooth LE Light Bulb With Raspberry Pi