Home Security Alarm

Hello, I am trying to make a home security alarm but I am new to Node-Red.

When the PIR has detected something i want it to send me a text on my mobile phone and a small led and siren should jump on when movement is detected.

Now I am stuck at the part where i want the siren and led to jump on untill I turn it back off.

Can someone please help me figure this out?
Kind regards, Zeno

First you need to decide on a hardware platform.

I am currently using the Raspberry Pi 3 B+

And do you plan to use that to provide the hardware platform for the light and sounder?

If so, you should search for people who have already added such things to Node-RED. There are examples around.

Well, i have looked around a bit but i didnt really find anything.
At the moment my program is working fine, when the PIR detects something, the siren makes sound and the led gives light. But that is only for a short amount of time (± 2 seconds) is it possible to keep it on untill i turn it back off on the dashboard?

You've not told us what siren you are using or what your flow looks like.

Put a Switch node in before the dashboard items so that your existing message can only switch the led and siren on not off. Only send On messages (whatever they are) to o/p 1 and ignore any others. Then from your acknowledge button feed the Off message to the led and siren.
The result is that the PIR can only switch them on, and your button will switch them off.

i also was looking for somthing like this , i ended up twiking my flow and used the below Node
it really helped me ,

i am doing somthing real simple

  1. MP3 File on my PC (used for sirene)
  2. and all PIRs go to counter
  3. if the counter is more than two in less than 10 secs
    i get a notification on my phone and also the siren will go on very load, connected to desktop studio monitors

i have doors, windows ,PIRs, there is no chance to move around the house without making it go on twice...

You might want to take a look at this project I created for my IoT students.
I reckon you could modify it to match your needs.
It uses a Wemos D1 Mini to handle the IR side of things and then send an MQTT message to RPi-3+ running Node-RED.
I've used Telegram to send messages to my mobile phone as the implementation is very easy.

Cheers from David.

1 Like

This is excactly what i need, could you get a little more specific into the programming in node-red?

I suppose I'd better say this as nobody else has.

It is easy to get carried away with things like this as Node-RED, Pi's, ESP's, etc make everything so easy to do. I certainly happily get carried away.

However, there is a big difference between doing something for the fun of it and relying on something for security.

A home-grown security "thing" will be a step up for most people who probably have nothing to start with. However, you wouldn't want to rely on this if you were a high-profile target or trying to protect a business.

I have things like this set up at home but I don't rely on it for security.

Anyway, I'm sure you know all these things so I'll shut up now.

2 Likes

Hi Julian - totally agree with all your comments.

Sorry about the delay in responding - I've been very busy this week.
Here's a cut-down version of the NR flow for the IR security system.

[{"id":"121e7a1e.9edc66","type":"mqtt in","z":"d604a211.103938","name":"","topic":"node41/reading/ir/level/#","qos":"2","datatype":"auto","broker":"a86115be.40797","x":230,"y":340,"wires":[["3cb3209c.2c5588","99766cf1.371078"]]},{"id":"28bc587e.eaea28","type":"rising-edge","z":"d604a211.103938","name":"","threshold":"0","x":650,"y":340,"wires":[["2631a893.1d397"]]},{"id":"2631a893.1d397","type":"function","z":"d604a211.103938","name":"","func":"msg.payload=\"IR detected in rear garden\";\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":340,"wires":[["3aed7900.dd064e"]]},{"id":"3cb3209c.2c5588","type":"function","z":"d604a211.103938","name":"","func":"if (msg.payload == \"1\")\n    {\n        msg.payload = 1;\n    }\nelse if (msg.payload == \"0\")\n    {\n        msg.payload = 0;\n    }\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":340,"wires":[["28bc587e.eaea28"]]},{"id":"99766cf1.371078","type":"debug","z":"d604a211.103938","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":400,"wires":[]},{"id":"7be32425.13144c","type":"inject","z":"d604a211.103938","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":240,"wires":[["3cb3209c.2c5588"]]},{"id":"6ae036c5.ae339","type":"inject","z":"d604a211.103938","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":280,"wires":[["3cb3209c.2c5588"]]},{"id":"fdaccb35.7a9a48","type":"inject","z":"d604a211.103938","name":"Test IR unit remotely","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":160,"wires":[["e103eaa7.5b52b"]]},{"id":"78e3cdd4.4c3fcc","type":"mqtt out","z":"d604a211.103938","name":"","topic":"node41/cmd","qos":"","retain":"","broker":"a86115be.40797","x":570,"y":160,"wires":[]},{"id":"e103eaa7.5b52b","type":"function","z":"d604a211.103938","name":"","func":"msg.payload = \"event,IRon\";\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":160,"wires":[["78e3cdd4.4c3fcc"]]},{"id":"3aed7900.dd064e","type":"telegrambot-notify","z":"d604a211.103938","name":"","bot":"","chatId":"","message":"","parseMode":"","x":980,"y":340,"wires":[]},{"id":"a86115be.40797","type":"mqtt-broker","z":"","name":"Use this one 192.168.1.142","broker":"192.168.1.142","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

I used a Wemos D1 Mini to handle the IR detector - wired it up as a switch.


I also used a set of "Rules" (in the Wemos) to remotely trigger GPIO-13 to remotely test the IR detector was working.

On IRon do
  gpio,13,1 //Set input 0 High
  timerSet,1,1 //timer 1 set for 1 sec
endon
 
On IRoff do 
  timerSet,1,0 //timer 1 set to halt,
  gpio,13,0 //Set input 0 low (normal state)
endon
 
On Rules#Timer=1 do  
  gpio,13,0 //Set input 0 low (normal state)
endon

Hope you find the above files/screenshots useful.
Regards from David.

PS:
I should add that I arrange for all my nodes to post their data in the format:

<node_number>/reading/<device_name>/<value>

You might need to alter the topic in the MQTT-In and MQTT-Out nodes to match the format you use.

1 Like

2 posts were split to a new topic: Security system not working