Voice Control your devices with Alexa under $5 !!

Research

  • AWS IOT ( which I accomplished)
  • Google Assistant( Accomplished)
  • Alexa Custom Skills(Partially Accomplished)
  • Alexa Custom Smart Home Skills(Partially Accomplished)
  • Existing Alexa Smart Home Skills(Accomplished, Easy and Cost Saving)
Architecture Diagram which I implemented

Actual Implementation

adding board to board manager.
  • Go to Tools > Boards > Boards Manager…
  • Search ESP8266 and Install it.
Esp8266 library installation
  • Close the Boards Manager window and select the Generic ESP8266 Module from board selection list as shown below.
select the board
  • COM: connect the current you want to control (mains voltage).
  • NC (Normally Closed): the normally closed configuration is used when you want the relay to be closed by default. The NC are COM pins are connected, meaning the current is flowing unless you send a signal from the ESP8266 to the relay module to open the circuit and stop the current flow.
  • NO (Normally Open): the normally open configuration works the other way around: there is no connection between the NO and COM pins, so the circuit is broken unless you send a signal from the ESP8266 to close the circuit.
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <Espalexa.h>
// -------- WIFI INFORMATION -----
const char *WIFI_SSID = "---username";
const char *WIFI_PASSWORD = "----password---";
void bedroomLightChange(EspalexaDevice* dev);
Espalexa espalexa;
EspalexaDevice* bedroomLight;
// To Control Lights
int bedroomLightPin=5; // D1
void connectToWiFi(){

// This function will try to connect to WIFI
Serial.println(" Trying to connect to WiFi..");
Serial.println(WIFI_SSID);

WiFi.begin(WIFI_SSID,WIFI_PASSWORD);

// try only for 15 times and then take a pause.
int retries = 0;
while(WiFi.status() != WL_CONNECTED && retries < 15) {
delay(500);
Serial.print(".");
retries++;
}

Serial.println("WiFi Connected");
Serial.println("IP Address: ");
Serial.println(WiFi.localIP());

}
void bedroomLightChanged(EspalexaDevice* d){
if (d == nullptr) Serial.println("Sorry No device Found");
if(d->getValue()){
//Tune on the device
digitalWrite(bedroomLightPin,HIGH);
d->setValue(127);
Serial.println("Turned on the light");
}else{
// Turn off the device
digitalWrite(bedroomLightPin, LOW);
d->setValue(0);
Serial.println("Turned off the light");
}


}
void lightsInitalize(){// Setup the inbuilt LED Pin
pinMode(LED_BUILTIN, OUTPUT);
// Low BedroomLight_01
pinMode(bedroomLightPin,OUTPUT);
digitalWrite(bedroomLightPin,LOW);
}void setup() {
Serial.begin(9600);
lightsInitalize();
connectToWiFi();
bedroomLight = new EspalexaDevice("Bedroom Light", bedroomLightChanged,EspalexaDeviceType::dimmable);
espalexa.addDevice(bedroomLight);
espalexa.begin();
}void loop() {
// put your main code here, to run repeatedly:
espalexa.loop();
delay(1);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <Espalexa.h>
// -------- WIFI INFORMATION -----
const char *WIFI_SSID = "---username";
const char *WIFI_PASSWORD = "----password---";
void bedroomLightChange(EspalexaDevice* dev);
Espalexa espalexa;
EspalexaDevice* bedroomLight;
// TO Control Lights
int bedroomLightPin=5; // D1
void connectToWiFi(){

// This function will try to connect to WIFI
Serial.println(" Trying to connect to WiFi..");
Serial.println(WIFI_SSID);

WiFi.begin(WIFI_SSID,WIFI_PASSWORD);

// try only for 15 times and then take a pause.
int retries = 0;
while(WiFi.status() != WL_CONNECTED && retries < 15) {
delay(500);
Serial.print(".");
retries++;
}

Serial.println("WiFi Connected");
Serial.println("IP Address: ");
Serial.println(WiFi.localIP());

}
void lightsInitalize(){// Setup the inbuilt LED Pin
pinMode(LED_BUILTIN, OUTPUT);
// Low BedroomLight_01
pinMode(bedroomLightPin,OUTPUT);
digitalWrite(bedroomLightPin,LOW);
}
void setup() {
Serial.begin(9600);
lightsInitalize();
connectToWiFi();
bedroomLight = new EspalexaDevice("Bedroom Light", bedroomLightChanged,EspalexaDeviceType::dimmable);
espalexa.addDevice(bedroomLight);
espalexa.begin();
}
uploading sketch
Top right corner of Arduino IDE
Serial Monitor showing the IP acquired

Conclusion

--

--

--

DevOps Consultant, ALM Consultant, CloudOps Consultant

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Wall Jumping in Unity

What I learned from my most recent coding project

Creating More “Organic” AI

Product Discovery at Scale

FINCA Uganda Jobs 2021 — Database Administrator

FINCA Uganda Jobs 2021

Spock in Cortilia: integration test overview

How to add Project to GitHub from command line

Getting Work Done: Challenges of Designing with Agile

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhijeet Kamble

Abhijeet Kamble

DevOps Consultant, ALM Consultant, CloudOps Consultant

More from Medium

Cause and Effect

Purgatorial awareness

💵Airdrop is live!

Mental health- SolGirls