Pham Hoang Son
Published © LGPL

Voice Controlled RGB Lamp

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

BeginnerFull instructions provided8 hours6,145
Voice Controlled RGB Lamp

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
To Delete RGB Led strip
×1
ULN2003A High-Voltage, High-Current Seven Darlington Driver Transistor
×1
Bluetooth speaker Fenda
×1
Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1

Software apps and online services

AWS IoT
Amazon Web Services AWS IoT
AWS Lambda
Amazon Web Services AWS Lambda
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit
Alexa Voice Service
Amazon Alexa Alexa Voice Service

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Basic connection

Connect Arduino + ESP8266 + ULN2003 + RGB LED

Code

SetColor

Arduino
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 IoT

Arduino
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);

}

Credits

Pham Hoang Son

Pham Hoang Son

1 project • 3 followers
Junior engineer - mechatronics

Comments