29 - 11 - 2020

Simple home security system

Experiment: Simple home security system.

AltonaLab diagram: KIT_SimpleHomeSecurity.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • Mini PIR motion sensor;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

The idea - Imagine you have a property 100km far from you and you do not know what is going on with it. A non stop running computer equipped with AltonaLab software and needful hardware will help you to monitoring your remote property:

  • PIR motion sensor - it is very cheap but it works more than perfect. If someone passes a few meters in front of it, the sensor's output will become at a high level for a few seconds. The sensor's output signal will be measured with an analog input of a Numato board and every security event will be caught. Let say we put the sensor in the living room;
  • Temperature sensor - some time the temperature in a remote object is very important to be monitored, for example, at the winter time the water pipes can froze, so if we know the temperature in an area close to the pipes, we can avoid the problems;
  • AltonaLab diagram has a block MailSender. You will receive an e-mail each time, when the PIR sensor catches a moving. You will receive an addition e-mail every day at 20:00h. With every e-mail you will receive an information about the temperature too. An additional e-mail at 20:00h is very important, because if there is not security event, you will receive at least one e-mail daily and you will know what happen with the house temperature. If you don't receive your daily e-mail, this is an important situation too - maybe your computer is crashed and stopped to work or someone stole your computer. If you rarely delete your emails, you'll have a history of what happened to your property in the last week or month.

Warning!!! Before starting the AltonaLab diagram, you must to do the next:

  • Set the CommPort property of Numato block in the diagram;
  • In the block MailSender to set all the properties related to the mail account, which you will use: Server, Port, UserName, Password, SenderEMail, RecipientMail, RecipientName. MailSender block is well described at the article with URL below:

https://scada.altonalab.com/index.php/en/descriptions-of-the-functional-blocks/internet-library

Because at this diagram, AltobaLab is a mail client, which is connected to the mail server, please read careful at the article above: How to send e-mail via GMail account - some special settings in the e-mail WEB site are needed, in other case, AltonaLab will be blocked to send mails from your e-mail server! If you use other mail server than GMail, similar settings are needed!

 

Please be very careful with PIR sensor! It is very small and it has not good readable texts on its board about its pins. Its board has two sides, one with electronic elements and other with soldering. The image below is with electronic elements on top side. The left pin is Positive power supply, the middle pin is signal output, then is GND. The pins of a PIR sensor are connected to the Connector board by cables Male to Female!!!

 

 The used AltonaLab diagram is:

  •  Because the diagram has to work on non stopped computer up to an infinity time, a Numato block is without fast optimization, so the parameter FastMode is unchecked and a parameter CommunicatePerSec is set to 1 sec. With this settings, when there is an event from the PIR sensor, it will be caught with 1..2 sec delay, but in this security system, the short delay is absolutely not a problem;
  • GPIO 0 from Numato board is used as analog input to measure the temperature and GPIO 1 is used as analog input too to catch the event from PIR sensor. When there is not a PIR sensor event, its output is measured as around 0 ADC value, when there is a moving in front of the sensor, its output is around 610  RAW ADC value. This is the reason because a HiHysteresists parameter of the block SchmittTrigger is set to 500 and LowHysteresists is set to 300. Using the block SchmittTrigger we convert analog value from the PIR sensor to a digital signal;
  • A measured temperature and a PIR sensor condition are shown with a text control and a lamp controls on the top side of the diagram;
  • At the block MailSender, using the parameter Inputs are added three inputs: Date from datetime type, LivingRoom from digital data type and Temp from analog data type. Those three signals are appeared as inputs of the same block. Then at the block's parameter Body is set the text below, which will form after the formatting a body of the send e-mail:

 

Date: <Date;dd.MM.yyyy HH:mm:ss>

Living room: <LivingRoom>

Temperature: <Temp;1>

 

The article from the URL below explains how to use a Text formation conception:

https://scada.altonalab.com/index.php/en/conceptions/text-formatting-strategy

Into the text of the e-mail body are used names of the block's inputs. When the block's input DoSend becomes to a high level, the names of the block's inputs will be replaced with theirs values and the result text will looks like the text below:

 
Date: 12.04.2020 11:39:18
Living room: On
Temperature: 19.5

You can easy add more inputs of a MailSender block if you want to monitoring more PIR or other sensors. At the top of the diagram are located two more lamp controls, one of them Mail is sent: will Turn ON when the e-mail is successfully sent. If some of the parameters of a MailSender blocks related to an identification to a Mail server are not correct, the Lamp control Mail send error will Turn ON.

  • The block MailSender will send a mail in two reasons - if there is an event from a PIR Sensor or the output of the block TimeSchedule becomes to a high level. The block TimeSchedule is set to send a mail every day at 20:00h. This mail is very important, because if there is not a PIR event a long time - weeks or months, using the mail from 20:00h you will know the temperature of your remote house. The other purpose of this daily mail is to know the computer is still running and is not crashed;