Project tutorial
Voice Controlled RGB Lamp

Voice Controlled RGB Lamp © LGPL

Make an Alexa clone using Raspberry Pi 3 and use it to control IOT RGB Lamp (Arduino Nano + ESP8266) that supports Philip Hue commands.

  • 3,644 views
  • 1 comment
  • 13 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

In this project I make a smart speaker with Alexa built in (Raspberry Pi 3), and an IoT RGB lamp, which connects to the internet. I use speaker to get feedback from Alexa.

How to Use

We can use Alexa to change the lamp's brightness and color using Philip hue commands:

1. Setting Hue Scenes

Turn on {scene}. For example: Turn on Relax

Scene: sunset, pencils, Deep sea, Kathy, Beach, Sky, Feet up, Blue rain.

2. Color Commands

Change the colors of bulb or rooms using these commands:

  • Turn on/off {specific light}
  • Set {light} to fifty percent
  • Turn my {light} light green.
  • Brighten to 60 percent or dim the lights.

This is sample color list (we can expand it easily using color code table):

  • "Turn the lights Tomato" – a nice shade of pink (#FF6347)
  • "Turn the lights Peru" – nice at-home champagne color (#CD853F)
  • "Turn the lights Firebrick" – A dark red warm color scene (#B22222 )
  • "Turn the lights Light Salmon" – A warm light pinky red color (#FFA07A)
  • "Turn the lights Dark Khaki" – A dark green color (#BDB76B)

All color and scenes are preset. Creating and editing theme will be supported later.

List of colors: A–F

The point is making affordable IoT devices. That's why I used Raspberry Pi 3 (so that I can reuse it later), cheap Arduino mini board and module ESP8266 (ESP-01). Thanks to Amazon for free AWS.

Using Arduino allows easily adding features like some sensors if needed.

How to Make

Step 1: Install Alexa on Raspberry Pi 3:

Follow the instruction here. There are many errors when I tried to install Alexa. After install sample application in my Raspberry Pi, Alexa returns no sound, here is the resolution for me. I hope it can help someone save time.

Step 2: Create a Smart Home Skill and Connected Lambda:

Follow the instruction here. But Alexa couldn't find devices: Alexa smart home discovery is not working. I spent a day to configure out. It was region problem. This is resolution.

Step 3: Create an IoT Thing, Connect your Lambda to your Thing:

You can follow these steps. More information here.

Step 4: Set up your ESP8266 and Arduino mini.

I use Arduino mini + ULN2003A to drive LED. +12V power is required for LEDs, so I put an DC-DC converter to get 3.3V for Arduino and ESP8266 module and put a 470uF tantalum capacitor. I used my CP210x USB-TTL converter to program both ESP8266 and Arduino.

Here are ESP8266 instructions.

Code

SetColorArduino
Se tcolor function - Arduino
#define redPin 5
#define greenPin 6
#define bluePin 3

void setup() {
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);
}
void loop() {

    delay(1000);  

}
void setColor(int redValue, int greenValue, int blueValue) {
    analogWrite(redPin, redValue);
    analogWrite(greenPin, greenValue);
    analogWrite(bluePin, blueValue);
}
ESP8266 - AWS IoTArduino
Connect to AWS IoT
#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include "ESP8266AWSImplementations.h"

Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;

AmazonIOTClient iotClient;
ActionError actionError;

char *ssid="***";
char *password="***";


void setup() {
  //ESP.wdtDisable();
  ESP.wdtEnable(30000);

  Serial.begin(115200);
  delay(100);


  // Connect to WAP
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  iotClient.setAWSRegion("us-east-1");
  iotClient.setAWSEndpoint("amazonaws.com");
  iotClient.setAWSDomain("a3aph76rnqfrwl.iot.us-east-1.amazonaws.com");
  iotClient.setAWSPath("/things/GRBLamp/shadow");
  iotClient.setAWSKeyID("AKIAJWWNWVWFPNTYWS**");
  iotClient.setAWSSecretKey("BdVe1iw+2XxhyiDdc7tup1SBuuycwMnXfOM41W**");
  iotClient.setHttpClient(&httpClient);
  iotClient.setDateTimeProvider(&dateTimeProvider);

}

void loop(){

  char shadow[100];
  strcpy(shadow, "{\"state\":{\"reported\":{\"test_value1\":123, \"test_value2\":234}}}");
  
  ESP.wdtDisable();
  Serial.println("Trying to send data");
  ESP.wdtEnable(30000);
  
  
  yield();
  ESP.wdtDisable();
  Serial.print(shadow);
  ESP.wdtEnable(30000);
    
  yield();
  char* result = iotClient.update_shadow(shadow, actionError);

  ESP.wdtDisable();
  Serial.print(result);
  ESP.wdtEnable(30000);

  delay(5000);

}

Schematics

Basic connection
Connect Arduino + ESP8266 + ULN2003 + RGB LED
untitled_sketch_2_tORBs8qp5A.fzz

Comments

Similar projects you might like

DIY Air Humidifier with Backlight Controlled by Alexa

Project tutorial by Andrii Romanenko

  • 1,155 views
  • 0 comments
  • 6 respects

Smart Pool: Alexa Controlled Pool Manager

Project tutorial by Benjamin Winiarski

  • 1,358 views
  • 2 comments
  • 7 respects

Voice Controlled K'nex Car

Project tutorial by Austin Wilson

  • 9,820 views
  • 4 comments
  • 52 respects

Voice Activated Media Appliances Using Arduino and Alexa

Project tutorial by Patel Darshil

  • 4,135 views
  • 2 comments
  • 19 respects

Remote and Voice Controlled Smart Fan

Project tutorial by Paul Trebilcox-Ruiz

  • 4,050 views
  • 3 comments
  • 19 respects

RGB Lighting Reactive to Music and WiFi Controlled

Project in progress by Philipp Jurasic

  • 4,062 views
  • 2 comments
  • 21 respects
Add projectSign up / Login