Menu
Microbots
0
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • ProtoBot
    • Wavelit Display
    • Modules & Parts
    • Tools & Gears
    • Coming Soon
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • English
  • Your Cart is Empty
Microbots
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • ProtoBot
    • Wavelit Display
    • Modules & Parts
    • Tools & Gears
    • Coming Soon
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

CodeCell: Alexa Lighting

In this build, we'll explore how to configure the CodeCell's onboard LED light using the Espalexa library, which allows Alexa to control devices like smart lights. We'll walk you through the process of connecting the CodeCell to your Wi-Fi, setting up the Espalexa library, and enabling voice control for the onboard LED through Alexa.


What You'll Learn

  • How to set up the CodeCell to connect to Wi-Fi.
  • How to use the Espalexa library to control the onboard LED via Alexa.
  • How to configure Alexa to recognize the CodeCell as a smart light.

About the Espalexa Library

The Espalexa library simplifies Alexa integration for ESP32 projects. It creates a virtual smart light, which Alexa can control via voice commands, without needing complex setup or cloud services. By using this library, your CodeCell can function as a smart device, like a light bulb, that Alexa can turn on, off, or dim.

Project Overview

In this project, the CodeCell is set up to connect to your Wi-Fi network. Once connected, Alexa can control the onboard LED light using voice commands, whether it's fully on (green) or off (no color).

Example:

Below is the example code to get you started. Update the Wi-Fi credentials with your network details, and follow the comments in the code to understand each step.


#include <Espalexa.h>
#include <WiFi.h>
#include <CodeCell.h>

CodeCell myCodeCell;

// WiFi credentials
const char* ssid = "SSID"; //Change to your SSID
const char* password = "PASSWORD"; // Change to your password 

// Alexa object
Espalexa espalexa;

// Function to handle Alexa commands
void alexaCallback(uint8_t brightness) {
  // Handle brightness (or ON/OFF) commands here
  if (brightness == 255) {
    myCodeCell.LED(0, 0xFF, 0);  // Full brightness, green light
  } else if (brightness == 0) {
    myCodeCell.LED(0, 0, 0);     // Turn off the LED
  }
}

void setup() {
  // Initialize serial for debugging
  Serial.begin(115200);
  myCodeCell.Init(LIGHT); /*Initializes Light Sensing*/

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");

  // Add a device to Alexa
  espalexa.addDevice("MyLED", alexaCallback);

  // Start Espalexa
  espalexa.begin();
}

void loop() {  
  espalexa.loop(); // Handle Alexa requests
}

How to Add Your Device in the Alexa App

After uploading the code and connecting the CodeCell to Wi-Fi, the next step is to add the device to your Alexa app. Follow these steps to pair it with Alexa:

  1. Open the Alexa App: On your smartphone, open the Alexa app.
  2. Go to Devices: Tap the "Devices" tab at the bottom of the screen.
  3. Add a New Device: Tap the "+" icon at the top-right corner, and select "Add Device."
  4. Select Light: Since the CodeCell will appear as a smart light, choose "Light" as the device type.
  5. Search for Devices: Alexa will now scan for new devices on your network. Wait for it to detect "MyLED" (or the name you've used in your code).
  6. Complete Setup: Once detected, tap on your CodeCell device, and follow the prompts to complete the setup.
  7. Test the Device: After the setup is complete, try giving a command like, "Alexa, turn on MyLED" or "Alexa, turn off my MyLED" to control the onboard LED!

With these steps, your CodeCell's onboard LED is now fully integrated into your smart home setup, and you can control it with Alexa voice commands or the Alexa app!

Tips for Customization

  • Experiment with Colors: Modify the LED color output in the alexaCallback() function to use different colors based on Alexa’s brightness level. You can use RGB values to create various effects.
  • Add more LEDs: Control RGB strip lights or NeoPixels through the CodeCell's GPIOs.
  • Additional Controls: Expand the project by adding multiple LED control points or combining with other CodeCell features like motion sensing or light monitoring.

Conclusion

This project demonstrates how to integrate the CodeCell with Alexa using the Espalexa library to control the onboard LED light. By following this example, you can easily build voice-activated projects with CodeCell, bringing IoT capabilities into your hands!

Get creative with the customization options and bring more of your projects to life with Alexa integration!

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2026 Microbots.

★ Reviews

Let customers speak for us

83 reviews
Write a review
87%
(72)
5%
(4)
2%
(2)
2%
(2)
4%
(3)
77
21
G
Experiment in Progress Mug
Gerald Kendrick

I am enjoying my Experiment in Progress coffee mug. It fits in well in the lab.

K
12-in-1 Screwdriver (Pen-Size)
Klaas

Very useful fun little screwdriver for the all tiny stuff

f
ProtoBot
frederic marty

I don't have much time right now to test the micro bot, but it looks good.

f
MotorCell
frederic marty

I don't have much time right now to test it but it looks good.

M
ProtoBot
Mehmed Muslija

ProtoBot has met all my expectations.
Watching one of the videos on YouTube, I thought it would be interesting and educational to make a small project for my 8 year old cousin. ProtoBot has provided a wide range of experiences and encouraged my cousin to take on new projects.

User picture
123