ESP32 HomeKit Tutorial | HomeSpan

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll be diving into the world of home automation with the help of homespan homespan is a powerful library that lets you create Apple homekit compatible accessories using an esp32 hey Siri turn on my switch hey Siri turn off my lights let's start with the hardware here I have an esp32 Dev module I can leave a link in the description for the one I got off of Amazon but there's plenty of options so the most important thing is just to make sure you understand your pin out and you have that up I have an LED connected to pin 15 and ground this is a 3.2 volt LED and I'm connecting it to 3.3 volts it's in the range where I feel comfortable plugging it in without a resistor but based on your LED you may need a resistor for that so we're going to go ahead and start with just turning on and off an LED and then next we will use a relay as a switch to turn on and off so let's jump in the firmware so open a new Arduino project and if this is your first time running esp32s you will actually need this board manager URL pasted inside of the preferences I can leave this in the description the next thing we're going to do is we need to install the right libraries so the only one we really need is the home span Library by Greg so what makes homespan so cool is it's simple to use and allows you to build complex custom home accessories each homespan accessory can have multiple services and have multiple characteristics so you can have a light bulb you can change the brightness the color and in our case we will have a light as well as a switch running on one device also check out the docs at some point the docks are great these are some of the best stocks I've seen so in this example I'm not going to go over every line of code but I'll go over the general code so first thing we're going to do is we are going to import homespan and we're going to create a new file and we will call that led.h and we're also going to import this file we will then add serial.begin next we will add a pairing code and when we connect to our iPhone we'll need to set this up so we'll do home span dot set pairing code and in this case it needs to be eight numbers we'll do one one one two two three three three we'll go with that for right now and then we will do home span dot begin we're going to put our category [Music] as lighting and if you actually look at the Docks there are tons of different categories you can add here but in our case oops in our case we will do lighting and we can call this my home LED all right here we're going to paste we're going to add a new accessory and we're going to jump in to our LED file here so I'm going to actually just call this LED so now we're going to reference in here and this is basically saying we're going to put this led on pin 15. and that's what we did when we set it up I'll paste this and then we can kind of go over it so here we have a class and we called it led so we have our variable LED pin and here we are passing in LED pin from over here so that's pin 15. so if you wanted on pin 18 whatever it is you can change it here next we have our Constructor here and we're creating a new characteristic and we are setting this to power so here this is basically going to allow us to turn on and off the power by affecting the LED pin so inside of this Boolean update we have the digital right which is from the Arduino Library which will change the state of the LED pin and update it we can now run home span Dot poll and that should be good I just noticed a mistake there I didn't have parentheses there now let's click upload let's now connect to the light we'll hit add accessory we'll hit more options my home LED add anyways the password was one one two two three three three we'll hit continue it'll connect we'll put this as our let's do kitchen I'll just call LED and there we go so now if I click this we have our LED turning on and off if I say hey Siri turn on my LED hey Siri turn off my LED perfect let's now get this switch connected as well so with the relay you're going to typically have two sides on this side this will connect to our esp32 and this will connect to any sort of like a decent amount of voltage so in this case I have 10 amps at 250 volts ac or 10 amp set 30 volts DC so we're going to plug into this side and this is our positive this is a 5.5 volt relay you can get a 3.3 um I believe you can get like a 12 a 24 there's quite a bit so then we'll take this middle one we'll plug this into ground and then this one will go into pin 17. on this other side we have three screw locks here and depending on how you hook this up you can actually have it inverted to whether this is on or off so if this is on this could be off or you can have this be on and this is on so depending on which model you have you can go look that up in in the schematics but it's pretty simple to get the site connected all right back to the firmware to get the switch connected is now almost the same thing we're going to add a new file called Dev relay dot h and inside of this it will be very very similar as the last one okay so now we'll go back to our main file and we're just going to add a new accessory we can add that here so here we're adding a new accessory and we are and we are sending the data to Dev relay now another thing we're going to change right here is the category instead of lighting we're going to change it to Bridges let's add the functionality to scan a QR code so here we'll do homespan set QR ID and here we will have our eight numbers we do need to have them spaced like this so one two three and then we'll have a dash 22-333 in order to use the QR code we actually need the home kit accessory simulator it's an add-on for xcode so you will need xcode for this but once you get xcoded downloaded you can download this accessory simulator and once you open that it should look like and follow this documentation on how to install it it's fairly easy once you get that it should look like this and here we can put in whatever whatever codes we want um but right here on category there's different different things we can add so I can do bridge here select bridge and I will put in that code 1112233 and I'll hit enter so now when you scan this this will do the connection to your iPhone alright this is looking really good oh I noticed I didn't import that and we don't need that okay let's go ahead and upload this to our device and test it out let's now connect to our esp32 we'll hit add accessory we can't use this camera for the QR code because it's not a verified device but we're going to click more options we see our homespan Bridge here we'll click that I'm going to hit add anyways and then here we can hit use camera and then with our camera we can scan our QR code so it's connecting to Bridge I will do a bedroom I will call this light and then for the second one I'll also do bedroom I'll call this switch and now we can turn on and off our light and oops turn on and off our switch I can say Hey Siri turn on my switch hey Siri turn on my light all right there you have it that's homespan with an esp32 if you like this video make sure you like And subscribe and be sure to comment four videos you'd like to see
Info
Channel: Taylor Galbraith
Views: 53,727
Rating: undefined out of 5
Keywords: esp32, esp32 tutorial, homeSpan, homeKit, esp32 homekit, esp32 home assistant, esp32 home automation, esp32 home automation projects, esp32 homespan, esp32 home projects, esp32 home security, tutorial, hardware, smart home, home automation, arduino project, smart home device, smart home esp32, esp32 projects for beginners, esp32 projects 2023, esp32 projects home automation, esp32 projects home assistant, esp32 projects tutorial, google home, home automation ideas
Id: K1xrCyN9T98
Channel Id: undefined
Length: 8min 54sec (534 seconds)
Published: Thu Jun 22 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.