Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 22, 2016 11:02
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/fcbf5435d94cbe28448c80c08b1d7769 to your computer and use it in GitHub Desktop.
Save infosmick/fcbf5435d94cbe28448c80c08b1d7769 to your computer and use it in GitHub Desktop.
Smick_007_Soil_Moisture_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": "2e5366e1.c42d6a",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "Description",
"info": "Questo flusso mostra l'uso del sensore analogico Soil Moisture per misurare il grado di umidità del suolo.\nSi apprenderà come configurare smick per generare:\n- sequenze di misure lette dal sensore;\n- l'evento DRY (secco) quando le misure scendono al di sotto di una soglia data;\n- l'evento WET (umido) 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": 40,
"wires": []
},
{
"id": "82435511.10dbd8",
"type": "link out",
"z": "d86c452a.8b5f88",
"name": "command",
"links": [
"d00f3010.4b85b"
],
"x": 935,
"y": 360,
"wires": []
},
{
"id": "6d497ad8.a565a4",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "actions on actuators",
"info": "",
"x": 750,
"y": 260,
"wires": []
},
{
"id": "36f877bb.ff76c8",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "actions on dashboard",
"info": "",
"x": 780,
"y": 580,
"wires": []
},
{
"id": "6dd255c3.c14c1c",
"type": "e-mail",
"z": "d86c452a.8b5f88",
"server": "smtp.gmail.com",
"port": "465",
"name": "infosmick@gmail.com",
"dname": "mail",
"x": 710,
"y": 460,
"wires": []
},
{
"id": "939d133d.1e25f",
"type": "twitter out",
"z": "d86c452a.8b5f88",
"twitter": "",
"name": "tweet",
"x": 710,
"y": 520,
"wires": []
},
{
"id": "6e49feaa.a7289",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "actions on social",
"info": "",
"x": 740,
"y": 400,
"wires": []
},
{
"id": "79ade2b4.cd35cc",
"type": "function",
"z": "d86c452a.8b5f88",
"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": 640,
"wires": [
[
"272a5e87.4356d2",
"c0e3f285.429a8"
]
]
},
{
"id": "360231a3.319a9e",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "events",
"info": "",
"x": 250,
"y": 280,
"wires": []
},
{
"id": "e20a83db.438a5",
"type": "comment",
"z": "d86c452a.8b5f88",
"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": 40,
"wires": []
},
{
"id": "6af68079.2e2fc",
"type": "comment",
"z": "d86c452a.8b5f88",
"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 | Soil Moisture sensor + 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 3.3V\n\n or\n \n Device pin Smick pin \n SM 1 GND\n SM 2 A0\n R 10k 1 A0\n R 10k 2 3.3V\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": 40,
"wires": []
},
{
"id": "c2460e79.0941a",
"type": "ui_gauge",
"z": "d86c452a.8b5f88",
"name": "soil moisture",
"group": "394dacb6.3739c4",
"order": 2,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "sensor",
"label": "",
"format": "{{value}}%",
"min": 0,
"max": "100",
"colors": [
"#ff0000",
"#00ff00",
"#0000ff"
],
"x": 790,
"y": 860,
"wires": []
},
{
"id": "a87d5f44.bf3ee",
"type": "comment",
"z": "d86c452a.8b5f88",
"name": "enable/disable",
"info": "",
"x": 740,
"y": 180,
"wires": []
},
{
"id": "272a5e87.4356d2",
"type": "debug",
"z": "d86c452a.8b5f88",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 790,
"y": 700,
"wires": []
},
{
"id": "c0e3f285.429a8",
"type": "ui_text",
"z": "d86c452a.8b5f88",
"group": "394dacb6.3739c4",
"order": 3,
"width": 0,
"height": 0,
"name": "alarm msg",
"label": "last alarm",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 790,
"y": 640,
"wires": []
},
{
"id": "66aa6c62.11ec94",
"type": "ui_dropdown",
"z": "d86c452a.8b5f88",
"name": "",
"label": "mode",
"group": "394dacb6.3739c4",
"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 DRY alarm",
"value": "DRY==A0<100",
"type": "str"
},
{
"label": "set WET alarm",
"value": "WET==A0>500",
"type": "str"
}
],
"payload": "",
"topic": "",
"x": 710,
"y": 320,
"wires": [
[
"82435511.10dbd8"
]
]
},
{
"id": "b983a1a0.63139",
"type": "debug",
"z": "d86c452a.8b5f88",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 790,
"y": 800,
"wires": []
},
{
"id": "1bdf2ee.17d20d1",
"type": "range",
"z": "d86c452a.8b5f88",
"minin": "0",
"maxin": "600",
"minout": "0",
"maxout": "100",
"action": "roll",
"round": true,
"name": "%",
"x": 550,
"y": 820,
"wires": [
[
"c2460e79.0941a",
"b983a1a0.63139"
]
]
},
{
"id": "e6305255.f5035",
"type": "link in",
"z": "d86c452a.8b5f88",
"name": "response_event",
"links": [
"290027bd.4e4828"
],
"x": 175,
"y": 660,
"wires": [
[
"1ad78b9f.f2fe54"
]
]
},
{
"id": "1ad78b9f.f2fe54",
"type": "switch",
"z": "d86c452a.8b5f88",
"name": "parse",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "DRY|WET",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"outputs": 2,
"x": 270,
"y": 660,
"wires": [
[
"79ade2b4.cd35cc",
"272a5e87.4356d2"
],
[
"1bdf2ee.17d20d1"
]
]
},
{
"id": "394dacb6.3739c4",
"type": "ui_group",
"z": "",
"name": "Soil Moisture",
"tab": "d364a88e.ef3468",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "d364a88e.ef3468",
"type": "ui_tab",
"z": "",
"name": "Soil Moisture",
"icon": "dashboard",
"order": 6
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment