Create Stopwatch and Countdown Timers in Node-RED (2026)

Implement stopwatch and countdown timers for industrial automation and process control applications

Sumit Shinde
Back to Blog Posts
Image with logo and the slogan: Elevate Node-RED with Flowfuse

Timers are everywhere in industrial automation. You need them to track how long a machine has been running, measure downtime, schedule maintenance, or coordinate processes that happen in sequence.

Through my work as a technical writer covering IIoT, building industrial applications, and being part of a company where our customers deploy real-world automation systems, I've observed that timers are ubiquitous in production environments. Whether it's a production floor display showing machine runtime, a maintenance terminal counting down to the next service window, or an operator interface tracking downtime by reason code—timers are foundational to industrial visibility. Here's an example of a performance operator terminal with timer functionality:

Performance Operator Terminal Performance operator terminal displaying real-time production metrics with timer functionality

If you want to explore this interface yourself, you can deploy this blueprint to your FlowFuse instance and start experimenting immediately.

In this article, we'll build two types of timers in Node-RED: stopwatches that measure elapsed time and countdowns that trigger actions after a set duration. Both are straightforward to implement and essential for most automation projects.

Prerequisites

Before following this tutorial, you should have:

  • A running Node-RED instance. For professional development and production deployments, FlowFuse is the recommended platform. If you don’t have an account, start your free trial today.

FlowFuse provides enterprise-grade Node-RED hosting with managed infrastructure, built-in DevOps tools, MQTT broker, database, team collaboration with granular access control, and seamless scaling capabilities. Whether you need cloud-hosted instances managed by FlowFuse or remote instances running on your edge devices, the platform provides unified management for both. FlowFuse also includes AI-powered features that accelerate flow development and streamline automation projects. From prototyping to mission-critical production deployments, FlowFuse handles the infrastructure complexity so you can focus on building flows.

That's all you need to get started.

Getting Started

We'll use two Node-RED community nodes for this tutorial: node-red-contrib-hourglass for stopwatch timers and node-red-contrib-countdown for countdown timers. Both are simple to configure and work reliably in production environments.

Let's start with installing and building a stopwatch.

Installing the Hourglass Node

First, install the hourglass node in your Node-RED instance:

  1. Open the Node-RED editor
  2. Click the hamburger menu (top right) and select "Manage palette"
  3. Go to the "Install" tab
  4. Search for node-red-contrib-hourglass
  5. Click "Install"

The hourglass node will appear in your palette under the function category.

Understanding Hourglass Commands

The hourglass node responds to control commands sent via msg.command. The available commands are:

  • start - Begins timing operation
  • stop - Stops the timer and outputs elapsed time
  • pause - Pauses timing without resetting
  • reset - Clears timer state and stops operation
  • status - Outputs current timer state without stopping

These commands control timer behavior.

Implementing a Stopwatch Timer

Build a basic stopwatch flow:

  1. Drag four inject nodes onto the canvas
  2. Add four change nodes, one after each inject node, and connect them
  3. Configure the change nodes to set msg.command:
    • First change node: set to "start"
    • Second change node: set to "status"
    • Third change node: set to "stop"
    • Fourth change node: set to "reset"
  4. Drag an hourglass node onto the canvas
  5. Connect all four change nodes to the hourglass node input
  6. Add a debug node and connect it to the hourglass node output
  7. Deploy the flow

When you trigger the first inject node, the stopwatch starts. The second inject node checks current elapsed time without stopping the timer—you can configure this inject node to repeat at intervals for continuous time monitoring. The third inject node stops the stopwatch and outputs the total elapsed time. The fourth inject node resets the stopwatch back to zero.

The node outputs a message containing timing information:

Hourglass node output message showing elapsed time in multiple formats Hourglass node output message showing elapsed time in multiple formats

The elapsed object provides multiple formats: a human-readable string, total milliseconds, and broken-down time components. This flexibility supports different display requirements and calculation needs.

This basic example demonstrates the pattern. In production applications, replace the inject nodes with actual process triggers—machine status signals from PLCs or MQTT messages from sensors. The hourglass node output then connects to databases for logging, dashboards for visualization, or notification systems for alerts when thresholds are exceeded.

Below is the complete flow.

Implementing a Countdown Timer

Countdown timers trigger actions after a specified duration. Common applications include scheduled maintenance windows, batch process timeouts, and timed equipment shutdowns.

To implement a countdown, we will use node-red-contrib-countdown.

Installing the Countdown Node

Install the countdown node in your Node-RED instance:

  1. Open the Node-RED editor
  2. Click the hamburger menu (top right) and select "Manage palette"
  3. Go to the "Install" tab
  4. Search for node-red-contrib-countdown
  5. Click "Install"

The countdown node will appear in your palette.

Building a Countdown Timer

Create a countdown timer flow in Node-RED:

  1. Drag an Inject node onto the canvas.

  2. Add a Change node and configure it to:

    • Set msg.payload to the countdown duration in seconds (for example, 50 for 50 seconds).
    • Set msg.topic to "control".
    • You can configure the countdown duration either in the Change node or directly in the Inject node, as long as msg.payload is in milliseconds and msg.topic is "control".
  3. Drag a Countdown node onto the canvas and configure it with the following settings:

    • Timer On payload: The message payload sent when the countdown starts (for example, true).
    • Timer Off payload: The message payload sent when the countdown completes (for example, false).
    • Restart countdown if message is received while running: Enable this to restart the countdown if a new control message is received.
    • Send output message on Reset: Enable this to send a message when the countdown is reset.
    • Set time to new duration if control message is received while running: Enable this to update the countdown duration while it is running.
    • Start countdown if control message is received while not running: Enable this to start the countdown using a control message, enable it for this example to allow starting countdown when control message recived
  4. Connect the Change node to the Countdown node.

  5. Add a Debug node and connect it to the Countdown node output.

  6. Click Deploy to activate the flow.

When you trigger the Inject node, the countdown starts. The Countdown node outputs messages at regular intervals, and the second output shows the remaining time.

Countdown node output showing remaining time updates Countdown node output showing remaining time updates

From the first output, it will send the message you configured at the start of the count and at the end of the countdown.

Below is the flow implementation that you can use as a starting point.

For this demonstration, we used an inject node to manually trigger the countdown. In production environments, you would replace this with actual process triggers—equipment status signals from PLCs, MQTT messages from sensors, or completion signals from upstream operations. For example, you might start a maintenance window countdown when equipment reaches a scheduled service interval, or initiate a cleanup cycle timer when a batch process completes.

While these examples cover the essential timer operations, both nodes offer additional configuration options. For comprehensive documentation, visit the node-red-contrib-hourglass and node-red-contrib-countdown pages on the Node-RED flows library.

Conclusion

That's it, you now have working stopwatch and countdown timers in Node-RED. The hourglass node tracks elapsed time, and the countdown node triggers actions after a set duration.

These implementations are ready for production use. Start with these basic patterns, test them in your environment, and expand as needed. Connect them to your PLCs, add dashboard displays, or integrate with your existing automation workflows.

Both nodes are actively maintained and used in real industrial systems, so you're building on proven foundations.

About the Author

Sumit Shinde

Technical Writer

Sumit is a Technical Writer at FlowFuse who helps engineers adopt Node-RED for industrial automation projects. He has authored over 100 articles covering industrial protocols (OPC UA, MQTT, Modbus), Unified Namespace architectures, and practical manufacturing solutions. Through his writing, he makes complex industrial concepts accessible, helping teams connect legacy equipment, build real-time dashboards, and implement Industry 4.0 strategies.