顯示具有 Remote access 標籤的文章。 顯示所有文章
顯示具有 Remote access 標籤的文章。 顯示所有文章

2023年9月22日 星期五

Raspberry Pi Smart temperature and humidity controller

Purpose:

這個專題以Raspberry Pi為核心配合DHT22溫溼度模組來做智慧溫度濕度控制器. 在Raspberry Pi中用Node-Red為圖形化界面監看與控制, 當溫度或濕度達到設定的臨界值時, 就控制相對應的Relay Port開啟風扇電源或是除濕機的電源.

This Project uses Raspberry Pi as the core and use DHT22 temperature and humidity module to make a smart temperature and humidity controller. Node-Red is used as a graphical interface for monitoring and control in Raspberry Pi. When the temperature or humidity reaches the set critical value, Just control the corresponding Relay Port to turn on the fan power or dehumidifier power.


Fundamental:

Raspberry Pi:

Raspberry Pi is a popular embedded system board that is relatively small in size and easy to use. Its applications range from hobbyist to professional work areas.

Node-RED
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
Node-RED 是 IBM 以 Node.js 為基礎, 開發出來的視覺化 IOT 開發工具, 透過「流程圖」方式的操作,透過 Node-RED 完成許多後端才能做的事情.
Node-RED is a visual IOT development tool developed by IBM based on Node.js. Through the operation of "flow chart", Node-RED can accomplish many things that can only be done in the back end.

DHT22

Digital-output relative humidity & temperature sensor/module

DHT22 output calibrated digital signal. It utilizes exclusive digital-signal-collecting-technique and humidity sensing technology, assuring its reliability and stability.Its sensing elements is connected with 8-bit single-chip computer. Every sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in type of programme in OTP memory, when the sensor is detecting, it will cite coefficient from memory.

Circuit:


Node-Red  [manage palette]:
安裝 [node-red-node-pi-gpio]
安裝 [node-red-dashboard]
安裝 [node-red-contrib-dht-sensor] 
安裝 [ node-rede-contrib-ui-led]
YouTubeDemo:


Project Flow:
[
    {
        "id": "aef41f4e7f9ffcd2",
        "type": "tab",
        "label": "Smart Controller",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c2aa9ab7d944216f",
        "type": "group",
        "z": "aef41f4e7f9ffcd2",
        "name": "Dehumidifier Power",
        "style": {
            "label": true,
            "color": "#0070c0"
        },
        "nodes": [
            "dad906e5056313b7",
            "15d973b809fcf8c5",
            "ab8ca2c6987b9821",
            "0c9d579aa745e441"
        ],
        "x": 634,
        "y": 579,
        "w": 432,
        "h": 162
    },
    {
        "id": "c864c5cb1857aff5",
        "type": "group",
        "z": "aef41f4e7f9ffcd2",
        "name": "Fan Power",
        "style": {
            "label": true,
            "color": "#0070c0"
        },
        "nodes": [
            "c312bc57f817ba13",
            "bd7640195caa6ca9",
            "3295f6dfc16a53aa",
            "ee26765eecfa5105"
        ],
        "x": 734,
        "y": 39,
        "w": 432,
        "h": 162
    },
    {
        "id": "b1ca411cd3db418d",
        "type": "group",
        "z": "aef41f4e7f9ffcd2",
        "name": "DHT22",
        "style": {
            "label": true,
            "color": "#ff3f3f"
        },
        "nodes": [
            "b58557c19cf33861",
            "d8c369caf9c49e2a",
            "734a368317708723",
            "7b53ca8fb09a6ec9",
            "55f04fd31173302d",
            "6e9ff33159e25b5b",
            "7915f1ddd5bac848",
            "3ebed56c0f1d3c49",
            "5a392ccf4706717c",
            "f4664c58d588e0d5"
        ],
        "x": 94,
        "y": 219,
        "w": 812,
        "h": 302
    },
    {
        "id": "dad906e5056313b7",
        "type": "rpi-gpio out",
        "z": "aef41f4e7f9ffcd2",
        "g": "c2aa9ab7d944216f",
        "name": "",
        "pin": "21",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 980,
        "y": 620,
        "wires": []
    },
    {
        "id": "15d973b809fcf8c5",
        "type": "ui_button",
        "z": "aef41f4e7f9ffcd2",
        "g": "c2aa9ab7d944216f",
        "name": "",
        "group": "2104cf7020a0d823",
        "order": 6,
        "width": 3,
        "height": 2,
        "passthru": false,
        "label": "Relay1 ON",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "1",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 730,
        "y": 620,
        "wires": [
            [
                "dad906e5056313b7",
                "ab8ca2c6987b9821"
            ]
        ]
    },
    {
        "id": "ab8ca2c6987b9821",
        "type": "ui_led",
        "z": "aef41f4e7f9ffcd2",
        "g": "c2aa9ab7d944216f",
        "order": 2,
        "group": "2104cf7020a0d823",
        "width": 3,
        "height": 1,
        "label": "",
        "labelPlacement": "left",
        "labelAlignment": "left",
        "colorForValue": [
            {
                "color": "#ff0000",
                "value": "1",
                "valueType": "num"
            },
            {
                "color": "#808080",
                "value": "0",
                "valueType": "num"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showGlow": true,
        "name": "",
        "x": 990,
        "y": 700,
        "wires": []
    },
    {
        "id": "0c9d579aa745e441",
        "type": "ui_button",
        "z": "aef41f4e7f9ffcd2",
        "g": "c2aa9ab7d944216f",
        "name": "",
        "group": "2104cf7020a0d823",
        "order": 7,
        "width": 3,
        "height": 2,
        "passthru": false,
        "label": "Relay1 OFF",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "0",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 730,
        "y": 700,
        "wires": [
            [
                "dad906e5056313b7",
                "ab8ca2c6987b9821"
            ]
        ]
    },
    {
        "id": "b58557c19cf33861",
        "type": "function",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "function 3",
        "func": "var num_h;\nnum_h=Number(msg.payload);\nif(num_h>65)\n{\n    num_h=1;\n}\nelse\n{\n    num_h = 0;\n}\nmsg.payload=num_h;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 480,
        "wires": [
            [
                "dad906e5056313b7",
                "ab8ca2c6987b9821"
            ]
        ]
    },
    {
        "id": "d8c369caf9c49e2a",
        "type": "inject",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 400,
        "wires": [
            [
                "734a368317708723"
            ]
        ]
    },
    {
        "id": "734a368317708723",
        "type": "rpi-dht22",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "topic": "rpi-dht22",
        "dht": 22,
        "pintype": "0",
        "pin": "18",
        "x": 400,
        "y": 400,
        "wires": [
            [
                "7b53ca8fb09a6ec9",
                "55f04fd31173302d"
            ]
        ]
    },
    {
        "id": "7b53ca8fb09a6ec9",
        "type": "function",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "function 1",
        "func": "\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 360,
        "wires": [
            [
                "6e9ff33159e25b5b",
                "7915f1ddd5bac848",
                "f4664c58d588e0d5"
            ]
        ]
    },
    {
        "id": "55f04fd31173302d",
        "type": "function",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "function 2",
        "func": "//var num_h;\n//num_h=Number(msg.humidity);\nmsg.payload=msg.humidity\n//msg.payload=num_h;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 420,
        "wires": [
            [
                "3ebed56c0f1d3c49",
                "5a392ccf4706717c",
                "b58557c19cf33861"
            ]
        ]
    },
    {
        "id": "6e9ff33159e25b5b",
        "type": "ui_gauge",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "group": "0e2b7585a755f9de",
        "order": 1,
        "width": 5,
        "height": 4,
        "gtype": "gage",
        "title": "Temperature",
        "label": "C",
        "format": "{{value}}",
        "min": "15",
        "max": "50",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 810,
        "y": 320,
        "wires": []
    },
    {
        "id": "7915f1ddd5bac848",
        "type": "ui_chart",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "group": "0e2b7585a755f9de",
        "order": 2,
        "width": 5,
        "height": 4,
        "label": "Temperature",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "15",
        "ymax": "50",
        "removeOlder": "30",
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 810,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "3ebed56c0f1d3c49",
        "type": "ui_gauge",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "group": "0e2b7585a755f9de",
        "order": 7,
        "width": 5,
        "height": 4,
        "gtype": "gage",
        "title": "Humidity",
        "label": "%",
        "format": "{{value}}",
        "min": "30",
        "max": "90",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 800,
        "y": 400,
        "wires": []
    },
    {
        "id": "5a392ccf4706717c",
        "type": "ui_chart",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "",
        "group": "0e2b7585a755f9de",
        "order": 8,
        "width": 5,
        "height": 4,
        "label": "Humidity",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "30",
        "ymax": "90",
        "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": 800,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "c312bc57f817ba13",
        "type": "rpi-gpio out",
        "z": "aef41f4e7f9ffcd2",
        "g": "c864c5cb1857aff5",
        "name": "",
        "pin": "16",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1080,
        "y": 80,
        "wires": []
    },
    {
        "id": "bd7640195caa6ca9",
        "type": "ui_button",
        "z": "aef41f4e7f9ffcd2",
        "g": "c864c5cb1857aff5",
        "name": "",
        "group": "2104cf7020a0d823",
        "order": 8,
        "width": 3,
        "height": 2,
        "passthru": false,
        "label": "Relay2 ON",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "1",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 830,
        "y": 80,
        "wires": [
            [
                "c312bc57f817ba13",
                "3295f6dfc16a53aa"
            ]
        ]
    },
    {
        "id": "3295f6dfc16a53aa",
        "type": "ui_led",
        "z": "aef41f4e7f9ffcd2",
        "g": "c864c5cb1857aff5",
        "order": 4,
        "group": "2104cf7020a0d823",
        "width": 3,
        "height": 1,
        "label": "",
        "labelPlacement": "left",
        "labelAlignment": "left",
        "colorForValue": [
            {
                "color": "#ff0000",
                "value": "1",
                "valueType": "num"
            },
            {
                "color": "#808080",
                "value": "0",
                "valueType": "num"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showGlow": true,
        "name": "",
        "x": 1090,
        "y": 160,
        "wires": []
    },
    {
        "id": "ee26765eecfa5105",
        "type": "ui_button",
        "z": "aef41f4e7f9ffcd2",
        "g": "c864c5cb1857aff5",
        "name": "",
        "group": "2104cf7020a0d823",
        "order": 9,
        "width": 3,
        "height": 2,
        "passthru": false,
        "label": "Relay2 OFF",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "0",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 830,
        "y": 160,
        "wires": [
            [
                "c312bc57f817ba13",
                "3295f6dfc16a53aa"
            ]
        ]
    },
    {
        "id": "f4664c58d588e0d5",
        "type": "function",
        "z": "aef41f4e7f9ffcd2",
        "g": "b1ca411cd3db418d",
        "name": "function 4",
        "func": "var num_t;\nnum_t=Number(msg.payload);\nif(num_t>26)\n{\n    num_t=1;\n}\nelse\n{\n    num_t = 0;\n}\nmsg.payload=num_t;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 260,
        "wires": [
            [
                "3295f6dfc16a53aa",
                "c312bc57f817ba13"
            ]
        ]
    },
    {
        "id": "046f084a03bdabc2",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 3,
        "width": 1,
        "height": 1
    },
    {
        "id": "56fc7974bf0df6d5",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 4,
        "width": 1,
        "height": 1
    },
    {
        "id": "d2f0e79dd5618e5f",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 5,
        "width": 1,
        "height": 1
    },
    {
        "id": "7114d12cc24c98d3",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 6,
        "width": 1,
        "height": 1
    },
    {
        "id": "dc633da99afabc3c",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 9,
        "width": 1,
        "height": 1
    },
    {
        "id": "4f778b6229bc3367",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 10,
        "width": 1,
        "height": 1
    },
    {
        "id": "230e208a37857a0e",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 11,
        "width": 1,
        "height": 1
    },
    {
        "id": "095e70cc3213bfde",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "0e2b7585a755f9de",
        "order": 12,
        "width": 1,
        "height": 1
    },
    {
        "id": "e0fd59ec6ed4609c",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "2104cf7020a0d823",
        "order": 1,
        "width": 1,
        "height": 1
    },
    {
        "id": "c526f957ab3b1226",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "2104cf7020a0d823",
        "order": 3,
        "width": 3,
        "height": 1
    },
    {
        "id": "fbc05b659121e403",
        "type": "ui_spacer",
        "z": "aef41f4e7f9ffcd2",
        "name": "spacer",
        "group": "2104cf7020a0d823",
        "order": 5,
        "width": 2,
        "height": 1
    },
    {
        "id": "2104cf7020a0d823",
        "type": "ui_group",
        "name": "Power Relay",
        "tab": "e0180b1b272f835d",
        "order": 2,
        "disp": true,
        "width": 12,
        "collapse": false,
        "className": ""
    },
    {
        "id": "0e2b7585a755f9de",
        "type": "ui_group",
        "name": "DHT22",
        "tab": "e0180b1b272f835d",
        "order": 1,
        "disp": true,
        "width": 11,
        "collapse": false,
        "className": ""
    },
    {
        "id": "e0180b1b272f835d",
        "type": "ui_tab",
        "name": "Raspberry",
        "icon": "dashboard",
        "order": 6,
        "disabled": false,
        "hidden": false
    }
]

2023年9月19日 星期二

Reinstall my Raspberry Pi4 Notes

因為在我的raspberry Pi3 跟 Pi4在Node-Red安裝TensorFlow都有問題. 找不出原因但共同點是64bit的系統. 所以就在Pi4上安裝Recommended 32-bit OS, 系統起來後安裝TensorFlow結果是可行的!

Because I have problems installing TensorFlow on Node-Red on my raspberry Pi3 and Pi4. I can’t find the reason but the common point is that they are 64bit systems. So I installed the Recommended 32-bit OS on Pi4. After the system is up, it turns out that it is feasible to install TensorFlow.

我的Raspberry Pi4 and Node-Red的安裝步驟

Installation steps for my Raspberry Pi4 and Node-Red

Raspberry Pi4

1. use raspberry pi imager choose Recommended 32-bit OS

2. write image to your SD card

Node-red in Pi4

1. follow https://nodered.org/docs/getting-started/raspberrypi steps

2. sudo apt install build-essential git curl

3. bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Node-red manage palette install for video application

1. node-red-dashboard

2. node-red-contrib-tensorflow


3. node-red-contrib-browser-utils

4. node-red-contrib-image-output

5. node-red-contrib-image-tools

6. node-red-contrib-multipart-stream-decoder

7. node-red-contrib-multipart-stream-encoder

8. node-red-contrib-teachable-machine

9. node-red-node-ui-webcam 

2023年8月24日 星期四

Raspberry Pi self-hosted ftp server and SSH remote access

Purpose:

This Project 利用Raspberry Pi 建構一個自己的FTP server, 並利用cpolar穿網intranet penetration cloud service在任何有網路的地方用電腦或手機去存取想要的資料. 也可Access and control your Raspberry Pi remotely via SSH and AnyDesk.

This Project use Raspberry Pi to build your own FTP server, and use cpolar intranet penetration cloud service to access the desired data with your computer or mobile phone anywhere there is a network. You can also Access and control your Raspberry Pi remotely via SSH and AnyDesk.

Fundamental:

Raspberry Pi:

Raspberry Pi is a popular embedded system board that is relatively small in size and easy to use. Its applications range from hobbyist to professional work areas.
FTP:

FTP (File Transfer Protocol) FTP server is computer software consisting of one or more programs that can execute commands given by remote client(s) such as receiving, sending, deleting files, creating or removing directories, etc. The software may run as a software component of a program, as a standalone program or even as one or more processes (in the background).

FileZilla Client:
The FileZilla Client not only supports FTP, but also FTP over TLS (FTPS) and SFTP. It is open source software distributed free of charge under the terms of the GNU General Public License.

AnyDesk:


AnyDesk 是一套功能強大的免費遠端遙控軟體,操作方式與 TeamViewer 差不多,但是連線速度更快,可以輕鬆突破防火牆的限制,執行程式後會得到一組電腦的ID,只要有被遙控端的ID,連線後等待對方同意就可以開始遠瑞控制。
AnyDesk is a set of powerful free remote control software. The operation method is similar to TeamViewer, but the connection speed is faster, and it can easily break through the firewall restrictions. After executing the program, you will get a set of computer IDs. As long as you have the ID of the remote terminal , After connecting, wait for the other party to agree to start remote control.

coplar:

cpolar is a secure intranet penetration cloud service, which exposes the local server under the intranet to the public network through a secure tunnel. This enables public network users to access intranet services normally.

Intranet penetration, simply put, means that the data of the intranet can be obtained by the external network and can be mapped to the public network, so that the data of the intranet can be accessed on the public network.
Installing the Cpolar on Raspberry Pi:
1. curl -sL https://git.io/cpolar | sudo bash 
or 
2. sudo wget https://www.cpolar.com/static/downloads/cpolar-stable-linux-arm.zip
3. sudo unzip cpolar-stable-linux-arm.zip
4. ./cpolar version
5. https://dashboard.cpolar.com/signup to register
6. ./cpolar authtoken xxxxxxxxxxxxxxxxxx
7. ./cpolar ssh 22

SSH:

The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.

PuTTY:

PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform. PuTTY is open source software that is available with source code and is developed and supported by a group of volunteers.



YouTubeDemo: