"Alexa, Turn on the Computer!"

About: Ahoy! I am a 20 year old student! I am studying Electronics and Communication Engineering I Love Electronics, Coding and Computers. (Breaking things has been my motivation for making):P I make DIY Electr...

After spending time with an Echo Dot for a few days I wanted to be able to turn on my computer using Alexa(don't ask me why xP).

Watch the Video, you'll get a good idea going into this project.

There is a way to do this without writing a dedicated Alexa app, Alexa supports smart lights out of the box. So if we can emulate a smart bulb interface we can use that to forward commands to other things. I'll be using Node-RED to emulate the smart bulb interface.

One of the obvious ways of doing it is by using Wake-on-LAN feature which can be turned on in the BIOS of your computer. But, I wanted to go the "do it like you see it" way . Hence this happened. I'll be explaining both the ways of doing it in this Instructable.

There are two handy diagrams explaining both the methods!

Things and Parts I used for this project

  • Node-RED
  • ESP 8266, Wemos D1 Mini Module
  • Active High, 3.3v Relay
  • Spare cables
  • Tools(Sodlering Iron, pliers and the standard ensemble of all electronics hobbyists)

Step 1: Watch the Video and Set-up Node-RED

For either of the methods, you'll need Node-RED running on a server(a Raspberry Pi will be perfect). https://nodered.org/docs/hardware/raspberrypi

You can check the above page for more info on Node-RED. It's a really handy tool with which you can have things up and running in a jiffy.

Install the Alexa and WOL(Wake on LAN) nodes in the palette manager. Also make sure the MQTT module is present for the relay method.

Step 2: Add the Alexa Module/node to the Flow and Configure It

  • Add the Alexa node to the flow
  • Add the MQTT output node, configure the MQTT server and the topic to publish the MQTT messages.(Relay Method)
  • Add the Wake on LAN node. (Wake on LAN method)
  • Configure the WOL node with the IP address and MAC Address of your computer.(I recommend having a static IP for your computer).
  • Rename the Alexa node to 'Computer', connect the modules as shown in the picture and deploy the flow.
  • Ask Alexa to detect devices and Alexa will find the 'computer' node on Node-RED.

Step 3: (WOL Method) Turn on Wake-on-LAN in Your Computer's BIOS Settings

  • That's it, just turn on the Wake on LAN feature and you're pretty much done as far as the WOL method goes.

Step 4: Program the Wemos D1 Mini or Any ESP 8266 Module

  • Program the ESP module so that it receives the MQTT messages published by Node-RED.
  • Program one of the I/O pins to turn on for 200ms every time it receives an 'on' message. Alexa sends 'on' and 'off' as string messages.
  • Use that I/O signal to turn on a relay(active-high 3.3v would be best, you'll have to make necessary changes otherwise).
  • I made my own 3.3v active high module, because I couldn't buy one.
  • You'll need to supply external power for the WiFi and Relay modules

Here's the code I used to program the Wemos D1 Mini.


#include 
#include
const char *ssid =  "xxx"; 
const char *pass =  "xxxxxxxxxxx";
IPAddress server(xx, xxx, xxx, xx); 
WiFiClient wclient;
PubSubClient client(wclient, server);
 
void callback(const MQTT::Publish& pub) {
  if(pub.payload_string()== "on"){
    digitalWrite(0,HIGH);
  delay(200);
  digitalWrite(0,LOW);
  }
 
}
void setup() {
 pinMode(0,OUTPUT);
 pinMode(2,OUTPUT);
 digitalWrite(0,LOW);
Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();
  client.set_callback(callback);
  wif();
  client.connect("arduino000Client");
  
  }
void loop() {
 if(WiFi.status() != WL_CONNECTED)
 wif();
 client.subscribe("helluvaTry");
}
void wif(){
  if (WiFi.status() != WL_CONNECTED) {
    Serial.print("Connecting to ");
    Serial.print(ssid);
    Serial.println("...");
    WiFi.begin(ssid, pass);
    if (WiFi.waitForConnectResult() != WL_CONNECTED)
      wif();
    Serial.println("WiFi connected");
    digitalWrite(2,HIGH);
     client.connect("arduino000Client");
  }
  }

Step 5: Make a Splitter Cable for Your Power Button Connector

  • Yeah, this is basically wires connected parallely to your power button pins on the motherboard.
  • The loose ends in the picture goes into the relay, the female connector goes into the motherboard power pins and the male end connects to the power button connector.

Step 6: That's It

  • Test out the configuration and the setup a few times and you're pretty much done.
  • Have fun with your voice activated computer(lol).

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Toys Contest

      Toys Contest
    • First Time Author

      First Time Author

    Discussions