Smart RGB Lamp Controlled Via ESP NOW

Introduction: Smart RGB Lamp Controlled Via ESP NOW

About: I'm just trying to make the world at least a little bit better.

In this project I'm going to show you how to make a smart RBG lamp which can be easily controlled remotely using the ESP NOW protocol.

Supplies

Version without remote control:

1) ESP32 x1

2) 128x32 OLED display x1

3) 470 ohm resistor x1

4) 20k potentiometers x3

5) Buttons x2

6) WS2812 LEDs (as much as you need)

7) 5V power supply x1


Remotely controlled version:

1) ESP32 x1

2) ESP8266 x1

3) 128x32 OLED display x1

4) 470 ohm resistors x2

5) 20k potentiometers x2

6) Buttons x2

7) WS2812 LEDs (as much as you need)

8) 5V power supplies x2

Step 1: Install the Drivers and Configure Arduino IDE *optional

If you've never flashed ESP32 or ESP8266 before you'll need to configure Arduino IDE and install drivers to upload the firmware to the boards, you can find drivers here:

CH340 driver for ESP8266: https://sparks.gogo.co.nz/ch340.html

CP210x driver for ESP32: https://www.silabs.com/developers/usb-to-uart-brid...

In case you don't have Arduino IDE, you can download it here: https://www.arduino.cc/en/software

Configuring IDE isn't a part of this tutorial, you can read about it here:

ESP32: https://randomnerdtutorials.com/installing-the-esp...

ESP8266: https://randomnerdtutorials.com/how-to-install-esp...

Step 2: Build the Circuit

I've included both schematic and circuit diagrams to make it easier for you.

Step 3: Schematic Diagram

Step 4: Circuit Diagram

Step 5: Download the Firmware

You can download the firmware here https://github.com/Northstrix/Smart-RGB-lamp-contr...

Adjust one of those variables if you need.

#define LED_PIN 13 // WS2812 data pin
#define LED_COUNT 4 // Number of LEDs
int br = 127; // Default brightness (0 - 0%; 127 - 50%; 255-100%)
int dd = 50; // Debounce delay for brightness buttons

I've used the Adafruit NeoPixel library to control the strip, you can find the official documentation for this library here: https://learn.adafruit.com/adafruit-neopixel-uberg...

Step 6: Flash ESP32

Upload the firmware that you've just downloaded to the ESP32.

Step 7: Test the Device

It's time to test the intermediate result.

Rotate the potentiometers to adjust hue and saturation.

Press the buttons to change the brightness.

Hold two buttons simultaneously for half a second to change the mode.

Note: You can only change the brightness in the default mode and the lamp mode.

Step 8: Default Mode

Nothing unusual, just fill the whole strip with the selected color.

  • Rotate the potentiometer attached to the D34 pin for rough hue adjustment.
  • Rotate the potentiometer attached to the D35 pin for precise hue adjustment.
  • Rotate the potentiometer attached to the D25 pin for saturation adjustment.
  • Press the button attached to D33 pin to the increase the brightness.
  • Press the button attached to D32 pin to the decrease the brightness.

Step 9: Rainbow Mode

Fills the whole strip with every color of the rainbow. Color changes automatically.

Step 10: Slow Rainbow Mode

The same as the rainbow mode, but takes about an hour to complete the cycle.

Step 11: Lamp Mode

Turns the whole strip into a lamp with controllable brightness.

  • Press the button attached to the D33 pin to increase the brightness.
  • Press the button attached to the D32 pin to decrease the brightness.

Step 12: Shinning Moon Mode

Fills the whole strip with the fully saturated white color, and sets the peak brightness.

Be careful, using this mode for a long time can damage your strip.

Step 13: Make a Lamp

This step is entirely up to you. Choose any shape and size you like and don't forget to count the number of LEDs in your lamp. I took a CN Tower in Toronto as an inspiration for my lamp.

Step 14: Moving Forward

It's time to get to the part when this device becomes remotely controlled.

By the way, if you don't need the wireless capability of this device you can stop here.

Step 15: Get the MAC Address of the Receiver Board

To get the MAC address of the board upload this code to the board.

#include <ESP8266WiFi.h>

void setup(){
  Serial.begin(115200);
  Serial.println();
  Serial.println(WiFi.macAddress());
}
 
void loop(){

}

Then open the serial monitor, and reboot the board.

If done correctly, you should see the MAC address in the console.

The MAC address of this board is 5C:CF:7F:FD:85:1D

Step 16: Flash the Transmitter Board

For some unknown reason, ESP32 stopped measuring the voltage on the D25 pin after I've included an ESP NOW library that's why there are two potentiometers instead of three, so I've decided to sacrifice the saturation adjustment feature. If you have a solution to this problem please post it down in the comment section.

You can find the firmware here https://github.com/Northstrix/Smart-RGB-lamp-contr...

Don't forget to adjust the number of LEDs attached to the transmitter, set the saturation, and replace the MAC address in the firmware with the MAC address of your receiver board.

#define LED_COUNT 4 // Number of LEDs
int sat = 255;
uint8_t broadcastAddress[] = {0x5C, 0xCF, 0x7F, 0xFD, 0x85, 0x1D};

Step 17: Flash the Receiver Board

You can get the firmware here https://github.com/Northstrix/Smart-RGB-lamp-contr...

Don't forget to adjust the number of LEDs and set the saturation.

#define LED_COUNT 60 // Number of LEDs
int sat = 255;

Step 18: Connect the Lamp to the Receiver Board

Connect the 470-ohm resistor between the D4 pin of the ESP8266 and the DI pin of the WS2812 LED strip.

Connect the GND pin of the ESP8266 to the GND pin of the WS2812 LED strip.

Connect the third pin of the ESP8266's power convertor to the +5V pin of the WS2812 LED strip.

And don't forget to connect the capacitors.

Step 19: Test the Device

Note that I removed two modes from the wireless version: rainbow and slow rainbow.

Step 20: Conclusion

Although this project is raw and no more than an MVP I believe it can one day become a fully functional smart lamp controlled not just via ESP NOW protocol, but also via Alexa or Telegram. If you like this project and you can make it better, please write a couple of your effects, modes, or features for this lamp, post the code on GitHub, and leave the link to the code in the comment section. With your help, this lamp can become an open-source alternative to the products that are already on the market or even better.

Thank you so much for reading this tutorial.

Colors of the Rainbow Contest

This is an entry in the
Colors of the Rainbow Contest

Be the First to Share

    Recommendations

    • Furniture Contest

      Furniture Contest
    • Arduino Contest

      Arduino Contest
    • Barbecue Speed Challenge

      Barbecue Speed Challenge

    Comments

    1
    Build_it_Bob
    Build_it_Bob

    2 days ago

    Hi Northstrix, I like the project and using the ESP NOW protocol. I also found that ESP NOW can be finicky due to timing, but it works well for many applications. I like that you presented the Instructable, and left it open to the community to add any suggestions or ideas.
    Keep up the great work, I am looking forward to reading through your other Instructables.
    Thanks for sharing,
    Bob D