Example 2 Health Monitoring¶
Hardware Preparation¶
Pi Terminal | Blood Oxygen Detection | Crowtail-Pulse Sensor |
---|---|---|
Pin Connection¶
Pi Terminal | Blood Oxygen Detection | Crowtail-Pulse Sensor |
---|---|---|
VCC | VCC | VCC |
ADC+ | SIG | |
- | NC | |
GND | GND | GND |
SDA1 | SDA | |
SCL1 | SCL |
- The pulse sensor module outputs analog voltage values. We need to use the ADS1115 chip to convert the collected analog voltage value into a digital voltage value. Therefore, we need to connect the pulse detection module to the ADC interface of the Pi Terminal.
- Note: The ADC1115 should be common grounded with the CM4+.
- The MAX30102 module integrates an IIC data output module internally. Therefore, we need to connect the SDA and SCL of the IIC on the blood oxygen detection module to the IIC bus 1 on the Pi Terminal.
Usage¶
Set up an MQTT server on the Pi Terminal.¶
If you are using the image we provided, the mosquitto software is installed, and it will automatically enable when you power on the Pi Terminal.
If you haven't install the mosquitto, you can get it from GitHub and install it, and then use the command mosquitto - c~/mosquitto -1.5.4/mosquitto. conf - v
to enable the MQTT server.
Mosquitto¶
After installing the mosquitto software, there will be a mosquitto.exe file in the installation directory (mosquitto is installed in the/etc/directory by default), which is the startup configuration file for mosquitto. We can modify some configurations of the mosquitto server by changing the contents of this file. For example, the server account, password, and so on.
Go to the /etc/mosquitto/directory and use command sudo vim mosquitto. conf
to open the configuration file
As we can see, there are also some explanations and the paths to other configuration files and logs inside. What we need to focus on is the last line 'including. dir/etc/mosquitto/conf. d'. We entered this directory.
There are three files in this directory. First, we open the README and check the instructions. We can see that the configuration file we need is the .conf file. Open the mosquitto. conf file
You can see that the first two lines inside indicate that our password is configured in the pwfile file in the same level directory The fourth and fifth lines indicate whether anonymous login is allowed (i.e. whether password login is required), and the current setting value is false, which means that a password is not required to log in to the server. If true is set, this password needs to be entered in the specified password file (pwfile). It is necessary to specify the port number that the server needs to listen to, which is set to 1883 (the commonly used MQTT listening port number, not recommended to be modified).
Set node red health monitoring process¶
In this Node Red application process, we need to use two key nodes, one is the pulse node, which is used to detect pulses. Another one is the max30102 node, which is used to detect blood oxygen. And both of these nodes need to be customized. Please turn back to Pi Terminal Node Red Tutorial to check how to create customized node. And click NodeRed-nodes.zip to download the customized node we created for reference.
Pulse Detection¶
-
Firstly, let's establish a process for detecting pulse. Drag and drop the pulse node first.
-
At the upstream node of the pulse node, we define a switch node in the dashboard so that we can control pulse detection module in the UI. The configuration of the switch node is as follows:
pulse-switch-1 pulse-switch-2 pulse-switch-3 -
Double click the switch node, and click the "Edit" button of the "Group" to enter "Edit dashboard group node" page. Continue click the "Edit" button of the "Tab" to enter "Edit dashboard tab node". Set a name for the UI panel. Here I named it "Elecrow for medical". Click "Update" to save and go back to the previous page.
-
On "Edit dashboard group node" page, select "Elecrow for medical" for the "Tab". And name the group as medical. Therefor the sub box named "medical" will be created.
-
-
After configuring the switch, you can connect it to the pulse node. As long as the pulse module is opened in the UI, the actual pulse module can work.
-
Next we need to connect a debug node for pulse data output. (Name the node as "pulse date" by change "Label")
-
Then we need a chart node to show the pulse date in a recent hour. Drag the chart node in to dashboard, and double click it for configuration.
- Select "[Elecrow for medical]medical" for the "Group"
- Fill in "pulse date" for the "Label"
- Other items can be set according to your preferences
-
Connect the pulse data chart node to the pulse node.
-
We can also use other type of chart to show the data. We have chosen the Level node here, which can display data in real-time like a bar chart.
- Select "[Elecrow for medical]medical" for the "Group"
- Fill in "pulse date" for the "Label"
- Other items can be set according to your preferences
-
We now have a completed process for pulse detection.
Blood Oxygen Detection¶
The construction of the blood oxygen detection process is also similar, drag the max30102 module like the pulse module, and then configure the upstream and downstream nodes. The following is the content of each node in the process of using the max30102 module.
Switch node
text node
chart node
After completing the above configuration, the complete flowchart is as follows
Enter the URL: 127.0.0.1 in the browser to access the corresponding ui panel.
Expand: How to import JSON files¶
Open the NodeRed, click the menu,and select Import.
Then click "select a file to import" in the import section and choose the corresponding JSON file to import.
Alternatively, you can copy and paste all the contents of the JSON file into the panel, and click on 'import' to complete the process.
The following is the JSON file of the nodes that have been arranged for the flow. Simply import it into NodeRed and you get the complete flow.
Please download the file at: Medical_App.json
[
{
"id": "81d32c34d77268a7",
"type": "tab",
"label": "flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "694a8a64a7102298",
"type": "pulse",
"z": "81d32c34d77268a7",
"name": "",
"x": 270,
"y": 120,
"wires": [
[
"199d47520299e2a8",
"12ef547ef25315c4",
"c838025a9b044660",
"a0f364f8c38154ac"
]
]
},
{
"id": "db1b776f9661a08c",
"type": "inject",
"z": "81d32c34d77268a7",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 90,
"y": 60,
"wires": [
[
"694a8a64a7102298",
"6040d7a27e3c8a63"
]
]
},
{
"id": "199d47520299e2a8",
"type": "debug",
"z": "81d32c34d77268a7",
"name": "pulse data",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 430,
"y": 80,
"wires": []
},
{
"id": "6040d7a27e3c8a63",
"type": "ui_switch",
"z": "81d32c34d77268a7",
"name": "pulse detect switch",
"label": "pulse detect switch",
"tooltip": "",
"group": "13092a19a4c0a3cf",
"order": 1,
"width": 4,
"height": 2,
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"animate": false,
"className": "",
"x": 130,
"y": 160,
"wires": [
[
"694a8a64a7102298"
]
]
},
{
"id": "12ef547ef25315c4",
"type": "ui_chart",
"z": "81d32c34d77268a7",
"name": "",
"group": "13092a19a4c0a3cf",
"order": 5,
"width": 12,
"height": 6,
"label": "pulse data",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "200",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 430,
"y": 200,
"wires": [
[]
]
},
{
"id": "c838025a9b044660",
"type": "ui_text",
"z": "81d32c34d77268a7",
"group": "13092a19a4c0a3cf",
"order": 2,
"width": 8,
"height": 2,
"name": "",
"label": "pulse data",
"format": "{{msg.payload}}",
"layout": "row-left",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 430,
"y": 140,
"wires": []
},
{
"id": "4a1c584026407e08",
"type": "inject",
"z": "81d32c34d77268a7",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 710,
"y": 60,
"wires": [
[
"037a4dbb1cacff51",
"f1f5dbaf13d27450"
]
]
},
{
"id": "c62895d4201c5600",
"type": "debug",
"z": "81d32c34d77268a7",
"name": "oximetry",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1080,
"y": 80,
"wires": []
},
{
"id": "037a4dbb1cacff51",
"type": "ui_switch",
"z": "81d32c34d77268a7",
"name": "Oxygen Detection Switch",
"label": "oximetry detect switch",
"tooltip": "",
"group": "13092a19a4c0a3cf",
"order": 3,
"width": 4,
"height": 2,
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"animate": false,
"className": "",
"x": 700,
"y": 140,
"wires": [
[
"f1f5dbaf13d27450"
]
]
},
{
"id": "5ea0aec9426c55e0",
"type": "ui_chart",
"z": "81d32c34d77268a7",
"name": "",
"group": "13092a19a4c0a3cf",
"order": 6,
"width": 12,
"height": 6,
"label": "oximetry data",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "90",
"ymax": "100",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1100,
"y": 200,
"wires": [
[]
]
},
{
"id": "c099d15a3766a7f9",
"type": "ui_text",
"z": "81d32c34d77268a7",
"group": "13092a19a4c0a3cf",
"order": 4,
"width": 8,
"height": 2,
"name": "",
"label": "oximetry data",
"format": "{{msg.payload}}",
"layout": "row-left",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 1100,
"y": 140,
"wires": []
},
{
"id": "f1f5dbaf13d27450",
"type": "max30102",
"z": "81d32c34d77268a7",
"name": "",
"x": 910,
"y": 140,
"wires": [
[
"c62895d4201c5600",
"c099d15a3766a7f9",
"5ea0aec9426c55e0"
]
]
},
{
"id": "a0f364f8c38154ac",
"type": "ui_level",
"z": "81d32c34d77268a7",
"group": "13092a19a4c0a3cf",
"order": 7,
"width": 24,
"height": 3,
"name": "",
"label": "pulse datect",
"colorHi": "#e60000",
"colorWarn": "#ff9900",
"colorNormal": "#00b33c",
"colorOff": "#595959",
"min": 0,
"max": "200",
"segWarn": "70",
"segHigh": "110",
"unit": "B/M",
"layout": "sh",
"channelA": "",
"channelB": "",
"decimals": 0,
"animations": "rocket",
"shape": "3",
"colorschema": "fixed",
"textoptions": "default",
"colorText": "#eeeeee",
"fontLabel": "",
"fontValue": "",
"fontSmall": "",
"colorFromTheme": true,
"textAnimations": true,
"hideValue": false,
"tickmode": "auto",
"peakmode": false,
"property": "payload",
"peaktime": 3000,
"x": 410,
"y": 260,
"wires": []
},
{
"id": "13092a19a4c0a3cf",
"type": "ui_group",
"name": "medical",
"tab": "de829934348a1330",
"order": 1,
"disp": true,
"width": 24,
"collapse": false,
"className": ""
},
{
"id": "de829934348a1330",
"type": "ui_tab",
"name": "Elecrow for medical",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]