๐Ÿ“–
Code and Compile Wiki
E-Learning SchoolYouTubeLinkedIn
  • Code and Compile Wiki
  • ๐ŸŒŽQuick Links
    • ๐Ÿ“ƒGitHub
    • ๐Ÿ‘ฉโ€๐Ÿ’ปLinkedIn
    • ๐Ÿ“ธInstagram
    • ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘งFacebook Group
  • ๐ŸขThe Company
    • ๐Ÿ’ฅVision and Values
    • ๐Ÿ˜ŽMeet the Creator!
    • ๐Ÿ’ธDiscount: 20% OFF
  • ๐ŸญFactory Automation
    • Industrial Control
    • Digital Twin
      • FACTORY IO
        • Tasks and Solutions
        • FACTORY IO Scene
      • Simumatik
        • 01: Introduction to Simumatik
        • 02: Conveyor ON-OFF control
        • 03: Conveyor direction control
        • 04: Motor Control with Codesys
        • 05: Electro-Pneumatics with S7-1200 PLC
        • 06: Control IoT Device with MQTT
        • ๐Ÿ“šResources
    • PLC
      • Allen Bradley
        • Micro850 PLC
          • PLC Exercises - Part 1
          • PLC Exercises - Part 2
        • Micrologix 1000 PLC
        • Micrologix 1400 PLC
      • Delta Electronics
        • DVP 14SS2
        • DVP 12SE
        • DVP 10SX
        • PLC Exercises 1
      • Omron
      • PLCnext
      • Siemens
        • S7-200
        • S7-1200 (Basic)
          • ๐Ÿ“™Course Presentations
          • ๐Ÿ“„TIA Projects
        • S7-1200 (Advanced)
          • ๐Ÿ“™Course Presentation and Projects
          • ๐Ÿ“™HMI Presentations and Projects
      • Codesys
        • Exercises - Part 1
      • WAGO CC100
      • Schneider
        • PLC Exercises
    • Safety Controller
      • Banner SC10 Series
        • 1: Introduction to Safety Controller SC10
        • 2: Interfacing SC10 controller with PC
        • 3: Programming SC10 controller
        • 4: RF door switch safety circuit
        • 5: E-Stop safety circuit
        • 6: E-Stop safety circuit with ext. Reset
        • 7: Indicating fault on Manual reset button
        • 8: Interfacing S7-1200 PLC with SC10
        • 9: Reading virtual Non-safety inputs via PROFINET
        • 10: Bypassing the Magnetic switch via PROFINET
        • 11: Monitoring safety signals on Node-RED Dashboard
        • ๐Ÿ“šResources
    • AC Drives
      • Allen Bradley
        • PowerFlex 400
      • Delta Electronics
        • VFD M-Series
        • Servo Drives ASDA-B Series
    • HMI
      • Weintek
      • Delta HMI
      • Siemens KTP400
        • Error 1: Missing Panel images
    • 3D Camera
    • SCADA
      • Ignition SCADA
  • ๐ŸŒŽIIoT
    • Introduction to IIoT
      • Importance of Unified namespace
    • IIoT Devices
      • Arduino
      • ctrlX CORE
        • ๐Ÿ“น01- Using ctrlX CORE as PLC and Node-RED Server
        • ๐Ÿ“น02- Using ctrlX CORE as MQTT Broker
        • ๐Ÿ“น03- Interfacing ctrlX CORE with ctrlX I/O via EtherCAT
        • ๐Ÿ“น04- Introducing ctrlX CORE IDE App
        • ๐Ÿ“น05- Connecting OT with IT using Bosch DeviceBridge app
        • ๐Ÿ“น06- Interfacing ctrlX CORE with IO-Link master using EtherCAT
        • ๐Ÿ“น07- ctrlX CORE as HMI- Part 1
        • ๐Ÿ“น08- ctrlX CORE as HMI- Part 2
        • ๐Ÿ”—Virtual ctrlX WORKS
      • Raspberry Pi
      • Revolution Pi
      • Weintek cMT-G01
      • Banner Snap Signal
    • IIoT Tools
      • SIGNL4
      • Node-RED
        • Tips
      • OPC UA
        • ๐Ÿ–ฅ๏ธOPC UA Course
        • ๐Ÿ’กTroubleshooting
          • ๐Ÿ“ƒCertificate error in Node-RED
      • MySQL
      • MQTT
      • IO-Link
        • SICK
  • ๐Ÿ‘จโ€๐Ÿ”ฌResources
    • Yearly Subscription Guideline
    • Based on Courses
    • Books and Guides
    • Computer configuration
    • Hardware and Software
    • ๐Ÿ“‘Articles
      • ๐Ÿ‘จโ€๐Ÿ’ปModbus Addressing
  • โš™๏ธProjects
    • SmartFactory
Powered by GitBook
On this page
  • 1.0 How to format the timestamps
  • 1.1 Bits-wise operation
  • 1.2 Safe mode
  • 1.3 Template code for the Table in Node-RED

Was this helpful?

  1. IIoT
  2. IIoT Tools
  3. Node-RED

Tips

In this page you will find several tips related to Node-RED

PreviousNode-REDNextOPC UA

Last updated 1 year ago

Was this helpful?

1.0 How to format the timestamps

Sometimes you need to use the timestamps in your Node-RED project. You can use the timestamp node to extract the timestamp like below:

Source code
[
    {
        "id": "3c9e9659a9a48e65",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "82ae8f7a87f62c48",
        "type": "inject",
        "z": "3c9e9659a9a48e65",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 80,
        "wires": [
            [
                "6e27c4f9b4be2f8f"
            ]
        ]
    },
    {
        "id": "853dbe45d82473a8",
        "type": "debug",
        "z": "3c9e9659a9a48e65",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 80,
        "wires": []
    },
    {
        "id": "6e27c4f9b4be2f8f",
        "type": "change",
        "z": "3c9e9659a9a48e65",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$now()",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 80,
        "wires": [
            [
                "71738532703c5a2c"
            ]
        ]
    },
    {
        "id": "71738532703c5a2c",
        "type": "function",
        "z": "3c9e9659a9a48e65",
        "name": "Optimizing String",
        "func": "msg.payload = msg.payload.substr(0, 10) + \" \" + msg.payload.substr(12, 7);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 590,
        "y": 80,
        "wires": [
            [
                "853dbe45d82473a8"
            ]
        ]
    }
]

1.1 Bits-wise operation

1.2 Safe mode

Many a time your flow caused your Node-RED to crash. And when you restart your Node-RED, it crashes again and makes it difficult for you to troubleshoot the flow. In this situation, you can use the safe mode of Node-RED where Node-RED will not start right after initializing the server. This allows you to edit the faulty nodes and deploy them again. This will save you hours of troubleshooting.

Just open the command prompt and type node-red --safe

1.3 Template code for the Table in Node-RED

<style>
    #history {
      font-family: "Arial";
        border-collapse: collapse;
        width: 100%;
        }
        
        #history td, #history th {
        border: 1px solid #ddd;
        padding: 8px;
        }
        #history tr:nth-child(even){background-color: #A8EEF8;}
        
        #history tr:hover {background-color: #40aeea;}
        
        #history th {
        padding-top: 12px;
        padding-bottom: 12px;
        text-align: center;
        background-color: #696969;
        color: white;
        }
        </style>
        
        <table id="history" border="1">
            <tr align="center">
                 <th>Timestamp</th>
                 <th>Tank 1 Value in cm</th>
                 <th>Tank 1 Value in %</th>
                 <th>Tank 2 Value in cm</th>
                 <th>Tank 2 Value in %</th>
            </tr>
                <tbody>
                    <tr align="center" ng-repeat="row in msg.payload">
                        <td ng-repeat="item in row" >{{item}}</td>
                        </tr>
                        </tbody>
                        </table>

๐ŸŒŽ
50 Lines of Code: Bits and bytes in JavaScript
Node-RED flow
Command promt view