Hey there!
So I wanna make my room smarter and make everything work with Google Home Voice Assistant, both the app and the smart speakers (This method also works with Alexa!). This "invention" isn't that impressive, but it is very useful. I've searched the web and there is no good option to both turn on and off a computer via the Internet. There's the option to use WOL (wake on LAN), BUT if you want to configure it to work with Google Assistant you basically have 2 ways.
1) Use an HA (home assistant) server. BUT (as always there's a BUTπ ) you can't connect it to Google Assistant IF you don't want to pay a subscription.
2) Use the pushbullet app on your phone. It is free, BUT if you want it to work you need your phone to be always connected to the same wifi network as your computer. So that isn't convenient, because I use unlimited mobile data and don't want to always connect my phone to the slower house wifi.
For a long time, I thought how to do this "my way" π . Then I saw the "Junk Drawer Competition 2024", so I got to thinking. Is there a way to do this with physical electronics. This way it is free, simple, and VERY customizable.
As I already use a custom button I connected to my motherboard
I thought that I could probably add a relay that would also, work as a button and would be connected to the motherboard. It would connect the 2 wires together for a short time, simulating a button press.
I remembered that there's a kind of new service called "Arduino Cloud". I know how to work with it because I participated in the Arduino cloud games, so I thought I could make that work.
So, finally, the tutorial ;)First, connect the Arduino 1010 to your relay. I have a bit more complicated circuit, because I couldn't find any 5v relays, so I made it with 12v so I needed 2 psu's and a bit more tinkering. I'm going to buy a 3.3v and use that in the future.
So Just connect the relays like this :
Now that you have made the circuit, we need to configure the Arduino. Go to the https://app.arduino.cc/things website and log in. Press on the "+ THING" at the top right of the screen. Connect the Arduino to your computer, install Arduino agent and "Add Associeted device". Then add Google or Alexa "Smart Home integration".
Then go to the variables and add one like this one. In the "declaration" choose the Google or Alexa category and choose the switch.
Then go to the "Sketch" tab and paste this code :
In the first file (.ino) :
#include "thingProperties.h"
int PCpin = 5;
int lock = 1;
void setup() {
Serial.begin(9600);
delay(1500);
pinMode(PCpin, OUTPUT);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
}
void onPcPWRChange() {
if ( (lock % 2) == 0){
Serial.print(" Called - PC ");
digitalWrite(PCpin, HIGH);
delay(400);
digitalWrite(PCpin, LOW);
}
lock++;
Serial.print(lock);
}
In the second one (thingProperties.h) :
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char SSID[] = "YOR WIFI NAME"; // Network SSID (name)
const char PASS[] = "YOUR WIFI PASSWORD"; // Network password (use for WPA, or use as key for WEP)
void onPcPWRChange();
CloudSwitch PcPWR;
void initProperties(){
ArduinoCloud.addProperty(PcPWR, READWRITE, ON_CHANGE, onPcPWRChange);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
In the 2nd file, you need to change the line with the wifi name and password.
Now you can upload them to your Arduino 1010.
Now you can plug in the Arduino and it will connect to the server.
The only thing now is to connect your Google or Alexa to the Arduino server. Im going to write a tutorial to connect it to Google Assistant.
Go to the Google Home app and in the "devices" tab press add and link your Arduino account.
Then go to the "Automations" tab and make an automation like this one
This way it will send a switch to turn on and off. The Arduino will listen to only one of the commands so that this works as a button, not a switch. (I couldn't find a way for it to send a command as like a button) So I wrote this little code bit to filter out only 1 signal
Summary
Now you can turn on or off your computer with your voice! You can also add other things to the automation so for example you can make everything turn on when you ask :) This also turns off the pc because, when the power button is pressed when the pc is on it automatically shuts down.
Ps - Happy New Year!!!!! π₯³
Comments