Skip to content

Example 2 Health Monitoring

Hardware Preparation


Pi Terminal Blood Oxygen Detection Crowtail-Pulse Sensor
pi-terminal MAX30102 crowtail-pulse-sensor
BUYNOW BUYNOW BUYNOW

Pin Connection


Pi Terminal Blood Oxygen Detection Crowtail-Pulse Sensor
VCC VCC VCC
ADC+ SIG
- NC
GND GND GND
SDA1 SDA
SCL1 SCL

e2-connection

  • 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

mosquitto-1

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.

mosquitto-2

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

mosquitto-4

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

  1. Firstly, let's establish a process for detecting pulse. Drag and drop the pulse nodepulse-node first.

  2. At the upstream node of the pulse node, we define a switch nodeswitch-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
    pulse-detect-switch pulse-detect-switch-3 pulse-detect-switch-2
    • 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.

      create-ui

  3. 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.

    pulse-sw-connect

  4. Next we need to connect a debug nodedebug for pulse data output. (Name the node as "pulse date" by change "Label")

  5. Then we need a chart nodechart to show the pulse date in a recent hour. Drag the chart node in to dashboard, and double click it for configuration.

    set-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
  6. Connect the pulse data chart node to the pulse node.

  7. We can also use other type of chart to show the data. We have chosen the Level nodelevel here, which can display data in real-time like a bar chart.

    pulse-level

    • Select "[Elecrow for medical]medical" for the "Group"
    • Fill in "pulse date" for the "Label"
    • Other items can be set according to your preferences
  8. We now have a completed process for pulse detection.

    pulse-detect-process

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

max-sw

text node

text-max

chart node

chart-max

After completing the above configuration, the complete flowchart is as follows

flow

Enter the URL: 127.0.0.1 in the browser to access the corresponding ui panel.

ui

Expand: How to import JSON files

Open the NodeRed, click the menu,and select Import.

import1

Then click "select a file to import" in the import section and choose the corresponding JSON file to import.

import2

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
    }
]