Introduction: Alarm PIR to WiFi (and Home Automation)

Picture of Alarm PIR to WiFi (and Home Automation)

Overview

This instructable will give you the ability to view the last date/time (and optionally a history of times) of when your House Alarm's PIRs (passive infrared sensors) were triggered, in your home automation software. In this project, I will discuss how to use with OpenHAB (free home automation software, which I personally use) although it will work with any other home automation software or application that supports MQTT (also described later in this article). This instructable will run you through the necessary steps on how to wire up a circuit board and Wemos D1 mini (an IOT board that utilises an ESP8266 chip) that taps into the alarm zones in your alarm control box so that when a zone (that contain one or more PIRs) is triggered, the Wemos sends a message wirelessly using the MQTT protocol to your home automation software which in turn, displays the last date/time of that trigger. Arduino code to program the Wemos is also provided.

Introduction

The image above is what I see via one of the screens on the OpenHAB app on my iPhone. The date/time text is colour coded to provide a quicker representation of when the PIR was triggered - it will show red (triggered within the last 1 minute), orange (triggered within last 5 minutes), green (triggered within last 30 minutes), blue (triggered within the last hour) or otherwise, black. Clicking the date/time, will display a historical view of PIR triggers, where a 1 means triggered, and 0 is idle. There are many uses for this, for example it could supplement your home presence solution, it can detect movement if you're away and via OpenHAB rules, send notifications to your phone, you could use it as I do to see if my kids are getting up in the middle of the night, triggered by a PIR that resides outside their bedrooms!

OpenHAB is simply the home automation software I use, there are many others - and if they support MQTT then you can easily adapt this project to suit the software you use.

Assumptions

This instructable assumes you already have (or will setup):

  • Obviously a home alarm system with PIRs (passive infrared sensors) and that you have access to the alarm control box to connect up the necessary wiring
  • OpenHAB (free open source home automation software) running, although as discussed it should work with any home automation software that can include an MQTT binding. Alternately, you can alter the code yourself to suit your own needs.
  • Mosquitto MQTT (or similar) broker installed and binding configured with OpenHAB (MQTT is a messaging subscribe/publish type protocol that is lightweight and great for communication between devices)

If you do not run OpenHAB and an MQTT broker, see this excellent article on the MakeUseOf web site

What do I need?

To create the wireless controller, you will need to source the following parts:

  • Wemos D1 mini V2 (has an ESP8266 wireless CHIP built-in)
  • An LM339 comparator (this will do the checking of PIR idle vs triggered)
  • A 5V DC power source for the Wemos (OR, a 5V voltage regulator such as an LM7805 plus 2 x capacitors, 10V 0.33uF and a 10V 0.1uF (or similar in size)
  • Two resistors for a voltage divider (size will depend on your alarm voltages, discussed later in the project)
  • A suitably sized breadboard for circuit setup and testing
  • A bunch of breadboard wires to connect everything together
  • Tools needed: side cutters, single core wire
  • A DC multi-meter (mandatory!)

Step 1: The Alarm System Control Box

Picture of The Alarm System Control Box

First some warnings and disclaimers!

Personally, I have a Bosch alarm system. I would highly recommend you download the relevant manual for your particular alarm system and familiarise yourself with it before you start as you will need to power down the alarm system to wire up the zones. I would also recommend you read this article in its entirety before you start!

Below is a list of a few things you should know before you start - ensure you read and understand each of them before proceeding! I take no responsibility if you screw up your alarm system and/or have to pay your installer to fix it. If you read and understand the following however and take the necessary precautions, you should be fine:

1. My alarm system had a backup battery inside the box and also had a tamper switch on the inside of the lid (that provides access to the alarm system board) so even powering the alarm off externally, when removing the front panel of the control box it triggered the alarm! To get around this whilst I worked on the project, I bypassed the tamper protection by unplugging then short circuiting the tamper switch (the thick red wire as shown in the photo above)

2. When powering the alarm system back up, after approx ~12 hours the alarm control panel started to beep with fault codes. After determining the fault codes via the manual, I found out it was warning me that:

  • The date/time was not set (I needed the master code and key sequence from the manual to reconfigure)
  • That the backup battery was not connected (easy fix, I'd just forgotten to plug the battery back in)

3. In my alarm, there are 4 x zone connection blocks (labelled Z1-Z4) for the PIR's to wire into on the main alarm board, however - my alarm system is actually capable of 8 zones. Each zone connection block can actually run 2 x zones each (Z1 does Z1 and Z5, Z2 does Z2 and Z6 and so on). The alarm system has built-in tamper protection to stop someone say, opening the lid to the alarm system as mentioned above, or cutting the wires to a PIR. It distinguishes between each zone tamper via EOL (end of line) resistors. These are specifically sized resistors that reside at the "end of the line" - in other words, inside the PIR (or control box tamper switch, or siren box or whatever is wired to that zone) As mentioned these resistors are used as 'tamper protection' - technically, if someone cuts the cables to a PIR - because the alarm system is expecting to see a certain resistance from that PIR, then should the resistance change, it assumes someone has tampered with the system and will trigger the alarm.

For example:

  • On my alarm, Zone "Z4" has 2 wires in it, one goes off to the PIR in my hallway and one goes off to the alarm control box tamper switch. Inside the hallway PIR, it has a 3300 ohm resistor. The other wire that runs to the control box tamper switch, has a 6800 ohm resistor wired in series. This is how the alarm system (logically) distinguishes between "Z4" and "Z8" tampers. Likewise, zone "Z3" has a PIR (with 3300 ohm resistor in it) and also the siren tamper switch (with 6800 ohm resistor in it) that makes up "Z7". The alarm installer would have pre-configured the alarm system so it knows what device is connected to each zone (and altered the size of the EOL resistor to suit, because the alarm system is programmed to know what size the different EOL resistors are. Under no circumstances should you change the value of these resistors!)

So based on the above, because each zone may have multiple devices attached too it (with different resistance values), and remembering the formula V=IR (voltage = amps x resistance) then that may also mean each zone may have different voltages. Which leads us onto the next step, measuring each zones IDLE vs TRIGGERED voltage...

Step 2: Measuring Alarm Zone Voltage

Picture of Measuring Alarm Zone Voltage

Once you have obtained access to the main board on your alarm system (and bypassed the tamper switch if you have one; as per the previous step) power your alarm system back on. We now need to measure each zones voltage when its IDLE (no movement in front of the PIR) vs TRIGGERED (PIR has detected movement) Grab a pen and paper so you can write down your voltage readings.

WARNING: The bulk of your alarm system is most likely to be running on 12V DC, however it will have its initial power feed at 220V (or 110V) AC, with a transformer converting power from AC to DC. READ the manual and take extra precaution ensuring you are NOT measuring any AC terminals!!! As per the screenshot of my alarm system on this page, you can see that the very bottom of the image is AC power in, transformed to 12V DC. We are measuring the 12V DC in the red boxes highlighted. Never touch the AC power. Take extreme care!

Measuring PIR Voltage

I have 4 x PIR's connected to Z1 through to Z4. Measure each of your zones as follows.

  1. First, identify the GND terminal and the zone terminals on the alarm panel. I have highlighted these in the image shown from the manual of my Bosch alarm.
  2. Grab your multimeter and set your voltage measurement to 20V DC. Connect the black (COM) cable from your multimeter to the GND terminal on the alarm. Place the red (+) lead from your multimeter on first zone - in my case labelled "Z1". Write down the voltage reading. Perform the same steps for the remaining zones. My voltage measurements are as follows:
  • Z1 = 6.65V
  • Z2 = 6.65V
  • Z3 = 7.92V
  • Z4 = 7.92V

As per the above, my first two zones only have PIR's attached too them. The latter two zones have both PIRs and tamper protection wired into them (Z3 control box tamper, Z4 siren tamper) Note the voltage differences.

3. You will likely need 2 people for this next step. You will also need to know which PIR is in which zone. Go back and read the voltage on the first zone. Now get someone in your house to walk in front of the PIR, the voltage should drop. Take note of the new voltage reading. In my case, the voltages read as follows when the PIRs are triggered:

  • Z1 = 0V
  • Z2 = 0V
  • Z3 = 4.30V
  • Z4 = 4.30V

As per the above, I can see that when zones 1 and 2 are triggered, the voltage drops from 6.65V to 0V. However when zones 3 and 4 are triggered, the voltage drops from 7.92V to 4.30V.

Measuring 12V power supply

We will be using the 12V DC terminal from the alarm control box to power our project. We need to measure the voltage from the 12V DC feed on the alarm. Although it already states 12V, we need to know a more accurate reading. In my case, it actually reads 13.15V. Write this down, you will need this value in the next step.

Why are we measuring voltage?

The reason we are needing to measure voltage for each PIR is because of the circuit we will be creating. We will be using an LM339 quad differential comparator chip (or quad op-amp comparator) as the core electrical component for this project. The LM339 has 4 independent voltage comparators (4 channels) where each channel takes 2 x input voltages (one inverting (-) and one non-inverting (+) input, see diagram) If the voltage of the inverting input voltage should drop lower than the non-inverting voltage, then its related output will be drawn to ground. Likewise, if the non-inverting input voltage drops lower than the inverting input, then the output is pulled up to Vcc. Conveniently, in my house I have 4 x alarm PIR's/zones - therefore each zone will be wired up to each channel on the comparator. If you have more than 4 x PIRs, you will need a comparator with more channels, or another LM339!

Note: The LM339 consumes power in nano-amps, so will not affect the EOL resistance of the existing alarm system.

If this is confusing, continue to the next step anyway it will start to make more sense once we wire it up!

Step 3: Creating a Voltage Divider

What is a voltage divider?

A voltage divider is a circuit with 2 x resistors (or more) in series. We provide voltage in (Vin) to the first resistor (R1) The other leg of R1 connects to the first leg of the second resistor (R2), and the other end of R2 connects to GND. We then take an output voltage (Vout) from the connection between R1 and R2. That voltage will become our reference voltage for the LM339. For more information on how voltage dividers work, see the Adohms youtube video

(Note: resistors don't have polarity, so they can be wired in either way around)


Calculating our reference voltage

Assuming that the voltage drops when your PIR is triggered (this should be the case for most alarms) then what we are trying to achieve, is to get a voltage reading that is pretty much halfway between our lowest idle voltage and our highest triggered voltage, this will become our reference voltage.

Taking my alarm as an example...

The zone idle voltages were Z1 = 6.65V, Z2 = 6.65V, Z3 = 7.92V, Z4 = 7.92V. The lowest idle voltage is therefore 6.65V

The zone triggered voltages were: Z1 = 0V, Z2 = 0V, Z3 = 4.30V, Z4 = 4.30V. The highest triggered voltage is therefore 4.30V

So we need to pick a number halfway between 4.30V and 6.65V (doesn't have to be exact, just roughly) In my case, my reference voltage needs to be around 5.46V. Note: If the lowest idle and highest triggered voltage are very close to each other due to multiple zones causing a range of different voltages, you may need to create 2 or more voltage dividers.

Calculating our resistor values for the voltage divider

Now we have a reference voltage, we need to calculate what size resistors we need to create a voltage divider that will provide our reference voltage. We will be using the 12V DC voltage source (Vs) from the alarm. However, as per the previous step when we measured the 12V DC feed we actually got 13.15V. We need to calculate the voltage divider using this value as the source.

Calculate Vout using ohms law...

Vout = Vs x R2 / (R1 + R2)

...or use an online voltage divider calculator :-)

You will need to experiment with the resistor values until you achieve your desired output. In my case, it worked out with R1 = 10k ohm and R2 = 6.8K ohm, calculated in long form as follows:

Vout = Vs x R2 / (R1 + R2)

Vout = 13.15 x 6800 / (10000 + 6800)

Vout = 89,420 / 16,800

Vout = 5.32V

Step 4: Wire Up the LM339

Picture of Wire Up the LM339

Voltage Divider to LM339 inverting inputs

As discussed earlier regarding the LM339 comparator, it will take 2 x inputs. One will be a voltage from each PIR to each channels non-inverting (+) terminal, the other will be our reference voltage to our inverting (-) terminal. The reference voltage needs to feed all 4 comparator inverting inputs. Power down your alarm system before performing these steps.

  • Run a wire from the 12V DC block on the alarm system to the + rail on your breadboard *
  • Run a wire from the GND block on the alarm system to the - rail on your breadboard
  • Install the LM339 comparator in the middle of the breadboard (the notch indicates closest to pin 1)
  • Install the 2 x resistors to create a voltage divider circuit and wire for divided voltage out
  • Run wires from the 'voltage divided' Vout to each LM339 inverting terminal
* TIP: use an alligator clip for the power if possible, as this makes it easier to provide ON/OFF power to your project


Alarm zones to LM339 non-inverting inputs

We now need to run wires from each zone on the alarm control panel to the LM339 comparator inputs. With the alarm system still powered off, for each zone feed a wire to each non-inverting (+) input on the LM339 comparator. For example, in my system:

  • Wire from Z1 goes to LM339 input 1+
  • Wire from Z2 goes to LM339 input 2+
  • Wire from Z3 goes to LM339 input 3+
  • Wire from Z4 goes to LM339 input 4+

Refer to the pin-out of the LM339 under step 3 if you a reminder (it is colour coded with the breadboard image). Once done, your breadboard should appear similar to the image shown in this step.

Power on the alarm system and measure the voltage coming out of the voltage divider to ensure it equals your reference voltage as calculated earlier.

Step 5: Wiring Up the Wemos D1 Mini

Picture of Wiring Up the Wemos D1 Mini

Wiring the Wemos D1 mini

Now we have all the LM339 inputs taken care of, we now need to wire in the Wemos D1 mini. Each LM339 output pin goes to a Wemos GPIO (general purpose input/output) pin that we will designate via code as an input pullup pin. The Wemos takes up to 5V maximum as its Vcc (input source) voltage (although regulates this internally down to 3.3V) We will use a very common LM7805 voltage regulator to drop the 12V rail on the breadboard down to 5V to power the Wemos. The datasheet for the LM7805 indicates we need a capacitor wired in on each side of the regulator to smooth out the power, as shown on the breadboard image. The longer leg of the capacitor is positive (+) so ensure this is wired in around the right way!

The voltage regulator takes voltage in (left side pin), ground (middle pin) and voltage out (right side pin) Double check the pin-out if your voltage regulator varies from the LM7805.

GPIO input pins

For this project, we are using the following pins:

  • zone Z1 => pin D1
  • zone Z2 => pin D2
  • zone Z3 => pin D3
  • zone Z4 => pin D5

Wire the outputs up from the LM339, to the related GPIO pins on the Wemos board, as per the breadboard image shown in this step. Again, I have colour coded the inputs and matching outputs, to make it easier to see what refers to what. Each GPIO pin in the Arduino is defined as an 'INPUT_PULLUP', meaning they will be pulled up to 3.3V under normal use (IDLE) and the LM339 will pull them down to ground should the PIR get triggered. The code detects the HIGH to LOW change, and sends a message wirelessly to your home automation software. If you are having issues with this working, its possible you have your inverting vs non-inverting inputs the wrong way around (if the voltage from your PIR goes high when triggered, as happens with most hobby PIR's, then you will want the connections the other way around)

Arduino IDE

Remove the Wemos from the breadboard, we now need to upload code to it (alternate link here) I won't go into detail on how to do this, as there are plenty of articles on the web on uploading code to Wemos or other ESP8266 type boards. Plug in your USB cable to the Wemos board and into your PC and fire up the Arduino IDE. Download the code and open it in your project. You will need to ensure the correct board is installed and loaded for your project as well as the correct COM port selected (Tools, Port). You will also need the appropriate libraries installed (PubSubClient, ESP8266Wifi) To get the Wemos board included in your sketch, see this article.

You will need to alter the following lines of code, and replace with your own SSID and password for your wireless connection. Also, change the IP address to point to your own MQTT broker.

// Wifi

const char* ssid = "your_wifi_ssid_here";

const char* password = "your_wifi_password_here";

// MQTT Broker

IPAddress MQTT_SERVER(172, 16, 223, 254)

Once changed, verify your code then upload to the Wemos board via a USB cable.

Notes:

  • If you are using different GPIO ports, you will need to adjust the code. If you are using more or fewer zones than I have, you will also need to adjust the code and the TOTAL_ZONES=4; constant to suit.
  • Under start up of my alarm system, the alarm system would do a power test to all 4 x PIRs which pulled all connected GPIO to ground, causing the Wemos to think the zones were being triggered. The code will ignore sending MQTT messages if it sees all 4 x zones active at the same time, as it assumes the alarm system is powering up.

Alternate download link to code HERE

Step 6: Testing and OpenHAB Configuration

Picture of Testing and OpenHAB Configuration

MQTT Testing

MQTT is a "subscribe / publish" messaging system. One or more devices can talk to an "MQTT broker" and "subscribe" to a certain topic. Any incoming messages from any other device that are "published" to that same topic, will be pushed out by the broker to all devices that have subscribed to it. It is an extremely lightweight and simple to use protocol and perfect as a simple triggering system such as the one here. For testing, you can view incoming MQTT messages from the Wemos to your MQTT broker by running the following command on your Mosquitto server (Mosquitto is one of many MQTT Broker software available). This command subscribes to incoming keepalive messages:

mosquitto_sub -v -t openhab/alarm/status

You should see inbound messages coming in from the Wemos every 30 seconds or so with the number "1" (meaning "I'm alive") If you see constant "0's" (or no response) then there is no communication. Once you see the number 1 coming in, then it means the Wemos is communicating with the MQTT broker (search "MQTT Last Will and Testament" for more information on how this works, or see this really good blog entry)

Once you have proved the communication is functional, we can test that a zone state is getting reported via MQTT. Subscribe to the following topic (the # is a wildcard)

mosquitto_sub -v -t openhab/alarm/#

The usual status messages should come in, as should the IP address of the Wemos itself. Walk in front of a PIR, and you should also see the zone information come in indicating it is OPEN, then a second or so later, that it is CLOSED, similar to the following:

openhab/alarm/status 1

openhab/alarm/zone1 OPEN

openhab/alarm/zone1 CLOSED

Once this is working, we can configure OpenHAB to have this nicely represented in the GUI.

OpenHAB Configuration

The following changes are required to OpenHAB:

'alarm.map' transform file: (optional, for testing)

CLOSED=Idle
OPEN=Triggered
NULL=Unknown
-=Unknown

'status.map' transform file:

0=Failed
1=Online
-=DOWN!
NULL=unknown

'items' file:

String          alarmMonitorState               "Alarm Monitor [MAP(status.map):%s]"                                { mqtt="<[mqttbroker:openhab/alarm/status:state:default]" }
String alarmMonitorIPAddress "Alarm Monitor IP [%s]" { mqtt="<[mqttbroker:openhab/alarm/ipaddress:state:default]" }
Number zone1_Chart_Period "Zone 1 Chart"
Contact alarmZone1State "Zone 1 State [MAP(alarm.map):%s]" { mqtt="<[mqttbroker:openhab/alarm/zone1:state:default" }
String alarmZone1Trigger "Lounge PIR [%1$ta %1$tr]"
Number zone2_Chart_Period "Zone 2 Chart"
Contact alarmZone2State "Zone 2 State [MAP(alarm.map):%s]" { mqtt="<[mqttbroker:openhab/alarm/zone2:state:default" }
String alarmZone2Trigger "First Hall PIR [%1$ta %1$tr]"
Number zone3_Chart_Period "Zone 3 Chart"
Contact alarmZone3State "Zone 3 State [MAP(alarm.map):%s]" { mqtt="<[mqttbroker:openhab/alarm/zone3:state:default" }
String alarmZone3Trigger "Bedroom PIR [%1$ta %1$tr]"
Number zone4_Chart_Period "Zone 4 Chart"
Contact alarmZone4State "Zone 4 State [MAP(alarm.map):%s]" { mqtt="<[mqttbroker:openhab/alarm/zone4:state:default" }
String alarmZone4Trigger "Main Hall PIR [%1$ta %1$tr]"

'sitemap' file (including rrd4j graphing):

Text item=alarmZone1Trigger valuecolor=[<=60="#ff0000", <=300="#ffa500", <=600="#008000", <=3600="#0000ff", >3600="#000000"] {
Frame {
Switch item=zone1_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone1State&period=h" visibility=[zone1_Chart_Period==0, zone1_Chart_Period==Uninitialized]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone1State&period=D" visibility=[zone1_Chart_Period==1]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone1State&period=W" visibility=[zone1_Chart_Period==2]
}
}
Text item=alarmZone2Trigger valuecolor=[<=60="#ff0000", <=300="#ffa500", <=600="#008000", <=3600="#0000ff", >3600="#000000"] {
Frame {
Switch item=zone2_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone2State&period=h" visibility=[zone2_Chart_Period==0, zone2_Chart_Period==Uninitialized]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone2State&period=D" visibility=[zone2_Chart_Period==1]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone2State&period=W" visibility=[zone2_Chart_Period==2]
}
}
Text item=alarmZone3Trigger valuecolor=[<=60="#ff0000", <=300="#ffa500", <=600="#008000", <=3600="#0000ff", >3600="#000000"] {
Frame {
Switch item=zone3_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone3State&period=h" visibility=[zone3_Chart_Period==0, zone3_Chart_Period==Uninitialized]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone3State&period=D" visibility=[zone3_Chart_Period==1]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone3State&period=W" visibility=[zone3_Chart_Period==2]
}
}
Text item=alarmZone4Trigger valuecolor=[<=60="#ff0000", <=300="#ffa500", <=600="#008000", <=3600="#0000ff", >3600="#000000"] {
Frame {
Switch item=zone4_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone4State&period=h" visibility=[zone4_Chart_Period==0, zone4_Chart_Period==Uninitialized]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone4State&period=D" visibility=[zone4_Chart_Period==1]
Image url="http://localhost:8080/rrdchart.png?items=alarmZone4State&period=W" visibility=[zone4_Chart_Period==2]
}
}

// OPTIONAL but handy for diagnosing status and IP address
Text item=alarmMonitorState
Text item=alarmMonitorIPAddress

'rules' file:

rule "Alarm Zone 1 state change"
when
Item alarmZone1State changed to OPEN
then
postUpdate(alarmZone1Trigger, new DateTimeType())
alarmZone1State.state = CLOSED
end
rule "Alarm Zone 2 state change"
when
Item alarmZone2State changed to OPEN
then
postUpdate(alarmZone2Trigger, new DateTimeType())
alarmZone2State.state = CLOSED
end
rule "Alarm Zone 3 state change"
when
Item alarmZone3State changed to OPEN
then
postUpdate(alarmZone3Trigger, new DateTimeType())
alarmZone3State.state = CLOSED
end
rule "Alarm Zone 4 state change"
when
Item alarmZone4State changed to OPEN
then
postUpdate(alarmZone4Trigger, new DateTimeType())
alarmZone4State.state = CLOSED
end

You may need to change the above OpenHAB configuration slightly to suit your own setup.

If you have any problems with PIRs being triggered then start from the beginning, and measure voltages for each part of the circuit. Once you are happy with that, check your wiring, ensure there is a common ground, check messages on the Wemos via a serial debug console, check MQTT communication and check the syntax of your transform, items and sitemap files.

Good luck!

Comments

jade7272 made it! (author)2017-11-12

This is a typical Security PIR it doesn't supply voltage to the Wires that comes from the security panel there is just typically just 1 NO 1 NC and a common ..I'm posting a full instructable on Friday to totally do away with the Security panel and utilize a raspi and some particles to do the same thing ..

chimeranzl (author)jade72722017-11-13

The entire purpose of the instructable is to get the date and time of when each PIR is triggered to your home automation from an *EXISTING* security system, not do away with it or retrofit new PIRs. The LM339 would not be required if you were wiring up your own “IOT/hobby based” PIRs that have voltage ranges within “IOT/hobby based” ESP type chips (eg: 3.3-5V). That would be super simple. What you are eluding too implies you are wiring up your own PIRs rather than utilizing existing wiring from an existing security system, and Im aware of NO or NC wires in a PIR, I simply found this was the easiest solution that will work with the majority of existing security systems that utilize EOL resistors without effecting the resistance of what the security system is “expecting” to see - where any change would cause tamper alerts triggering the alarm to sound.

jade7272 (author)2017-11-12

Pretty Good Instructable ..Question why are you using the MQTT maps and rules ..in the OpenHab..Wouldn’t a standard MQTT reporting work just as well and be a little less complicated ..Like the sitemap File would just have one line

Text item = officemotion

Item file

Number Officemotion "Office Motion [%.2f]" (Alarms) {mqtt<[mymosquitto:mosquitto/MyHouse/OffMot:state:default"}

That’s all I’m using

Then I just subscribe to the MQTT ..With Node Red and send it off to my Particle subscribe ..And activate an alarm ..Works pretty good ..Or am I missing something

chimeranzl (author)jade72722017-11-13

You’re missing something. Perhaps best to read the instructable in its entirety. MQTT does not do reporting, and it is not MQTT maps (transforms) and rules - they are part of OpenHAB. The transforms are to show status of the Wemos (online or not), the rules are to present the last date/time of the trigger. You can do a number as you have suggested, but that will just alert you that the PIR has been triggered, not when it was triggered. Saves having to use timers to try and keep track of date and time on the Wemos itself.

diy_bloke (author)2017-11-03

looks great but I am a bit confused by the PIR's and the LM339. Don't the Pirs just give off a high or a low signal? so what are the comparators for then, or do i miss something?

chimeranzl (author)diy_bloke2017-11-03

Hey,

The PIRs give off a lower voltage when triggered (some hobby PIRs are the opposite, low when idle high when triggered) As per the example of voltages I’ve mentioned for my system in this instructable, for example zone 1 - it’s 6.65V while idle and 0V when triggered, zone 3 was 7.92V idle and 4.30V triggered. We can’t plug this directly into the GPIO pins of the Wemos, as it’ll fry it!!

The GPIO pins are only capable of 0V (LOW) or 3.3V (HIGH) - (although I believe they maybe up to 5V tolerant) The LM339 simply compares two input voltages and puts out one of two levels depending on the result of the comparison. The LM339 outputs are open collector, and connected to GPIO pins of the Wemos which are defined as input pull-up - in other words internally pulled up to 3.3V (HIGH) in the Wemos. When the PIR is triggered, the voltage difference at the LM339 inputs change, therefore pulling its related output to GND (LOW)

If your alarm system PIR happened to output 3.3V and 0V, there would be no need for the LM339 (most hobby based PIRs would be in this category, but not home alarm PIRs hence the need for the comparator)

Hope that makes sense!

diy_bloke (author)chimeranzl2017-11-04

ah ok, I see. thanks for your extensive explanation

About This Instructable

704views

27favorites

License:

More by chimeranzl:Alarm PIR to WiFi (and Home Automation)Wifi to RF - Door LockHRV Temperature to OpenHAB Via ESP8266 (Serial Code Example!)
Add instructable to: