Turn on and Off Your Computer With Google Home & Blynk
by Mathias Juel in Circuits > Arduino
2303 Views, 3 Favorites, 0 Comments
Turn on and Off Your Computer With Google Home & Blynk
Hello Guys and welcome to this tutorial!
This time i will show you how to turn on your computer with your Google Home
BEWARE !!READ THIS!!:
1. Be sure to isolate the connectons! I chose to 3d print an case to fix this problem
2. If you connect power to your computers button you will burn the motherboard off, therefore we use a relay to fix that problem.
Why i did this
I bought the google home and soon began to control everything with it. (For example my lights)
I did this because I am lazy and didn't want to walk to the switch if I was in bed.
Later I found my self in the bed, and this time I forgot to turn off my computer.
There I thought, I should be able to turn it on and off with my google.
I started googling around, but unfortunately, I didn't find anyone that has done that.
So I started myself. I started from the bottom.
I didn't know anything about this topic, but I learned fast and after 2 weekends I had the finished product!
Now I can be as lazy as I want :D, but first i have to share it with the community.
What you will need
1. NodeMCU - https://goo.gl/HDd5S7
1. Relay Module - https://goo.gl/HDd5S7
1. Breadboard or PCB - https://goo.gl/HDd5S7
1. Computer with Arduino software on
1. Smartphone with the Blynk app
Setting Up Blynk
This project is using the Blynk library & the IFTTT project to connect to the google
If you want to know what blynk is, then click here -> https://docs.blynk.cc/
First, you have to install the app on your smartphone. (Picture 1)
When that app is installed, open it and make a account. If the app asks which server you will connect to, select Blynks standard server.
When your account is created, click new project.
Make the settings like this:
Project name: You can choose one!
Choose device: NodeMCU
Connection type: WiFi
Theme: You can choose one!
Then create the project.
Now you have a big workspace and three buttons in the top.
Click on the workspace to open the widget box.
Here you should choose button. It should automatically move you back to the Workspace, and now you can see a button widget.
Click on the widget to open the button settings.
Make the settings like this: (Picture 2)
Name: D1
Output: Pin(D1) 1_0
Mode: Push
ON/OFF Labels: Standart settings
When you are done, click ok in the top right corner.
Again, click on the workspace to open the widget box, and choose the button widget.
Click on the widget the open the button settings.
Make the settings like this: (Picture 3)
Name: Start / Stop
Output: Pin(V1) 0_1
Mode: Switch
ON/OFF Labels: Standart settings
When you are done, click ok in the right top corner.
Again, click on the workspace to open the widget box, and choose the button widget.
Click on the widget the open the button settings.
Make the settings like this: (Picture 4)
Name: Restart
Output: Pin(V2) 0_1
Mode: Switch
ON/OFF Labels: Standart settings
When you are done, click ok in the right top corner.
Now we are done configuration, Click on the Settings button, (it is in the top right corner of the workspace)
Scroll down to Auth Token, Here you should click E-Mail, and the token will be delivered in your inbox.
Then click OK in the top right corner.
Then to the right of the settings button, you should click play, and then it will say "(Project Name) is offline."
Now we are done with this app!
Installing the Arduino Libraries
Before we can begin programming the NodeMCU you need the software and libraries
First install the Arduino software - https://www.arduino.cc/en/Main/Software
Then install the NodeMCU Library - https://www.youtube.com/watch?v=RVSCjCpZ_nQ
And then install the Blynk Library - https://www.youtube.com/watch?v=Ea0y1ExNNnI
Then when all of the Libraries are installed, Open the Arduino software and then in the top corner, go to Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
Now you can connect your NodeMCU to the computer (with an usb cable)
Then open the windows program Device Manager and under ports find the "Silicon Labs"(Picture 1)
Then open the Arduino software again and go to Tools -> Port -> Select you com(number that corresponds to the NodeMCU) (Picture 2)
Programming the NodeMCU
Now we are ready to programming the NodeMCU.
Create an empty Arduino sketch and copy the code from the link
https://pastebin.com/PykABC3Q
Note there are three varibles that you have to fill
Line 7: Auth Code: Replace TOKEN with the token that was sent to your E-Mail.
Line 8: SSID: Replace SSID with your WiFi ssid.
Line 9: Password: Replace PASS with your WiFi password.
When you have changed the variables, you can click upload in the left corner.
Now you should just wait untill the program is uploaded.
Now we are done with the computer and are now ready to begin testing
Prototyping
Now we are ready to connect the Relay to the Arduino
MAKE SURE TO UNPLUG THE ARDUINO WHILE CONNECTING PINS!
On the NodeMCU we need three pins
A 5 volt pin - Vin
A ground pin - GND
And a Digital pin - D1
Connect pin Vin to the positive terminal on the relay (It will probaly be labeled VCC or +)
Connect pin GND to the grond terminal on the relay (It will probaly be labeled GND or -)
Connect pin D1 to the controlling terminal on the relay (It will probaly be labeled IN)
Now you can connect pins to the output end.
Connect you computer button to the NC (Normally Closed) and COM (Common)
IFTTT
Now we are close, but we need one thing more
And that is connecting it to the google home
Go to IFTTT -> https://ifttt.com/my_applets
Click on New applet
Then click on +this (Picture 1)
Search for Google assistant (Picture 2)
Choose Say Simple Phrase (Picture 3)
Set the phrases up as the picture (Picture 4)
Then click on +that (Picture 5)
Search for webhooks (Picture 6)
Then open the CMD application on your computer (Picture 7, Dont mind it says "kommandoprompt" it is danish for CMD)
Then enter ping blynk-cloud.com
Then look after an ip (This can be diffrent from the picture, as it is based on your location) (Picture 8)
Then open your browser again and now we can configure the webhook applet
URL: http://IP:8080/TOKEN/update/V1?value=1
Method: GET
Content type: Application/json
Body: Nothing
(Picture 9)
Now you should wait up to 24 hours, and then you can try to tell google your command. Basically you are done.
But if you want to be able to force shut it off (Emulating holding the button down for 6 seconds)
You should make one more applet, The only thing you change are the phrases and the webhook url to
Thank You
Now we are done, and thank you for reading this
If it dont work or you have any questions, feel free to write an Mail or send a private message on Instructables.
I started as a noob and i will still classify myself as a noob, but i should be able to help you with your problems.
For me it works and i should for you too.
Finishing up
I chose to install my project permantly to a PCB and, soon i will 3d print a case. You can see it on the picture that is attatched.
Also i attatched some quick connectors to my PCB so quickly can remove it from the computer if nessecary.
BEWARE !!READ THIS!!:
1. Be sure to isolate the connectons! I chose to 3d print an case to fix this problem
2. If you connect power to your computers button you will burn the motherboard off, therefore we use a relay to fix that problem.