SENSBLUE ATLAS/Node-RED: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{DISPLAYTITLE:Node-RED}} | {{DISPLAYTITLE:Node-RED}} | ||
[[File:Node-RED Logo.png|frameless|150x150px]] | |||
== Node-RED Simplified Flows == | == Node-RED Simplified Flows == | ||
'''Flow Node-RED''' | '''Flow Node-RED''' | ||
These easy-to- | These easy-to-deploy flows aim to make the integration of the ATLAS into any scenario faster by adding anabstraction layer between the user and the stack. This is achieved through the use of subflows, which containthe code needed for the features and where changes can be made if necessary, exposing a node that "hides"that more complex integration. | ||
=== 1. Import Flows to Example Folder === | === 1. Import Flows to Example Folder === | ||
To import the flows and add them to the Node-RED examples folder, execute the following: | To import the flows and add them to the Node-RED examples folder, execute the following: | ||
1.1 First | 1.1 First copy the ATLAS folder to a folder with permissions, i.e. /pi | ||
1.2 Copy the folder to the Node-RED examples folder using the command:<syntaxhighlight lang="bash"> | 1.2 Copy the folder to the Node-RED examples folder using the command:<syntaxhighlight lang="bash"> | ||
| Line 14: | Line 16: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[File:Node-RED Simplified Flows img 1.png|center|frameless|1037x1037px]] | [[File:Node-RED Simplified Flows img 1.png|center|frameless|1037x1037px]] | ||
[[Media:Simplified Flows.zip|Simplified Flows | |||
<table style="border: none; background: transparent; margin: 15px 0; border-collapse: collapse;"> | |||
<td style="padding: 0 0 0 10px; border: none; background: transparent;"> | |||
<span class="atlas-btn">[[Media:Simplified Flows.zip|Simplified Flows]]</span> | |||
</td> | |||
</table> | |||
'''Analog Inputs''' | '''Analog Inputs''' | ||
This flow | This flow implements a demonstration of acquisition and control of analog ports AI1..AI4 via MQTT and theNode-RED Dashboard 2.0. The system is divided into two main subflows: '''Analog Inputs''', for readingchannels AI1 to AI4, and '''Analog Outputs''', for configuring/reading channels AO1 and AO2. The main logic isencapsulated in subflows, allowing reuse in other tabs or projects. | ||
=== 2. Main Components === | === 2. Main Components === | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Component | !Component | ||
!Function | !Function | ||
| Line 44: | Line 51: | ||
==== 3.1 Function ==== | ==== 3.1 Function ==== | ||
The Analog Inputs subflow allows | The Analog Inputs subflow allows selecting which AI channels should be read and in which unit/type eachchannel should operate: voltage ('''voltage''') or current ('''current'''). The subflow has four outputs, one perchannel: AI1, AI2, AI3 and AI4. | ||
==== 3.2 ENV Variables ==== | ==== 3.2 ENV Variables ==== | ||
{| class="wikitable" | {| class="wikitable tech-table" | ||
!Variable | !Variable | ||
!Type | !Type | ||
| Line 53: | Line 60: | ||
!Description | !Description | ||
|- | |- | ||
|readAI1 | |'''readAI1''' | ||
|bool | |bool | ||
|true | |'''true''' | ||
|Enables/disables reading of channel AI1. | |Enables/disables reading of channel AI1. | ||
|- | |- | ||
|AI1_type | |'''AI1_type''' | ||
|string | |string | ||
|voltage | |'''voltage''' | ||
|Type of AI1 reading: voltage or current. | |Type of AI1 reading: '''voltage''' or '''current'''. | ||
|- | |- | ||
|readAI2 | |'''readAI2''' | ||
|bool | |bool | ||
|true | |'''true''' | ||
|Enables/disables reading of channel AI2. | |Enables/disables reading of channel AI2. | ||
|- | |- | ||
|AI2_type | |'''AI2_type''' | ||
|string | |string | ||
|voltage | |'''voltage''' | ||
|Type of AI2 reading: voltage or current. | |Type of AI2 reading: '''voltage''' or '''current'''. | ||
|- | |- | ||
|readAI3 | |'''readAI3''' | ||
|bool | |bool | ||
|true | |'''true''' | ||
|Enables/disables reading of channel AI3. | |Enables/disables reading of channel AI3. | ||
|- | |- | ||
|AI3_type | |'''AI3_type''' | ||
|string | |string | ||
|voltage | |'''voltage''' | ||
|Type of AI3 reading: voltage or current. | |Type of AI3 reading: '''voltage''' or '''current'''. | ||
|- | |- | ||
|readAI4 | |'''readAI4''' | ||
|bool | |bool | ||
|true | |'''true''' | ||
|Enables/disables reading of channel AI4. | |Enables/disables reading of channel AI4. | ||
|- | |- | ||
|AI4_type | |'''AI4_type''' | ||
|string | |string | ||
|voltage | |'''voltage''' | ||
|Type of AI4 reading: voltage or current. | |Type of AI4 reading: '''voltage''' or '''current'''. | ||
|} | |} | ||
| Line 108: | Line 115: | ||
} | } | ||
} | } | ||
</syntaxhighlight>If no channel is active, the function emits the warning "No AI channels selected" and does not send a message. | </syntaxhighlight>If no channel is active, the function emits the warning "'''No AI channels selected'''" and does not send a message. | ||
==== 3.4 Configuring the AI mode ==== | ==== 3.4 Configuring the AI mode ==== | ||
The group '''Set acquisition mode''' allows sending the configuration of the analogue channels to <code>analogInputs/config/in</code>. The function '''Set AIX mode''' creates taskParams only for the active channels and sets each channel as:<syntaxhighlight lang="json"> | The group '''Set acquisition mode''' allows sending the configuration of the analogue channels to <code>analogInputs/config/in</code>. The function '''Set AIX mode''' creates '''taskParams''' only for the active channels and sets each channel as:<syntaxhighlight lang="json"> | ||
{ | { | ||
"mode": "single", | "mode": "single", | ||
| Line 124: | Line 131: | ||
==== 4.2 ENV Variables ==== | ==== 4.2 ENV Variables ==== | ||
{| class="wikitable" | {| class="wikitable tech-table" | ||
!Variable | !Variable | ||
!Type | !Type | ||
| Line 213: | Line 220: | ||
=== 6. Validations and protections implemented === | === 6. Validations and protections implemented === | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Area | !Area | ||
!Validation | !Validation | ||
| Line 250: | Line 257: | ||
It is composed of two main subflows: | It is composed of two main subflows: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Component | !Component | ||
!Function | !Function | ||
| Line 281: | Line 288: | ||
=== 10. MQTT topics === | === 10. MQTT topics === | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Topic | !Topic | ||
!Usage | !Usage | ||
| Line 316: | Line 323: | ||
The parser converts the states to booleans: | The parser converts the states to booleans: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!State received | !State received | ||
!Value sent to UI | !Value sent to UI | ||
| Line 335: | Line 342: | ||
Each switch sends: | Each switch sends: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Switch | !Switch | ||
!msg.topic | !msg.topic | ||
| Line 362: | Line 369: | ||
|} | |} | ||
The '''set digital outputs''' function converts the values into physical states: | The '''set digital outputs''' function converts the values into physical states: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Logical value | !Logical value | ||
!State sent | !State sent | ||
| Line 375: | Line 382: | ||
=== 13. ENV variables of the Digital Outputs === | === 13. ENV variables of the Digital Outputs === | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Variable | !Variable | ||
!Default value | !Default value | ||
| Line 399: | Line 406: | ||
=== 14. Dashboard === | === 14. Dashboard === | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Field | !Field | ||
!Value | !Value | ||
| Line 415: | Line 422: | ||
|grid | |grid | ||
|}Groups on the page: | |}Groups on the page: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Group | !Group | ||
!Content | !Content | ||
| Line 426: | Line 433: | ||
|} | |} | ||
Input LEDs: | Input LEDs: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Value | !Value | ||
!Color | !Color | ||
| Line 437: | Line 444: | ||
|} | |} | ||
Output LEDs: | Output LEDs: | ||
{| class="wikitable" | {| class="wikitable mix-table" | ||
!Value | !Value | ||
!Color | !Color | ||