Termperature measurement, switch LED at 27°C degree, Node-RED Dashboard

Show the world your Revolution Pi project!
Post Reply
User avatar
dirk
Posts: 2271
Joined: 15 Dec 2016, 13:19

Termperature measurement, switch LED at 27°C degree, Node-RED Dashboard

Post by dirk »

Hello everyone, I was thinking of measuring the temperature and then switching on a warning LED from 27 °C onwards - here the Result:
The green LED is toggled with each control cycle. The yellow LED indicates that 27°C has been exceeded. The whole thing is controlled with a Python script and run by the RevPi Commander. Also, I have included a visualization with Node-RED.

Hardware
1. PT100 4-Wire-Sensor
2. 24V-LED
3. RevPi Connect 5 Module
4. RevPi AIO Module
5. RevPi DIO Module
Test Setup Hardware
Test Setup Hardware
PiCtory Configuration
PiCtory Configuration
PiCtory Configuration
Part 1 - The RevPi AIO Configuration
Part 2 - the RevPi DIO Configuration

Python Code

Code: Select all

import revpimodio2
import time

rpi=revpimodio2.RevPiModIO(autorefresh=True)

while True:
    if rpi.io.Temperature.value > 270:
        rpi.io.Yellow.value = 1
    else:
        rpi.io.Yellow.value = 0
    rpi.io.Green.value = not rpi.io.Green.value
    time.sleep(0.5)
RevPi Commander
RevPi Commander
RevPi Commander
Node-RED Flow

Node-RED Flow
Node-RED Flow
I've installed the Node-RED Dashboard plugin

Code: Select all

[
    {
        "id": "4b9bf61949bae800",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f6e50dc613a1a36c",
        "type": "revpi-single-input",
        "z": "4b9bf61949bae800",
        "server": "9cb6436022ade0d1",
        "inputpin": "Temperature",
        "topic": "",
        "x": 160,
        "y": 180,
        "wires": [
            [
                "2fb8db139b716928",
                "a30ee54856c3796b"
            ]
        ]
    },
    {
        "id": "2fb8db139b716928",
        "type": "ui_chart",
        "z": "4b9bf61949bae800",
        "name": "",
        "group": "d6fc59d34b020121",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "Temperature",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "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": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "a30ee54856c3796b",
        "type": "ui_gauge",
        "z": "4b9bf61949bae800",
        "name": "",
        "group": "d6fc59d34b020121",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Temperature",
        "label": "°C",
        "format": "{{value/10}}",
        "min": 0,
        "max": "400",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "270",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 430,
        "y": 220,
        "wires": []
    },
    {
        "id": "9cb6436022ade0d1",
        "type": "revpi-server",
        "host": "localhost",
        "port": "8000",
        "user": "",
        "password": "",
        "rejectUnauthorized": false,
        "ca": ""
    },
    {
        "id": "d6fc59d34b020121",
        "type": "ui_group",
        "name": "Standard",
        "tab": "867f447a9ee24c5c",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "867f447a9ee24c5c",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
Post Reply