DIY Projects

DIY Alexa controlled RGB Smart bulb using ESP8266

Learn how to build an RGB LED smart bulb using ESP8266 controlled by Amazon Alexa.

In this Project you will learn how to build an Amazon Alexa controlled RGB Smart LED bulb by interfacing ESP8266 node MCU with WS2812b Neopixel LCD strip. This is a simple ESP8266 project the connections are simple and you can build the smart bulb with in few minutes.

Now a days due to the smart home revolution, people are moving towards smart IoT products which can ease the day today activity. There are wide variety of smart products like smart door locks, smart CCTV cameras, Smart switches, Smart temperature controlled fans, Smart Refrigerators, Smart lights and everything is adopted to smart features with Internet connectivity to monitor and control them from smart phones and AI assistants.

Taking this into consideration lets build a cheap DIY smart RGB LED bulb to beat the markets costly smart bulbs.

Related project: DIY Smart LED strip with Sound reactive effects using ESP8266 or ESP32

Required components:

Here are the required components along with Amazon buying links at best prices.
Product NameQuantityamazon logoamazon logo india
ESP8266 Node MCU or D1 Mini1
WS2812b LED stripYour Choice
220v AC to 5v DC converter1
Micro USB cable1

WS2812b Pinout Diagram:

ws2812b pinout diagram

As you see from the above pinout diagram the WS2812b LED strip has 3 pins, 2 pins for power supply 5v and GND and the middle pin is for data. Every LED has a chip which stores the data of the color which it has to show and the data of the next LEDs. The data flows from the starting to the ending LEDs, make sure to connect the data pin from the microcontroller from the beginning arrow printed on the LED strip.

For more details about Neopixel LEDs refer : How NeoPixel LED works in detail

Circuit Diagram:

Connect all the required components according to the below circuit diagram.

interfacing nodemcu with WS2812b circuit diagram

To reduce the space and cost you can also use D1 mini microcontroller instead of Node MCU.

As you can see from the above image we powered Node MCU and LED strip from the HiLink 100-240v AC supply to 5V DC converter. If its not available you can also use any mobile charger circuit to power it.

As we are using only 6 LEDs Strip, each LED consumes 50mA at maximum brightness so 6 consumes nearly 300mA you can choose the number of LEDs according to the requirement. So choose a minimum of 5v 0.5A converter for better stability.

VIN and GND pins of Node MCU are connected to +ve and -ve pins of Converter supply respectively.

+5v and GND pins of LED strip are connected to +ve and -ve pins of Converter supply respectively. Din pin of LED strip is connected to digital pin D3 of Node MCU. A resistor of 330 ohms is connected between data pin to protect the LED strip first LED from voltage fluctuations which may cause damage to it.

Program code:

Connect the NodeMCU to the PC where Arduino IDE is installed through USB cable. For safely don’t connect the AC power supply while uploading the code. Choose the correct port and board as Node MCU V1 from Tools menu and install the required libraries from the Library manager of download from the below links and extract them in Arduino Libraries folder.

Required Libraries:

  • Download FastLED library : Link
  • Download ESP8266WiFi library: Link
  • Download Espalexa.h library: Link

Next copy the below code and paste it in IDE workspace change the WiFi credentials and press upload button. That’s it the code will be uploaded.

You can also implement this :Change WiFi Credentials of ESP8266 without uploading code again

After uploading the code, Turn on the Alexa echo device which is connected to the same network.

The library aims to work with every Echo on the market, but there are a few things to look out for.

Espalexa only works with a genuine Echo speaker, it probably wont work with Echo emulators, Raspberry Pi homebrew devices or just the standalone mobile app.

Next open Amazon Alexa app on mobile, from bottom menu choose “More” and from that click on “Add a Device”. From the list of All devices choose ‘other’ option at the bottom. then click on “DISCOVER DEVICES” as shown in the steps screenshots below.

adding alexa smart bulb to alexa device through mobile app

After scanning you will find a light, so click on setup and choose the group and done. Now you can turn on/ off , change the brightness and even colors of the bulb.

alexa smart bulb setup and settings

Fixing the LED strip and components into bulb:

Take a normal LED bulb and remove the LEDs and drivers from it to make space for our smart LED, Connect the AC point of the bulb to Ac to 5v DC converter and place the LCD strip in such a way that it emits max brightness towards the diffuser. That’s it.

Errors and Solutions:

wl_definitions.h: No such file or directory

You will get this error if you use the latest version of the ESP8266WiFi library. Remove it and download it from the above links and extract it in libraries folder, the error will disappear.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles


  1. I made this projet, works with Alexa but do not turn on more than 1(ONE) LED and the blue does not work.
    I change the strip with the same problem.
    In the serial monitor I can see the command been sent, but looks like the D3 pin do not send the blue part of the command.
    Can you help me?

    1. hi Jose,
      had you set the number of LEDs in this line #define NUM_LEDS1 6
      use the library versions we have given.
      You can use other pins D1 or D2 or D4 and also change the pin info in code.
      things to note:
      Is powersupply suffient for LEDs.
      Is Wiring is good.

Leave a Reply

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

Back to top button