LIQUIDATION SALE! FREE Shipping on orders over $49 USA $99 INTERNATIONAL USE CODE: "LIQUIDATION" for 50% OF

Fire Sensor MQTT OpenHAB ESP8266

Fire Sensor MQTT OpenHAB ESP8266

Demo: 

Hey guys Matt here from MKSmartHouse.com and in this video I am going to give you a demo of the Fire Sensor we will be creating.
So what is this fire sensor exactly well, it is a sensor that connects to our openhab server through MQTT and tells it the state of the fire detector. Personally It provides a sense of relief because now I will know if there is a fire at home and can possibly get it put out faster instead of coming home to a house burnt to the ground. If I pull out a mobile device and open up the openHAB app you can see that I now have a new item in a new frame called fire detectors.The item is the fire sensor and it is labeled as “House”. This item shows me the current status of the fire detectors in the main house. The reason I have it called house is because in the future when there are fire detectors in the garage I plan on putting another device there to show the status of those fire detectors. This device is great because whenever the fire detectors go off I get a notification on my phone. I locked my mobile device and as you can see if I press the test button on the fire detector I get a notification. If I go back to the openhab app you can now see that if I press the test button the device status changes to Fire Detected. Next, I am going to show you around the device. Starting from the top we have the wire that goes to the fire detector and this is how we get the signal from it. Next we have the control box and then if we keep going down is its power wire connected to an outlet. But, let's take a closer look at the control box. It is all housed in a nice plastic enclosure with two holes for screws. Anyway if we open it up we can see the Custom PCB and its components. First up at the top left is the communication port and this is how we are going to program the device. Below that is the 5 volt to 3.3 volt regulator because the ESP8266 uses 3.3V . To the right of that is the mode switch and we use this to either put the device into program mode or in run mode. To the left of that is the 5 volt power input terminal. In the top right there is a 1K resistor. Below that and to the left is a 330 ohm resistor and 10k resistor. To the right of the resistors is the input terminal from the fire detector. Underneath that is PC817 optocoupler. If we flip the board over we will see the esp right in the middle. The esp8266 is the whole brains of the device and it is what connects to the openhab server through mqtt over wifi. But let's talk a little bit more about the fire detector and how we connect to it. If we take a look at my fire detectors you can see that there are three wires coming out of it, that is because this is a hardwired fire detector with a battery backup. These types of fire detectors feature something called interconnect and what it does is that if 1 fire detector goes off then all the fire detectors connected also go off. So what my device does is it pretends to be a fire detector and receives the signal. In past videos some of you guys mentioned that you wanted to know a little bit more in detail how the hardware works so I will try to explain how the fire sensor works. Let's pretend there is a fire, the fire sensor and fire detector go off. The first thing that happens is the fire detector sends a 9 volt pulse over the red and white wires. The red and white wires are connected to the fire sensor through the blue terminal block. The white wire side of the terminal block is then connected to the Cathode of the optocoupler. The red wire side of the terminal block is connected to the 1K resistor and the 330 ohm resistor. The reason I have these two resistors is to bring the voltage down. Then the other end of the 330 ohm resistor is connected to the Anode of the optocoupler. For those of you who don’t know an optocoupler in the most basic terms is sort of a switch that if you apply voltage to one side it connects the other. In this case the voltage side is the one with the fire detector. So lets talk about the other side. The emitter side of the optocoupler is connected to ground and the collector side is connected to GPIO 13 on the esp8266. But GPIO 13 also has a resistor connected to that goes to 3.3v, this is known as a Pull Up Resistor. The rest of the esp8266 and the circuit is just standard stuff but If you guys want me to do a video on that let me know. That’s it that is the entire device! In the next video I will show you all the hardware we will need and how to put it together. If you want to be ready for the hardware video you can buy a kit or the PCB to make the device at the link in the video description. 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. Good Bye!

Fire Sensor MQTT OpenHAB ESP8266

Hardware: 

Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to build the Fire Sensor.
 
So, in this video we are going to go over all the parts required for the Fire Sensor and then we are going to make it. To start off with the parts we are going to need 2 2 pin PCB Terminals, 1 4 pin female header, 1 3 pin male header, 1 2 pin jumper, 1 5v to 3.3v regulator, 1 10k resistor, 1 330 ohm resistor, 1 1K resistor, 1 PC817 Optocoupler, 1 esp8266, 1 custom Fire Sensor PCB more on that later, 1 plastic enclosure, 2 conductor 22 Gauge Cable, Male usb connector and a 5v USB Wall adapter. The wall adapter can be any usb 5v adapter like a phone charger. For tools we are going to need a soldering iron with ST7 tip, flux, steel wire, solder, wall tac, PCB holder, helping hands, wire strippers, small wire cutters, small flat screwdriver and a hot glue gun. That is everything that we will need. The links to all the parts and tools will be over on my website, link is in the description. On my website you will also find the kit for this device, so instead of buying all the parts separately you can buy 1 kit and get all the parts fast and at the same time. There is even an option to get the device assembled so all you have to do is install its software and set it up. In the beginning I did say custom circuit board because to make this easier I designed a custom circuit board so that way not only will it be very stable and have strong connections with no guess work in assembling it but, also so I can make many of them really easily for my house. I have provided the gerber file on my website as well as where to get it made. You can also buy the PCB on my website, which is the easiest and fastest way to get them.
 
Since all the connections are already made on the circuit board all we have to do is solder the components on to the board. First let's take the circuit board and put it into the circuit board holder. If you look closely at the circuit board you will see that there are labels next to the component slots, when I say where to put the component that is what I will be referring to. I like to solder from the less sensitive components to to most sensitive so, let's start off with the 2 pin terminals,
 
1. take the terminals and put them in J3 and J4. Then solder them in.
 
If you want to know how to solder or how I solder then check out my guide for the door sensor because in that video I went over it in detail.
 
2. Next take the 4 pin female header and put it into J2 and solder it in.
 
If the leads get long and stick out cut them with wire cutters.
 
3. Then take a strip of the male header and using the wire cutters make a header that is 3 pins long. Take that 3 pin male header and solder it into J1. 4. For slot U2 take the 5v to 3.3v regulator and match up its leads to the board and solder it in.
5. Next take the 1k resistor and solder it into slot R3.
 
To put the resistor in the slot you have to bend its leads so that way they are parallel to each other.
 
6. After that take the 330 ohm resistor and solder it into slot R2.
7. Finally take the last resistor which is the 10k resistor and solder it into slot R1.
8. The last component on the top of the PCB is the PC817 Optocoupler and it gets soldered into slot U3 but, when you put it in the slot make sure you align the little circle on the optocoupler with the square silver pad on the PCB.
9. Before we flip over the PCB we are going to put the 2 pin jumper on the 3 pin male header and above the PGM side.
10. Great now we have one component left to solder and that is the esp8266, it is on the back of the PCB so flip it over.
 
I recommend putting flux on every single pad of the esp8266 and of the circuit board and then solder it in. Next we are going to work on the power cable to the device. I am talking about the 5 volt power cable.
 
11. First thing we have to do is take the 2 conductor 22 Gauge cable and cut it to length, I cut mine to the length of 10 feet.
12. Then take one end of the wire and strip it to expose the 2 conductors.
13. Strip a little of the each conductor and then take wire boot and plastic boot of the usb connector and slide it over the 2 conductors.
14. Next take the helping hands and put the 22 gauge wire in one of them and the usb connector in the other.
15. Then solder the black wire to the far left pin and the red wire to the far right pin.
16. Now put some hot glue on the connector and slide over the plastic boot and the wire boot.
 
If you want you can connect the USB to the 5v wall adapter but do not plug it into the wall.
 
17. Almost done, strip the other end of the 22 gauge cable and then loosen the two screws on the 2 pin terminal above the 5v.
18. Then take the red wire and put it into the hole parallel to where it says + and the black into the hole above the - symbol and tighten the screws. 19. You can now put the pcb into the enclosure put do not put on the lid.
 
That is it for the hardware of the actual device now all it needs is some software which will be in the next 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!

Fire Sensor MQTT OpenHAB ESP8266

Software: 

ssh into your pi or whatever your server may be.
The first thing we are going to do is create the Fire Sensor item.
 
So type in sudo nano /etc/openhab2/items/home.items and press enter, you may need to type in admin password.
Then type in the comment //Fire Sensors then underneath that we are going to create the fire sensor item.
So type in String MKFireSensor1 "House [%s]" <fire> { mqtt="<[broker:MK-SmartHouse/utilities/MK-FireSensor1:state:default]" }
And press enter.
Now press control x then y and enter.
 
Next up is the sitemap file so we can see the status of the device.
 
Type in sudo nano /etc/openhab2/sitemaps/home.sitemap and press enter.
 
So go to the bottom underneath the “OutSide” closing bracket and type in
    Frame label="Fire Detectors"
      {
          Text item=MKFireSensor1
      }
 
and press enter,
 
Let's make it send a notification to the mobile devices when it detects a fire.
 
In ssh type in sudo nano /etc/openhab2/rules/home.rules and press enter.
At the bottom of the file type in
//Fire Detected In The House
rule "Fire Sensor"
when
  Item MKFireSensor1 received update
then
      if(MKFireSensor1.state == "FIRE DETECTED!")
      {
          sendBroadcastNotification("FIRE DETECTORS: HOUSE FIRE DETECTOR ACTIVATED")
      }
end
 
Now press control x then y and enter.

Fire Sensor MQTT OpenHAB ESP8266

Final Install: 

Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to install the Fire Sensor in your house.
 
First up let's go over the materials and tools we need to install this Fire Sensor. For materials we are just going to need 2 screws, 2 conductor 22 gauge wire and white heat shrink. As for tools we are going to need wire strippers, wire cutters, a screwdriver with phillips bit, heat gun or lighter and a small flat screw driver. The links to all the materials and parts are over on my website, the link is in the description.
 
The first thing we have to do is connect the fire detector to the fire sensor and to do this we have to use the 2 conductor 22 gauge wire. Grab the wire strippers and strip off the white insulation on both ends to expose the 2 conductors. Now that we can see the red and black wires, using the wire strippers strip those as well to expose the copper wires. Right now there is one problem we have red and black wires but we need red and white wires. So take the white heat shrink and cut pieces to put over the black wires on each side of the cable. Then take a heat gun or a lighter, I will use a lighter and heat up the heat shrink so it compresses to the wire. Great! Now we have red and white wires. Now on one end of the wire fold back the copper conductors. This is the end that will go into the fire sensor. Next on the fire sensor loosen the terminal screws using a flat screwdriver. Now take the red and white wires with the folded copper conductors and put the red wire into the red side of the terminal and the white wire into the white side of the terminal. Once they are in use the small flat screwdriver and tighten the screw terminal. Now the fire sensor part is done so take the lid to the device and put it on. If your fire detectors are connected to main power then go to your breaker panel and turn off the electricity to them, just to be safe. Speaking of we will not be touching or working with high voltage wires but we will be working near them. Once the breaker is off remove the fire detector from the ceiling so we can see all of the wires. Next let’s connect the other end of the red and white wires so run them over to your fire detector, I put my wires through the blue electrical housing. After that locate the red and white wires from the fire detecor in the electrical housing and bring them out. Then remove the screw cap from red wires and add the red wire coming from the fire sensor and screw the screw cap back on. This means the red wire is connected so now let's connect the white wire. So remove the screw cap from the white set of wires and add the white wire from the fire sensor and put the screw cap back on. This means that both wires are connected and the Fire sensor is also fully connected. Now let’s tidy everything up! So tuck the red and white set of wires back into the electrical box. Following that put the fire detector back onto the ceiling. You can now also turn the breaker for the fire detectors back on. Next let’s go back to the fire sensor and mount it. To mount it we are going to use two small screws. First decide where you want to mount it, I will mount mine on a stud in ceiling. Then take one of the screws and screw it in. After that take the fire sensor and slide it underneath the screw. Then take the other screw and screw it in the top hole of the fire sensor. Great! Now, it is mounted! The last thing we have to do is plug it into power so I ran the power cable over to my network setup power strip since it was close. If you are interested in my network setup I have a couple videos on it on my channel. That is it! The fire sensor is fully connected! So let’s test it. To test it we simply have to activate the fire detectors, on mine I just have to hold down the test button and they activate. And since all the fire detectors are connected together I can do it on any fire detector, I will do it on the fire detector in the hallway. And as you can see when I hold down the button the fire detector activates and I get a Notification on my phone. If it works then that is it, the Fire Sensor is now complete and fully installed! I am so happy because I will now always know the status of my fire detectors and get a notification if something is wrong! 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. Good Bye!

Fire Sensor MQTT OpenHAB ESP8266

Links: