Showing posts with label PIR. Show all posts
Showing posts with label PIR. Show all posts

Monday, September 18, 2017

Remote zones

Recently I have started to play with feature that was on my list for long time. That is remote zone. To introduce it a little, on beginning I had in mind 2 general types of zones. Local zones are directly connected to gateway hardware. These can be build in 8 analog plus 4 digital zones, or zones connected by I2C expansion connector. Then remote zones connected either by RS485(wire) or wireless zones. Connection type does not matter to gateway, but such zones can be divided to two groups by reporting state. One group would report fully its state, that is it will report every change of state out of OK, PIR or Tamper. The other, battery powered remote zones, will only report alarm states such as PIR or Tamper. Gateway will then automatically change the zone state to OK if there is no event received for 2 seconds.

Remote zones brings new possibilities, you can build yourself a wireless PIR and add it to your gateway. Or you can build remote expander, either wired or wireless that will extend you zone count. Imagine you have barn near by, and you have only 4 wires connected to barn, that is only enough wires for authentication node. Now you decide you need two analog plus one digital zones there. Simply enough you connect such zones, with some little protection circuity, directly to authentication node. Add code to authentication node to include zone registration plus zone state handling, and you have 3 new zones connected.

I have here on my desk for test a battery powered remote zone, as shown on
picture. It is running for some days, and seems to do its job properly. I use Chinese all-in-one PIR sensor AS312 attached to PIR shell by hot glue. For this purpose I have modified standard battery node code and added zone state handling, based on interrupt signal coming form PIR sensor. The node does also temperature and humidity monitoring out of external SHT11. Battery life seems to be reasonable, with some modification it could last few months with 700mAh Li-Po. This is tempting, it would be nice to create rechargeable wireless PIR sensor that could be placed into standard commercial PIR shell :). I will publish the code to GitHub as example code.

Registering is same as for sensors. As soon as the node is powered up it will send registration packet and gateway will add a zone in zone tab. Then you can set attributes as for any other zone. Zone setting are sent back to nodes as master copy, and on next power cycle the zone is registered with newly stored  attributes. There are enforced rules for remote zones during registration, such as analog digital flag on bit 15 and it is based on registration  type ('A' or 'D'). Or remote zone flag on bit 12 is set On, and present bit flag on bit 14 is set On. Zone number cannot override any local zone, that is it cannot be lower then 13, or cannot override existing I2C zone. Zone last OK and PIR timestamps are set to registration time. Sleeping battery powered remote zones share the same message queue as sensors, that is gateway keeps registration packet for at least one hour to not loose such packets during node sleep.



Friday, October 7, 2016

Connecting balanced PIR sensor.

Picture on right side shows how to connect balanced PIR sensor. The idea is beautifully simple, I'm not the author I have got inspired by professional alarm boards. It is required to add two resistors into the end of every PIR sensor loop, and create simple voltage divider. Any analogue input on gateway is prepared to handle such divider. Resistor values are set in software and expected value is 2k2 Ohm for both. As you see from diagram there only 3 wires needed to connect a PIR to gateway input as ground is common to both. There is possibility to daisy chain the sensors in one loop, but then you need 4 wires and the resistor divider will be present only on last sensor in chain.

With such setup the gateway is then able to recognise 3 different states of any sensor. That is OK, PIR and Tamper. And it is very hard to tamper the wires connected to sensor as attacker is not able to measure the resistance hidden inside the sensor.

Tuesday, November 11, 2014

How to wire up PIR

Bellow is only valid for gateway versions bellow 1.6.

Main board is equipped with 7 analogue inputs that are able to measure different states on the sensors by using just one wire. Well actually you need three together with power and ground. On the right you can see the wiring schema.  It is a simple voltage divider with 22k and 10k resistor that take the input voltage and create different voltage levels based on state of PIR outputs. In this way we can use any commercially available PIR sensor module that is able to operate with 12V power supply.

There can be more sensors on one input, but that would require more than just three wires as you need to daisy chain the signal and signal inputs from PIR and TMP. Not problem for someone who is using CAT5e cable to wire the sensors, it is actually cheaper than original 4-wire cable.

To sum up possibilities with such setting.  We are able to see these states:

  • normal operation
  • trip
  • tamper
  • unknown state / damaged

In software we measure the voltage level in zone thread every 250 millisecond. 4 times a second is safe way as the PIR modules usually keep the outputs on or off for one whole second. Also the thread has highest priority. In order to compensate for different wire lengths, there are voltage  rages feedback specified for each state, rather than a single value. And because input voltage can change when switching to battery and back, the whole measurement is compensated to the input voltage as well.