Placeholder Image

字幕表 動画を再生する

  • Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to

  • setup the software for the door sensor using a Windows Computer.

  • [Intro]

  • So in the last video we left off with the door sensor being fully built so all it needs

  • is firmware and to be connected to the home automation server.

  • So let's start off with the firmware.

  • I recommend having my website open up so that way you have all the steps and commands ready,

  • and so you do not have to type in everything you can just copy and paste.

  • I know this is the software video but, there are some hardware things that we need besides

  • a computer.

  • We are going to need an arduino of some kind preferably a UNO or a MEGA equivalent with

  • its usb cable of course and male to male dupont jumper cables.

  • Links to these items will be in the description or on the website.

  • The first thing we are going to do is grab the arduino and put a jumper cable from RES

  • to GND.

  • Then grab the door sensor and connect all the pins to their corresponding spots so,

  • TX to TX, RX to RX, GND to GND, and 5V to 5V.

  • Before we continue, check to make sure the 2 pin jumper is above PGM.

  • Next we are going to go to the computer and go to the Arduino website https://www.arduino.cc/en/Main/Software

  • scroll down to download the Arduino IDE, and click Windows Installer, then press download.

  • Next, go to File Explorer and your downloads folder.

  • Double click on the arduino installer and click yes in the pop up.

  • Click agree, then next, and install.

  • It will ask you to install device software, click install for all the pop ups.

  • When it is done click close.

  • Find the arduino icon on your desktop and double click it.

  • Great we installed the arduino IDE, so now plug in your arduino.

  • To confirm your arduino is connected in the top bar go to Tools and if you hover over

  • Port: you should see COM and then a number if you can then select it.

  • (If you have a couple COM’s then unplug the arduino and see which com disapeared,

  • that is the arduino) Now we are going to add the ESP8266 boards so go to Arduino, then

  • preferences and in Additional Boards Manager URLs: type in http://arduino.esp8266.com/stable/package_esp8266com_index.json

  • then press OK.

  • Next go to tools.

  • Then hover over board and to the right click Boards Manager.

  • In the search box type in esp8266.

  • It should be the first one and it should say esp8266 by esp8266 Community.

  • Click on it and press install.

  • Once it is installed press the close button.

  • Now, go back to Tools, hover over board and go to the right and scroll down to and click

  • Generic ESP8266 Module.

  • Next we are going to add the MQTT Library, so go to sketch and in the drop down hover

  • over Include Library and in the right click on Manage Libraries.

  • In the search type in MQTT.

  • Scroll through the list to find the one that Says MQTT by Joel Gaehwiler, click on it and

  • press install.

  • Once installed click close.

  • Great!

  • All the prep work is complete.

  • Close out of arduino and now all we have to do is grab the code so we are going to head

  • over to my site, the link is in the description to the exact page and press the download MK-DoorSensor

  • code.

  • (Insert the rest of what goes here in terms of downloading) Then go to file explorer and

  • then downloads folder and double click on MK-DoorSensor.ino.

  • A pop up will come up asking if you want to put it in a folder, click OK.

  • It should bring up the code for the door sensor, and there are only a few things we have to

  • change.

  • The first thing is the wifi settings which are the ssid and password so change those

  • according to your network.

  • Please keep in mind that the esp8266 only works on 2.4ghz so type in your 2.4ghz wifi

  • ssid and password not your 5ghz.

  • Also when adding the information only change what is inside the quotation marks.

  • Next set of parameters are the Web Updater settings.

  • The devices I designed are great because I implemented a web user interface for each

  • individual device so that way if you ever have to flash new firmware you just go to

  • its web address.

  • The web address information is found at that top of the code in the giant comment block.

  • The first parameter is the hostname of the device, usually I only change the last digit

  • but since this is the first door sensor I will keep it as it is.

  • Next is the update path and personally I don’t change that.

  • After that is the web user interface username and password, these are the credentials you

  • use to access the webpage because each device is protected.

  • The next set of parameters are for mqtt.

  • The first one is the outTopic and this is the topic for which the device sends commands

  • to on the server.

  • The next one is the MQTT Server Ip address and this is simply the IP address of your

  • home automation or openhab server.

  • The last one is the Unique device ID and this simple differentiates each device on the MQTT

  • side, I usually just change the last digit for every single device.

  • That is it the code is ready to be flashed.

  • So go to tools and make sure the Board: is Generic ESP8266 Module and the port is COMX.

  • Once those are good press the upload button, it is the one with an arrow pointing to the

  • right.

  • When it is uploading you should see dots moving at the bottom and some percents.

  • After it is done uploading you should see it say 100% and Done uploading.

  • To confirm that it flashed correctly and is working you can fire up MQTT.fx, connect to

  • the server and in the subscribe section type in # and press subscribe.

  • Now if you separate and bring together the two contacts of the door sensor you should

  • see it either say OPEN or CLOSED depending on its current status.

  • If you do not have MQTT.fx then check out my Home Automation Server Setup Guide.

  • Now that we know it works let's close up the device and get it ready for use with the Automation

  • System.

  • First unplug the dupont wires in between the arduino and the device.

  • Then take the 2 pin jumper and move it over so it is above RUN.

  • After that take the lid to the device and put it on.

  • Finally plug the device into the wall.

  • Now the device is complete and just needs to be added to OpenHAB.

  • So ssh into your pi or whatever your server may be.

  • The first thing we are going to do is create the door sensor item.

  • So type in sudo nano /etc/openhab2/items/home.items and press enter, you may need to type in admin

  • password.

  • The type in the comment //Security items then underneath that we are going to create a software

  • switch to control the security system.

  • Type in Switch SecuritySystem "Security System" and press enter.

  • Now we are going to create the actual item type in Contact MKDoorSensor1 "Door Status

  • [%s]" <door> { mqtt="<[broker:MK-SmartHouse/security/MK-DoorSensor1:state:default]" } and press enter.

  • Now let me go over the two items we created.

  • The first one is a dummy switch and we will implement it later more in the rules but what

  • it will do is turn the openHab security system on and off.

  • The second item is the door sensor.

  • This is the line you would replicate if you had more door sensors.

  • Anyway the first part is Contact and since this device is a door sensor we use contact

  • type.

  • The next part is the item name and I just used its hostname without the dash.

  • After that is the label text and it is what shows up in the interface and how it is formatted

  • with the name and value.

  • Next to that is the icon name which is what picture shows up in the interface.

  • Then lastly, we have the mqtt path to the device.

  • Now press control x then y and enter.

  • Next up is the sitemap file so we can see the device status and our switch.

  • Type in sudo nano /etc/openhab2/sitemaps/home.sitemap and press enter.

  • It will bring up the sitemap.

  • If you are following along with my series then we have many different frames in our

  • sitemap.

  • I am going to replace what is int the security frame with our new items.

  • So delete the demo switch and type in Switch item=SecuritySystem and press enter and line

  • up your cursor underneath the S in switch and type in Text item=MKDoorSensor1 what we

  • did is import the items into the sitemap.

  • Now press control x then y and enter.

  • Before we go any furthur lets confirm that everything works so go to your web user interface

  • and then Basic UI.

  • You should see the Security system switch which right now does not do do anything but

  • you should also see the the door sensor or in my case the side door and if you open and

  • close the contacts you should see the status change.

  • Great it all works except the switch so let's fix that and make the security system do something.

  • In terminal type in sudo nano /etc/openhab2/rules/home.rules and press enter.

  • In the file type in //Side Door Sensor Is Open

  • rule "Side Door Sensor" when

  • Item MKDoorSensor1 received update OPEN then

  • if(SecuritySystem.state == ON) {

  • sendBroadcastNotification("SECURITY SYSTEM: SIDE DOOR OPEN")

  • } End

  • Let me explain what this does, it checks for whenever the door sensor sends open and if

  • it does, then it checks for if the security system is on and if it is then it sends every

  • user you setup in myopenhab.org a notification.

  • Now press control x then y and enter.

  • Go back to the basic UI and make sure the Security System switch is on.

  • Now make the door sensor closed then open.

  • If everything works right and you have a mobile device setup with openhab then you should

  • get a notification.

  • Also if you turn of the switch then you will not get notifications.

  • That is it!

  • The software is complete, now all we have to do is install the device in its final place

  • which will be completed in the next final installation video.

  • Alright thank you for watching and If you have any questions leave them in the comments

  • section below or head over to mksmarthouse.com/forum where you have a better chance of it getting

  • answered.

  • Good Bye!

Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to

字幕と単語

動画の操作 ここで「動画」の調整と「字幕」の表示を設定することができます

B1 中級

MQTT OpenHAB ESP8266 ドア/ウィンドウセンサ.ソフトウェア(WINDOWS使用) (MQTT OpenHAB ESP8266 Door / Window Sensor: Software (Using WINDOWS))

  • 14 0
    Ed に公開 2021 年 01 月 14 日
動画の中の単語