Smick_005_PIR

This flow shows the use of a PIR sensor. You will learn how to configure Smick to generate the ALARM event when the sensor detects motion. The associated dashboard allows you to:

  • Enable / disable the said event;
  • Real-time view a received alarm;
  • Displays the last alarm detected and sent to e-mail and twitter.
[
    {
        "id": "5f462c.328339d4",
        "type": "link out",
        "z": "1603a5ba.b22cfa",
        "name": "command",
        "links": [
            "d00f3010.4b85b"
        ],
        "x": 875,
        "y": 380,
        "wires": []
    },
    {
        "id": "df06890c.3e3848",
        "type": "trigger",
        "z": "1603a5ba.b22cfa",
        "op1": "1",
        "op2": "0",
        "op1type": "str",
        "op2type": "str",
        "duration": "5",
        "extend": true,
        "units": "s",
        "reset": "",
        "name": "",
        "x": 320,
        "y": 520,
        "wires": [
            [
                "114400fe.b4db3f",
                "e083b16d.b0cc4",
                "7cd8f38f.bccb2c"
            ]
        ]
    },
    {
        "id": "b84f0c59.2bd47",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "actions on actuators",
        "info": "",
        "x": 510,
        "y": 320,
        "wires": []
    },
    {
        "id": "b33eb37e.0bea9",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "actions on dashboard",
        "info": "",
        "x": 780,
        "y": 460,
        "wires": []
    },
    {
        "id": "3c181883.eca398",
        "type": "e-mail",
        "z": "1603a5ba.b22cfa",
        "server": "smtp.gmail.com",
        "port": "465",
        "name": "infosmick@gmail.com",
        "dname": "mail",
        "x": 730,
        "y": 720,
        "wires": []
    },
    {
        "id": "a5f30042.c809c",
        "type": "twitter out",
        "z": "1603a5ba.b22cfa",
        "twitter": "",
        "name": "tweet",
        "x": 730,
        "y": 780,
        "wires": []
    },
    {
        "id": "377a199b.519666",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "actions on social",
        "info": "",
        "x": 760,
        "y": 660,
        "wires": []
    },
    {
        "id": "114400fe.b4db3f",
        "type": "function",
        "z": "1603a5ba.b22cfa",
        "name": "alarm msg",
        "func": "function timeDate(tz) {\n    var d = new Date(Date.now()+tz*3600000);\n\n    return  d.getUTCHours() + \":\" +\n            d.getUTCMinutes() + \":\" +\n            d.getUTCSeconds() + \" \" +\n            d.getUTCDate()\t+\"/\" +\n            (d.getUTCMonth()+1) + \"/\" +\n            d.getUTCFullYear();\n}\n\nmsg.payload=\"motion detected in the living room at \" +\n            timeDate(1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 580,
        "wires": [
            [
                "d5ab1a8b.ed5ba8",
                "fe07f077.ee471"
            ]
        ]
    },
    {
        "id": "888f6c55.0931e",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "events",
        "info": "",
        "x": 170,
        "y": 300,
        "wires": []
    },
    {
        "id": "1c914744.1b3cc9",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "Description",
        "info": "Questo flusso mostra l'uso di un senore PIR.\nSi apprenderà come configurare smick per generare l'evento ALARM quando il sensore rileva un movimento.\nLa dashboard associata consente di:\n- abilitare/disabilitare il suddetto evento;\n- di visualizzare in tempo reale un allarme ricevuto;\n- di visualizzare l'ultimo allarme rilevato ed inviato su e-mail e twitter.\n\n\nThis flow shows the use of a PIR sensor.\nYou will learn how to configure Smick to generate the ALARM event when the sensor detects motion.\nThe associated dashboard allows you to:\n- Enable / disable the said event;\n- Real-time view a received alarm;\n- Displays the last alarm detected and sent to e-mail and twitter.\n",
        "x": 130,
        "y": 60,
        "wires": []
    },
    {
        "id": "8a9531fb.2f078",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "Licence & History",
        "info": "Package : Smick v.1\nModule  : LED - digital output\nAuthor  : Curci\nLicence : (CC) BY-NC-SA\n\nThis work is licensed under a Creative Commons \nAttribution-NonCommercial-ShareAlike \n4.0 International License.\n\nHistory\n\nDate        Author  Description\n2016.12.17  Curci   genesis",
        "x": 300,
        "y": 60,
        "wires": []
    },
    {
        "id": "a6a3af6e.8b597",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "BOM",
        "info": "Bill Of Material\n\nHardware:\n\n    1 Human internet terminal (PC, tablet or smartphone) connected to the internet\n    1 Smick Wi-Fi connected to the internet\n    1 PIR\n\nHW Connections:\n\n    Device  pin     Smick pin\n    PIR     -       GND\n    PIR     out     D2\n    PIR     +       5V\n\nFlow Connections:\n\n    Smick_001_console\n\nAccount:\n\n    Wi-Fi credentials\n    MQTT broker\n    FRED\n    E-mail\n    Twitter\n",
        "x": 450,
        "y": 60,
        "wires": []
    },
    {
        "id": "be5ea091.bd123",
        "type": "link in",
        "z": "1603a5ba.b22cfa",
        "name": "alarm",
        "links": [
            "139a7884.1997d7"
        ],
        "x": 175,
        "y": 520,
        "wires": [
            [
                "df06890c.3e3848"
            ]
        ]
    },
    {
        "id": "e083b16d.b0cc4",
        "type": "ui_gauge",
        "z": "1603a5ba.b22cfa",
        "name": "alarm",
        "group": "43f2185.a7a3fe8",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "wave",
        "title": "living room",
        "label": "",
        "format": "",
        "min": 0,
        "max": "1",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "x": 730,
        "y": 520,
        "wires": []
    },
    {
        "id": "7cd8f38f.bccb2c",
        "type": "function",
        "z": "1603a5ba.b22cfa",
        "name": "internal led",
        "func": "\nmsg.payload=\"led=\" + msg.payload;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 380,
        "wires": [
            [
                "5f462c.328339d4"
            ]
        ]
    },
    {
        "id": "267f99af.2d3286",
        "type": "ui_switch",
        "z": "1603a5ba.b22cfa",
        "name": "",
        "label": "alarm enable",
        "group": "43f2185.a7a3fe8",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": true,
        "topic": "",
        "style": "",
        "onvalue": "alarm==d2=1",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "alarm==null",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 690,
        "y": 240,
        "wires": [
            [
                "5f462c.328339d4"
            ]
        ]
    },
    {
        "id": "eb729a1.74e5568",
        "type": "comment",
        "z": "1603a5ba.b22cfa",
        "name": "enable/disable",
        "info": "",
        "x": 700,
        "y": 200,
        "wires": []
    },
    {
        "id": "d5ab1a8b.ed5ba8",
        "type": "debug",
        "z": "1603a5ba.b22cfa",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 750,
        "y": 840,
        "wires": []
    },
    {
        "id": "fe07f077.ee471",
        "type": "ui_text",
        "z": "1603a5ba.b22cfa",
        "group": "43f2185.a7a3fe8",
        "order": 0,
        "width": 0,
        "height": 0,
        "name": "alarm msg",
        "label": "Last",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 750,
        "y": 580,
        "wires": []
    },
    {
        "id": "43f2185.a7a3fe8",
        "type": "ui_group",
        "z": "",
        "name": "PIR alarm",
        "tab": "7482d054.817ee",
        "order": 1,
        "disp": false,
        "width": "6"
    },
    {
        "id": "7482d054.817ee",
        "type": "ui_tab",
        "z": "",
        "name": "PIR alarm",
        "icon": "dashboard",
        "order": 4
    }
]
infosmick

Flow Info

created 3 months, 2 weeks ago

Node Types

Core
  • comment (x8)
  • debug (x1)
  • e-mail (x1)
  • function (x2)
  • trigger (x1)
  • twitter out (x1)
Other
  • link in (x1)
  • link out (x1)
  • ui_gauge (x1)
  • ui_group (x1)
  • ui_switch (x1)
  • ui_tab (x1)
  • ui_text (x1)

Tags

  • IoT
  • Smick
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option