Control a Bluetooth LE Light Bulb With Raspberry Pi

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.control a bluetooth le light bulb with raspberry pi

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.control a bluetooth le light bulb with raspberry pi

Requirements :

• Raspberry Pi B/B+/2/3/A/A+/ZERO

Yeelight Blue

Bluetooth 4.0 USB Module

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


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top