Warning: Declaration of Db::query($query) should be compatible with mysqli::query($query, $resultmode = NULL) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 29

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Cannot modify header information - headers already sent by (output started at /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php:0) in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 168

Warning: session_start(): Cannot start session when headers already sent in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 169

Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64
jobs.html_title
2

members

Easy Raspberry basics: Project 13a Raspberry PI 3 model B board - Node-RED and Xiaomi Yeelight Smart Bulb

of Lex C. in Raspberry Pi 3

Raspberry basics: Project 13a

Project name: Raspberry PI 3 model B board - Node-RED and Xiaomi Yeelight Smart Bulb

Tags: Raspberry, Raspberry PI 3 model B board, Node-RED, Xiaomi Yeelight Smart Bulb

In this project, you need these parts :

1.Raspberry PI 3 model B 1 pc

2. Micro SD card and SD card adapter 1 pc

3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

7. Xiaomi Yeelight Smart Bulb RGBW – E27 AC220V or Xiaomi Yeelight Smart Bulb RGBW – E26 AC110V

General

We will learn how to integrate Xiaomi Yeelight Smart Bulb with Node-RED on Raspberry PI 3 model B board.

We will make a web application with Node-RED and Raspberry Pi to control the Yeelight lamp.

You need Node-RED installed on your Raspberry PI 3 and Node-RED Dashboard.

Project notes:

  • The Xiaomi Yeelight RGBW Smart Bulb will be controlled using the Yeelight node which we install;
  • We will have a color picker or a drop-down menu to change the bulb color in application;
  • The application allows us to change the temperature and brightness too;
  • We will have the Toggle button. If you press this button when the lamp is ON, the lamp turns OFF and vice versa.

Understanding Yeelight RGBW E27 Smart LED Bulb

Yeelight RGBW E27 Smart LED Bulb is a great addition to Xiaomi Yeelight Series, which enhances the lighting experience of your daily life. It features 16 million colors RGB light and 1700 - 6500K adjustable white light, offering you the most wonderful ambient lighting. With WiFi technology, you can control your light from your bedroom to your backyard. What's more, is has a ultra long lifetime of up to 11 years. Therefore, you don't even have to think about replacing a bulb!

Main Features:

  • 16 millions colors at your fingertip, romantic ambient light decorates your life
  • 1700-6500K adjustable white light: Wide range temperature adjustment, fulfilling all your needs
  • WiFi remote control: Stable and high-speed transmission, everything is just in your hand
  • More possibilities: Works with MIJIA, IFTTT and supports open API
  • Ultra long lifetime of up to 11 years, you don't even have to think about replacing a bulb
  • Capable of providing fancy lighting for 30sq.m.room
  • Group control: Control a singe bulb or group bulbs all at your fingertip
  • Easy to use, install the bulb, download the App, connect the bulb to your network, then enjoy smart lighting. Read more about the Yeelight app here.

Please NOTE: change the language setting on your phone to English, and then download the Xiaomi Smart Home App, it will change the language of the App to English as well.

Work with IFTTT - brings everything together

If This Then That ( or IFTTT ) is both a website and a mobile app that launched in 2010 and has the slogan 'Put the Internet to work for you'. The idea is that you use IFTTT to automate everything from your favorite Apps and websites to App-enabled accessories and smart devices. IFTT has become the ultimate automation service for small tasks between Internet-connected services. Whether on the Web or with selected Apps for iOS and Android, IFTTT can handle anything its member service 'channels' support. When user-specified events occur, follow-up tasks are triggered and handled. There are numerous combinations ( also called 'recipes' ) on IFTTT that can make your life easier. These links consist of just two elements: a Trigger ( If This ) and an Action ( Then That ) – For example, If you own a Xiaomi smart light, you could use IFTTT to automatically turn on the light every time you're tagged in a Facebook photo. In another example, you could set your light to be turned on, if the motion is detected in your home when you're not at home. 
The product has passed Alexa certification and could be voice controlled by Amazon Echo

Specifications:

General

Brand: Yeelight 

Model: YLDP02YL 

Holder: E27 

Output Power: 9W 

Voltage (V): AC 220 

Luminous Flux: 600LM 

Lifespan: 11 years 

Features: Dimming,Remote Control,WiFi 

Function: Commercial Lighting,Home Lighting,Studio and Exhibition Lighting 

Available Light Color: RGBW 

Body Color: Silver 

Sheathing Material: Aluminum Alloy,Plastic

Dimension and Weight

Product weight: 0.1450 kg 

Package weight: 0.2500 kg 

Product size (L x W x H): 12.00 x 5.50 x 5.50 cm / 4.72 x 2.17 x 2.17 inches 

Package size (L x W x H): 13.00 x 6.50 x 6.50 cm / 5.12 x 2.56 x 2.56 inches

Package Contents

Package Contents: 1 x Yeelight YLDP02YL Color LED Bulb

Understanding the Raspberry PI 3 model B

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

Specification:

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

Signals and connections of the Raspberry PI 3 model B


Step by Step instruction

We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.

1. Setup and preparation

We assume that you have Windows 10 installed on your PC and Raspbian OS installed on your Raspberry PI 3 board.

  1. Insert your micro SD card with Raspbian OS to Raspberry Pi 3 board.
  2. Connect the TV or PC monitor Display port (HDMI Port) to your Raspberry PI 3 board HDMI Port (HDMI cable required).
  3. Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1,  etc).
  4. Plug in your USB mouse and USB keyboard to Raspberry PI 3 board USB ports.
  5. Get connected. Connect an Ethernet cable to 10/100 LAN port of Raspberry Pi 3 or plug in WiFi adapter (see the list of supported here) to USB port of Raspberry Pi 3.
  6. Connect Micro USB power supply to Raspberry PI 3 board micro USB input.
  7. The Raspberry PI desktop will start up.
  8. Open Terminal window and type the command: sudo apt-get update
  9. Then type the command: sudo apt-get install 

2. Install Node-RED and Node-RED Dashboard on your Raspberry PI 3.

3. Enable LAN Control

When the Yeelight bulb connected to our router, we go to your Yeelight app and enable the LAN Control.

 

  1. Select the Yeelight Color Bulb.
  2. Open the bottom right menu and choose the LAN Control option.
  3. Tap the enable button.
  4. You are ready for next step as your Node-RED flow can interact with the Yeelight bulb now. 

4. Installing the yeelight Node-RED node

  1. To control the Yeelight with Node-RED, first you need to install node-red-contrib-yeelight. In the Terminal window type the commands: 
  2. node-red-stop
  3. cd ~/.node-red
  4. npm install node-red-contrib-yeelight

5a Creating Node-RED flow

  1. To start Node-RED enter the command: node-red-start
  2. Type this command to find out your IP address: hostname -I  In our case it is 192.168.0.121.
  3. To access Node-RED go to any Web browser on your PC.
  4. Locate the address bar at the top and type intype http://your_Raspberry_Pi_IP_address:1880 (in our case that is http://192.168.0.121:1880) then press Enter button. This will display the Node-RED. 
  5. Make sure you have the yeelight node. If you don’t have the node check that you have followed the steps above.
  6. Select Color Picker, Slider x2, Dropdown, Button from Dashboard, Function from Function, yeelight x 5 from MiHome.

  7. Make a tab Room 1, Yeelight Smart Bulb group in Room1. How to create tab and group you can find here.
  8. See the settings for tab and group below.
  9. Let's modify nodes now. See the Color picker settings below.
  10. See the Function node settings below:
  11. Add these lines in Function filed - 
  12. msg.payload = msg.payload.replace(/[#]/g,"0x");
  13. return msg;
  14. See the settings for Set PGB color node (it is modified yeelight toggle node):
  15. Modify one Slider node with settings below:
  16. See the settings for Set Brightness node (it is modified yeelight toggle node):
  17. Modify one Slider node with settings below:
  18. See the settings for Set Temperature node (it is modified yeelight toggle node):
  19. Modify one Dropdown node with settings below:
  20. See the settings for Set RGB Color node (it is modified yeelight toggle node):
  21. Modify one Button node with settings below:
  22. See the settings for Toggle node (it is modified yeelight toggle node):
  23. Connect all nodes. See the picture below.
  24. As you can see this flow is very complex. We recommend importing the flow (see the section below how to do it) instead of make it from the begining.

5b Importing the Node-RED flow

  1. To start Node-RED enter the command: node-red-start
  2. Type this command to find out your IP address: hostname -I  In our case it is 192.168.0.121.
  3. To access Node-RED go to any Web browser on your PC.
  4. Locate the address bar at the top and type intype http://your_Raspberry_Pi_IP_address:1880 (in our case that is http://192.168.0.121:1880) then press Enter button. This will display the Node-RED. 
  5. Make sure you have the yeelight node. If you don’t have the node check that you have followed the steps above.
  6. To import the Node-RED flow provided click here to download and view the file. Copy the code provided in file.
  7. At the top right corner of Node-RED select the menu, and go to Import  -> Clipboard.
  8. Paste the code and click on Import button.

 

6. Adding Yeelight bulb IP address

 

  1. You can use the an IP scanners like Advanced IP Scanner or Angry IP Scanner to scan for your Yeelight bulb IP address. In our case the Yeelight’s IP address is 192.168.0.124.
  2. Double-click on each Yeelight’s node:
  3. We will show you an example with one node which is valid for all five Yeelight nodes. Make a new config node. Press on pen sign and enter your Yeelight bulb IP address (we have 192.168.0.124) with default port 55443. Click on Add button and then click on Done button.
  4. After making all changes click on Deploy button to save all the changes.
  5. Your Node-RED application is ready. To access Node-RED UI and see how your application looks open any web browser in your local network and type: http://Your_RPi_IP_address:1880/ui (in our case it is http://192.168.0.121:1880/ui).
  6. Your application should look as example below.
  7. You can control your Xiaomi Yeelight Smart Bulb with Node-RED now.

Summary

We have learnt how to integrate Xiaomi Yeelight Smart Bulb with Node-RED on Raspberry PI 3 model B board.

Library

  • No libraries needed in this project

Sketch

  • No sketches needed in this project


Other projects of Lex C.

jobs.published_at
jobs.viewed