8.5 CheerLights

CheerLights is a global network of synchronized lights that can be controlled by anyone.

Join the @CheerLights LED color-changing community, which allows LEDs around the world to change colors simultaneously.

You can place your LEDs in a corner of your office to remind yourself that you are not alone.

In this case, we also utilize MQTT, but instead of publishing our own messages, we subscribe to the “cheerlights” topic. This allows us to receive messages sent by others to the “cheerlights” topic and use that information to change the color of our LED strip accordingly.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

ESP32 Starter Kit

320+

ESP32 Starter Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

ESP32 WROOM 32E

BUY

ESP32 Camera Extension

-

Jumper Wires

BUY

WS2812 RGB 8 LEDs Strip

BUY

How to do?

  1. Build the circuit.

    ../../_images/iot_5_cheerlight_bb.png
  2. Then, connect ESP32-WROOM-32E to the computer using the USB cable.

    ../../_images/plugin_esp32.png
  3. Open the code.

    • Open the iot_5_cheerlights.ino file located in the esp32-starter-kit-main\c\codes\iot_5_cheerlights directory, or copy the code into the Arduino IDE.

    • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.

    • Always displaying “Unknown COMxx”?

    • The PubSubClient and Adafruit_NeoPixel libraries are used here, you can install them from the Library Manager.

      ../../_images/mqtt_lib.png
  4. Locate the following lines and modify them with your <SSID> and <PASSWORD>.

    // Replace the next variables with your SSID/Password combination
    const char* ssid = "<SSID>";
    const char* password = "<PASSWORD>";
    
  5. Find the next line and modify your unique_identifier. Guarantee that your unique_identifier is truly unique as any IDs that are identical trying to log in to the same MQTT Broker may result in a login failure.

    // Add your MQTT Broker address:
    const char* mqtt_server = "mqtt.cheerlights.com";
    const char* unique_identifier = "sunfounder-client-sdgvsasdda";
    
  6. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button.

  7. At this point, you can see that your RGB strip is displaying a certain color. Place it on your desk and you will notice that it periodically changes colors. This is because other @CheerLights followers are changing the color of your lights!

  8. Open the Serial Monitor. You will see messages similar to the following:

WiFi connected
IP address:
192.168.18.77
Attempting MQTT connection...connected
Message arrived on topic: cheerlights.
Message: oldlace
Changing color to oldlace

Control global @CheerLights devices

  1. Join the Discord Server and utilize the CheerLights bot to set the color. Simply type /cheerlights in any of the channels on the CheerLights Discord Server to activate the bot.

    ../../_images/sp230511_163558.png
  2. Follow the instructions provided by the bot to set the color. This will allow you to control CheerLights devices globally.

    ../../_images/sp230511_163849.png