Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 22, 2016 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infosmick/e692a115d8cbf5c5a8cc70f2af9c30f7 to your computer and use it in GitHub Desktop.
Save infosmick/e692a115d8cbf5c5a8cc70f2af9c30f7 to your computer and use it in GitHub Desktop.
Smick_006_analog_in_v2

This flow shows the use of analog sensors (potentiometer, LDR, ...). You will learn how to configure Smick to generate:

  • Measurement sequences read from the sensor;
  • The LOW event when measurements fall below a certain threshold;
  • The High event when measurements exceed a certain threshold. The associated dashboard allows you to:
  • Enable / disable these events;
  • Measurements of real-time display on a received indicator (gauge);
  • Displays the last LOW / HIGH detected and sent to e-mail alarm and Twitter.
[
{
"id": "82283593.256f98",
"type": "link out",
"z": "c50576d5.b7af18",
"name": "command",
"links": [
"d00f3010.4b85b"
],
"x": 935,
"y": 400,
"wires": []
},
{
"id": "b05f8481.58d868",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "actions on actuators",
"info": "",
"x": 750,
"y": 300,
"wires": []
},
{
"id": "182a53b5.e0602c",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "actions on dashboard",
"info": "",
"x": 760,
"y": 700,
"wires": []
},
{
"id": "7b9c1fec.633c3",
"type": "e-mail",
"z": "c50576d5.b7af18",
"server": "smtp.gmail.com",
"port": "465",
"name": "infosmick@gmail.com",
"dname": "mail",
"x": 710,
"y": 500,
"wires": []
},
{
"id": "68b0bc07.f7e484",
"type": "twitter out",
"z": "c50576d5.b7af18",
"twitter": "",
"name": "tweet",
"x": 710,
"y": 560,
"wires": []
},
{
"id": "92c8a391.39b3f",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "actions on social",
"info": "",
"x": 740,
"y": 440,
"wires": []
},
{
"id": "dba2835f.b5b5d",
"type": "function",
"z": "c50576d5.b7af18",
"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=msg.payload + \" level alarm at \" + timeDate(1);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 700,
"wires": [
[
"390ea4e5.d7bf1c",
"38b4d5ef.66eb5a"
]
]
},
{
"id": "52b00a19.992274",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "events",
"info": "",
"x": 250,
"y": 320,
"wires": []
},
{
"id": "e213e6f9.afc0c8",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "Description",
"info": "Questo flusso mostra l'uso di sensori analogici (Potentiometer, LDR,...).\nSi apprenderà come configurare smick per generare:\n- sequenze di misure lette dal sensore;\n- l'evento LOW quando le misure scendono al di sotto di una soglia data;\n- l'evento HIGH quando le misure superano una soglia data.\nLa dashboard associata consente di:\n- abilitare/disabilitare i suddetti eventi;\n- di visualizzare in tempo reale le misure ricevute su un indicatore (gauge);\n- di visualizzare l'ultimo allarme LOW/HIGH rilevato ed inviato su e-mail e twitter.\n\n\nThis flow shows the use of analog sensors (potentiometer, LDR, ...).\nYou will learn how to configure Smick to generate:\n- Measurement sequences read from the sensor;\n- The LOW event when measurements fall below a certain threshold;\n- The High event when measurements exceed a certain threshold.\nThe associated dashboard allows you to:\n- Enable / disable these events;\n- Measurements of real-time display on a received indicator (gauge);\n- Displays the last LOW / HIGH detected and sent to e-mail alarm and Twitter.",
"x": 110,
"y": 80,
"wires": []
},
{
"id": "d2515f8c.357ef",
"type": "comment",
"z": "c50576d5.b7af18",
"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": 280,
"y": 80,
"wires": []
},
{
"id": "9b87b83d.556c68",
"type": "comment",
"z": "c50576d5.b7af18",
"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 Pot | LDR + 10kohm resistor\n\nHW Connections:\n\n Device pin Smick pin\n Pot left GND\n Pot center A0\n Pot right 3.3V\n \n or \n \n Device pin Smick pin \n LDR 1 GND\n LDR 2 A0\n R 10k 1 A0\n R 10k 2 GND\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": 430,
"y": 80,
"wires": []
},
{
"id": "cad53aa1.dde3e8",
"type": "ui_gauge",
"z": "c50576d5.b7af18",
"name": "analogic sensor",
"group": "7c709b15.0385b4",
"order": 2,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "sensor",
"label": "",
"format": "{{value}}",
"min": 0,
"max": "1023",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 740,
"y": 900,
"wires": []
},
{
"id": "71f47e0a.f5777",
"type": "comment",
"z": "c50576d5.b7af18",
"name": "enable/disable",
"info": "",
"x": 740,
"y": 220,
"wires": []
},
{
"id": "390ea4e5.d7bf1c",
"type": "debug",
"z": "c50576d5.b7af18",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 730,
"y": 620,
"wires": []
},
{
"id": "38b4d5ef.66eb5a",
"type": "ui_text",
"z": "c50576d5.b7af18",
"group": "7c709b15.0385b4",
"order": 3,
"width": 0,
"height": 0,
"name": "alarm msg",
"label": "last alarm",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 730,
"y": 760,
"wires": []
},
{
"id": "5d74af2b.64375",
"type": "ui_dropdown",
"z": "c50576d5.b7af18",
"name": "",
"label": "mode",
"group": "7c709b15.0385b4",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"options": [
{
"label": "disable",
"value": "A0==NULL",
"type": "str"
},
{
"label": "enable",
"value": "A0@1",
"type": "str"
},
{
"label": "set LOW alarm",
"value": "LOW==A0<340",
"type": "str"
},
{
"label": "set HIGH alarm",
"value": "HIGH==A0>680",
"type": "str"
}
],
"payload": "",
"topic": "",
"x": 710,
"y": 360,
"wires": [
[
"82283593.256f98"
]
]
},
{
"id": "da035eef.f0ae6",
"type": "debug",
"z": "c50576d5.b7af18",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 730,
"y": 840,
"wires": []
},
{
"id": "4a2e69f2.1bb9e8",
"type": "link in",
"z": "c50576d5.b7af18",
"name": "response_event",
"links": [
"290027bd.4e4828"
],
"x": 195,
"y": 700,
"wires": [
[
"187b99d0.1afeb6"
]
]
},
{
"id": "187b99d0.1afeb6",
"type": "switch",
"z": "c50576d5.b7af18",
"name": "parse",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "HIGH|LOW",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"outputs": 2,
"x": 310,
"y": 700,
"wires": [
[
"dba2835f.b5b5d",
"390ea4e5.d7bf1c"
],
[
"da035eef.f0ae6",
"cad53aa1.dde3e8"
]
]
},
{
"id": "7c709b15.0385b4",
"type": "ui_group",
"z": "",
"name": "Analogic sensor",
"tab": "b07a13ec.60f27",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "b07a13ec.60f27",
"type": "ui_tab",
"z": "",
"name": "Analogic input",
"icon": "dashboard",
"order": 5
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment