Use Alexa to Control your TV!

Ose 9
46 followers
42 Video Views·Oct 27, 2022
If you lose your remote all the time like I do, I'd recommend giving this video a watch because
basically in this video I cover that anything this remote can do, this Alexa docket can do.
All right, take a look. Alexa, turn on the TV. Okay, there you go. It's about to turn on. It
kind of takes a while to come on, but okay. Alexa, turn on Greg's Netflix. And give it a second.
There it is. So how does this work? Well, basically the same sensor that's in this
remote we can use to send our own signals with a Wi-Fi module. All right, so that sounds a
little confusing, but let's see what we need to get this started. Here's the Wi-Fi module.
This is an Arduino Uno, or you can replace it with an ATtiny85 microcontroller. Here's an IR
transmitter, 100 ohm resistor to use with the transmitter, and an IR receiver, and of course
the Amazon Alexa. Plug the Wi-Fi chip into your PC. Now open up your internet and go to my GitHub,
which I linked in the description. You're going to go to the ESPWemo repository. I list the steps
that you need to do in order to get this to work. First, we're going to download all three of these
libraries. So here's the first library. We're going to download the zip. Here's the second one,
UDP. We're going to download that zip. And finally, we're going to go to the last one,
go to downloads, and download repository. Next, you're going to unzip all these files.
I put them into my own folder, so I'm going to copy these,
Ctrl-C. Then I'm going to go over to my documents, Arduino, find the libraries folder,
and I'm going to paste these in here. Looks like I already have it in there. I'm just going to
replace the files. Next, I'm going to go back to the internet, back to my GitHub page, and I'm
going to download my own repository, which has both of the sketches in it. For the Wi-Fi module,
we're going to be using ESP8266-Alexa, and for the Arduino, we're going to use the other one.
So now we're going to open up the IDE, and here's the sketch here. So I broke it down by parts.
Here's the Wi-Fi credentials, your ID, your password. You don't need to touch that section.
Here's where you map out which pins are going to do what. Here's just a quick overview. You can
also look it up online, the outputs, but you're going to use the GPIO pins. Here's the initialization
to touch that. Here's where you actually name each device. So I have TV, Greg's Netflix,
sleep, and the office. You don't have to touch the callback message. Here's what happens when
each one is called. So here for TV, it reads the state. If it's on, it writes high, and if it's
off, it writes high also because TV on and off send the same signal. Next for Greg's Netflix,
we do it normally where on is high, off is low. We do that for each one. Next, here's the actual
function handle. Because it's just a pulse, I delay for 500 seconds, and then I write it to low.
Now let's go to tools, board. We're going to set it to node MCU. You might have to go to your board
manager to download that. You want to choose your port once you have it connected, and upload that
to your ESP module. Now we can open the Alexa app on your device. Go to your smart home,
and you're going to click add devices. It should come up with each device you name where it does
here. It finds all four of them. Now what I did was I mapped out each LED to each pin
or each device. So you can see me testing it here. Alexa, turn on TV. Okay. Alexa,
turn on Greg's Netflix. Okay. Alexa, turn on the office. Okay. Alexa, turn on sleep.
Okay. Okay, now we're going to set up the Arduino connected to your PC.
We're going to go back to my GitHub page, or I guess you don't have to. We're going to be using
this sketch right here. So open up your IDE. Here's the sketch. First, I define which pins
are going to do what, because I have four devices, four pins. Initialize it. Here's where you write
the actual code. Basically, the first one is the power code. On the next one, so for example,
for the office, I press enter, up, up, up, right, enter, enter, and that will turn on the office.
Now I do a similar operation for the sleep timer. I record all my clicker hits and put
the codes here. In my previous video, I go over how to actually record those clicker hits.
Now go to tools, change the board to Arduino Uno, and choose your port for that device,
and upload this sketch to your Arduino Uno. Now I'm going to construct a circuit here.
There's the Wi-Fi module with the IR transmitter and the resistor.
We're going to supply power to the chip. Here's the schematic for that. It's an easier view.
Feel free to pause the video. Now I'm going to map out each of the outputs of the Wi-Fi module
to the inputs of the Arduino. I'm going to supply it with power. This is what it looks like at the
end in prototype. Now we're going to test it. Alexa, turn on TV. Okay. Alexa, turn on Netflix.
I couldn't find... Alexa, turn on Greg's Netflix. Okay. Alexa, turn on the office.
Okay. Notice how the clicker hits in my sketch before navigate perfectly to my Netflix list,
one over for the office. Alexa, turn on sleep. Okay. I did a similar trial and error to figure
out how to put on sleep for one hour. Alexa, turn off TV. Okay. Now I know this kind of looks like
a big mess. There's so many wires hanging everywhere, so what I did instead was I put it
onto a little board like this. Basically, I used that AtTiny device instead of the Arduino.
So this is how I did it. I made this little bootloader for AtMega, AtTiny's different types
of chips. This plugs right onto the Arduino like a shield. Next, you just take your AtTiny chip
and you plug it into the slot that says AtTiny85. Now I can program that chip using the Arduino.
I'll cover this in a later video, but for now you can just use the Arduino.
Let me know what you thought of my video in the comments below. If you were confused about the
IR section of this video, be sure to check out my tutorial on that on my channel. Other than that,
feel free to subscribe and check out my other videos and hopefully I'll be uploading more
projects soon.
