Stand with Ukraine flag
Try it now Pricing
Cloud
Europe
Documentation > Solution Templates > Swimming Pool SCADA system
Getting Started
Devices Library Guides API FAQ
On this page

Swimming Pool SCADA system template

Available since TB Version 3.8.0

SCADA (Supervisory Control And Data Acquisition) is a complex software system designed for the collection, processing, and storage of information in real-time.

Based on ThingsBoard, a Swimming Pool SCADA system template has been implemented. It’s designed to monitor and control swimming pool components. Sensors data in the local network is collected and sent via the Modbus protocol to the IoT Gateway. The Gateway communicates with ThingsBoard through the MQTT protocol, ensuring continuous devices connectivity and data transmission to the SCADA system. ThingsBoard acts as the core of the SCADA system, storing data from devices in a database, processing it, visualizing the information, and sending control commands to the devices.



To understand how the Swimming Pool SCADA system template works, let’s start by installing it.

Install solution template

You will need to have access to ThingsBoard Professional Edition. The easiest way is to use ThingsBoard Cloud server. The alternative option is to install ThingsBoard using installation guide.

  • Navigate to the "Solution templates" page. Locate "Swimming Pool SCADA system" in your solution templates library. Click "Install" to begin the installation process;
  • After installation, the instructions for setting up the solution will open.

Follow the next steps:

- Step 1: Install Docker Compose on your system. Follow the instructions in the official Docker Compose installation guide;

- Step 2: Launch the Modbus Pool Emulator. Execute the provided command to simulate a comprehensive swimming pool system:

1
docker run --rm -d --name tb-modbus-pool-emulator -p 5021-5034:5021-5034 thingsboard/tb-modbus-pool-emulator:latest && docker logs -f tb-modbus-pool-emulator

This command will launch a Modbus pool emulator containing 14 devices, which act as a unified system and communicate through the ModBus protocol.

- Step 3: Launch the IoT Gateway. First, create the docker-compose.yml file with the necessary configurations:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '3.4'
services:
  # ThingsBoard IoT Gateway Service Configuration
  tb-gateway:
    image: thingsboard/tb-gateway:latest
    container_name: tb-gateway
    restart: always

    # Necessary mapping for Linux
    extra_hosts:
      - "host.docker.internal:host-gateway"

    # Environment variables
    environment:
      - host=$YOUR_INSTANCE_HOST
      - port=$YOUR_INSTANCE_PORT
      - accessToken=$ACCESS_TOKEN

where

  • $YOUR_INSTANCE_HOST is a host of your ThingsBoard instance
  • $YOUR_INSTANCE_PORT is a port of your ThingsBoard instance
  • $ACCESS_TOKEN is an access token for the gateway from platform server

ThingsBoard will automatically generate and substitute the necessary values. You only need to copy and save this configuration in the docker-compose.yml file.


Now, run the command below from the folder where you’ve saved the docker-compose.yml file to run the IoT Gateway:

1
docker compose up

We’ll delve into more details on this topic in the Gateway section, where we’ll cover how Gateway operates within the ThingsBoard environment, setting up various devices, and configuring data communications.

We will explore the IoT Gateway in more detail in the “Gateway” section, where we will discuss how the gateway operates within the ThingsBoard environment, devices connectivity, and data transmission configuration.

The IoT Gateway is running. Click “Close” to proceed to the dashboard.

Dashboard

As part of this solution, we have developed a comprehensive Swimming Pool SCADA system dashboard that allows you to visualize, interact with, and control real-time data from multiple devices. The dashboard is designed to display critical information for water management, temperature control, and equipment performance. It allows operators to interact with various system components for real-time control and monitoring from any device.

Key features:

  • Interactive States: Easily navigate the system by clicking on individual devices to access detailed metrics of specific states, streamlining your workflow.

  • Flexible Layouts for Multi-Device Access: Whether you're using a desktop, tablet, or smartphone, the dashboard’s adaptive design ensures seamless operation and accessibility to your pool system anytime, anywhere.

  • Water Quality Management: Keep your pool in optimal condition by monitoring water levels and pH data. The system helps maintain balance and prevents water quality issues.

  • Temperature Control: Use outdoor temperature and pool temperature sensor data for intelligent heat pumps control. The system ensures that the water temperature is maintained efficiently according to predefined targets.

  • Equipment Monitoring: Monitor the performance of pumps, sand filters, and other critical equipment. The dashboard provides insights into rotation speed, vibration, flow rates, power consumption, and more to monitor operational efficiency.

  • Valve Control: Remotely control water flow across different segments of the system by controlling valves. This adds flexibility to the system and enables quick adjustments to water flow as needed. You can interact with the valves directly through the dashboard to turn them on or off as necessary.

  • Energy Management: Track energy usage for heat pumps, filtration systems, and other devices. Use this data to optimize energy efficiency and reduce costs.

  • Remote System Management: Take full control of your swimming pool system from anywhere. Operate pumps, switch between modes, and manage valves remotely.

SCADA systems are divided into two types:

  • High-Performance SCADA systems, which emphasize simplified interfaces, faster decision-making, and improved information perception efficiency.
  • Traditional SCADA systems, which focus on basic monitoring and control.

Choose the SCADA system type that suits you best:

image

Clicking on different devices provides detailed metrics and controls for each component.

The mobile view demonstrates the flexibility of the dashboard, allowing you to manage and monitor the swimming pool SCADA system across different devices, including tablets and smartphones.

image

Clicking on different devices provides detailed metrics and controls for each component.

The mobile view demonstrates the flexibility of the dashboard, allowing you to manage and monitor the swimming pool SCADA system across different devices, including tablets and smartphones.

For further customization of the Swimming Pool SCADA system dashboard refer to the dashboard development guide.

For real-time monitoring of device data received from Modbus servers, you can access the ThingsBoard IoT Gateways dashboard to view the status and data of connected devices.

System components

The SCADA Swimming Pool system includes:

  • 14 operational devices, essential for monitoring and controlling various components of the pool system;
  • An asset that gathers data from its connected devices and stores it as attributes for subsequent monitoring and control of various components within the SCADA system;
  • The gateway transmits data from these devices to ThingsBoard, ensuring seamless device connectivity and data transfer within the SCADA system.

Devices

Choose the SCADA system type:

The system includes the 14 operational devices:

Heat pump

The heat pump controls the pool temperature and operates automatically based on predefined temperature settings. This behavior is managed within the Swimming Pool Device Rule Chain to ensure efficient energy usage and precise temperature regulation. Depending on the temperature readings, the heat pump will automatically:

  • turn off if the pool temperature exceeds the target set on the heat pump, or if the outdoor temperature is above the defined threshold.
  • turn on if both the pool temperature and outdoor temperature fall below their respective target values.


The following settings are available for the heat pump:

  • Turn On/Off heat pump;
  • Changing current temperature;
  • Setting status warnings;
  • Enabling critical state animations;
  • Propeller Speed Adjustment: Adjust the propeller speed depending on the temperature or other device parameters.


Water pump

Manage the circulation of water throughout the pool by turning the pump on or off.


pH filter

Ensure the water pH levels are within optimal ranges by managing the filtration and chemical treatment process. Pressing the pH filter will open the pH filter diagram in a popup window.


Sand filter

Allow for efficient debris removal from the pool. The filter supports multiple functions, including filtration, wasting, backwashing, recirculation and rinsing, all of which can be controlled remotely via the SCADA system.


Water level meter

Measure the water level in the pool, providing critical data to maintain optimal water levels and detect potential leaks.


Valves

Allow for precise control of water flow between different sections of the pool system. Pressing the valve will open or close it.

The system includes the 14 operational devices:

Heat pump

The heat pump controls the pool temperature and operates automatically based on predefined temperature settings. This behavior is managed within the Swimming Pool Device Rule Chain to ensure efficient energy usage and precise temperature regulation. Depending on the temperature readings, the heat pump will automatically:

  • turn off if the pool temperature exceeds the target set on the heat pump, or if the outdoor temperature is above the defined threshold.
  • turn on if both the pool temperature and outdoor temperature fall below their respective target values.


The following settings are available for the heat pump:

  • Turn On/Off heat pump;
  • Changing current temperature;
  • Setting status warnings;
  • Enabling critical state animations;
  • Propeller Speed Adjustment: Adjust the propeller speed depending on the temperature or other device parameters.


Water pump

Manage the circulation of water throughout the pool by turning the pump on or off.


pH filter

Ensure the water pH levels are within optimal ranges by managing the filtration and chemical treatment process. Pressing the pH filter will open the pH filter diagram in a popup window.


Sand filter

Allow for efficient debris removal from the pool. The filter supports multiple functions, including filtration, wasting, backwashing, recirculation and rinsing, all of which can be controlled remotely via the SCADA system.


Water level meter

Measure the water level in the pool, providing critical data to maintain optimal water levels and detect potential leaks.


Valves

Allow for precise control of water flow between different sections of the pool system. Pressing the valve will open or close it.

Asset

The Swimming Pool SCADA system includes a single asset named Swimming Pool SCADA system. This asset serves as the central hub for propagating data from all connected devices. The data collected by the asset is later used to monitor and control various components of the system. Additionally, a script within the rule engine processes this data to calculate the statuses of each pipe, indicating whether water is flowing or not, which is then displayed on the dashboard for real-time monitoring.

Gateway

The ThingsBoard IoT Gateway integrates devices into the SCADA system in ThingsBoard, ensuring seamless connectivity and data transmission. The “Pool System Gateway” gateway configuration is accessible on the “Gateway” page in the “Entities” section.

The Pool System Gateway displays connected devices and their status. Click “Show Device Info” icon next to the device to view detailed information, including its status and relevant metrics.

Connector configuration

Let’s go over the connector settings. Click the “Connectors configuration” button to display available connectors. Click on the “Modbus Gateway” connector to open its configuration settings. Navigate to the “Master Connectors” tab, where you’ll find connection parameters for connecting devices to the Modbus server and data processing settings for each device.

We’ll examine the configuration parameters using the “Main intake valve” device as an example. Click the pencil icon next to the device name to open its settings window.

In this template, we’re using an emulator to simulate devices and their telemetry data. The host host.docker.internal and port 5021 are specific to your Modbus device. If you need to connect actual devices, replace the host and port values with the real ones. A detailed description of other parameters, such as Method, Unit ID, and others, can be found on the Modbus Connector configuration page.

Scroll down to the “Time series” section. Here, you can configure the processing of incoming data. These settings will be interpreted in ThingsBoard as device telemetry data. To open the time series configuration, click the pencil icon. For more details on each parameter and setting in the “Time series” section, refer to the Modbus time series settings documentation.

In the “RPC Requests” section, you can configure parameters for remote procedure calls (RPC) from ThingsBoard to the device. This section is necessary for sending commands and receiving responses from the device. For detailed information on each parameter in “RPC Requests”, refer to the Modbus RPC settings documentation.

Rule chain

The Swimming Pool Device Rule Chain is the core of the Swimming Pool SCADA system, processing telemetry, managing devices, and triggering automated actions. Each message flows through structured nodes that handle telemetry, generate alarms, and control devices. This ensures smooth data flow, real-time monitoring, and timely responses for all connected devices. The data is then visualized on the dashboard, allowing users to interact with and control devices while monitoring system performance in real time.


Message processing flow:

  • Alarm Generation: Every message first passes through the device profile node. This step allows the system to generate alarms based on the conditions defined in the device profiles (such as for the heat pump, water pump, and sand filter). If the telemetry exceeds the set thresholds, alarms are triggered and displayed on the dashboard.
  • Message Type Switch: After the initial profile processing, the message moves to the message type switch node. This node routes messages based on their type, such as telemetry data, attribute updates, or RPC requests. It sends each message down the appropriate path for further processing.
  • General logic – save attributes, time series, and RPC requests: Independent of the message type, several actions occur for all devices.

    • save attributes node: The telemetry data from devices is saved as attributes.
    • save time series node: Time series data is saved for historical analysis and monitoring.
    • rpc call request node: The system can generate and send RPC requests to devices. These RPC commands may turn devices on/off, change operational modes, or control valve positions. For example, valves can be opened/closed, and pumps can be activated/deactivated based on predefined conditions or manual requests.
  • Activity/inactivity events: This part of the rule chain is responsible for monitoring the activity and inactivity of devices. The system catches these events, propagating the device states to the asset. This data is crucial for further calculations and to ensure real-time updates about which devices are active.
  • Device profile filtering: Once the telemetry data is saved, the message is routed through the device profile switch node. This node filters the devices based on their profile, allowing for device-specific actions:

    • Heat pump: When telemetry from the heat pump is detected, the system checks specific conditions—like target temperature, outdoor temperature, and pool temperature—through a switch node. If the telemetry conditions meet the thresholds for turning the heat pump on or off, an RPC request is sent to control the heat pump’s state.

    • Sand filter, Water pump, Water sensor, Valve: For these devices, the message passes through a script node that adds the device name to the necessary telemetry. This step ensures that the telemetry is properly propagated as attributes on the asset for further use.


Main calculation script that determines the conditions for water flow through the pipes:

After the device profile switch node, the message is sent to the script node. The function of this node creates a new message that contains the device name in the modified camelCase format + its telemetry from the incoming message, and returns an object with the updated data. For example, the device name “Water pump outgoing valve”, converted to camelCase, becomes “waterPumpOutgoingValve” + the telemetry key name “opened”, and is recorded as “waterPumpOutgoingValveOpened”.

Next, the change originator node changes the “originator” of the message. This node specifies an asset instead of devices as the message source. In other words, all telemetry goes to the asset and is stored as attributes using the save attributes node.

Next, the originator attributes node requests the specified attributes from the asset and sends them to the main calculation script in the script node. This script is crucial for determining which pipe segments are currently active. The calculation determines whether water should flow through specific pipes based on attribute values and saves this values using the save attributes node.

Variables:

  • filterSegmentFlowing determines whether water flows through the filtration segment. This depends on several conditions, including whether the pump is operating and the valves allowing water to pass through the filter are open.
  • drainSegmentFlowing determines whether water is flowing through the drain segment. This depends on the filtration status and whether the corresponding mode is set on the filter.
  • heatSegmentFlowing determines whether water is flowing through the heating segment. This occurs if the water is being filtered but not drained, and the heating valve is open.
  • phFilterSegmentFlowing determines whether the flow is passing through the pH filtration segment. This depends on the filtration status and whether the corresponding valve is open.
  • fillSegmentFlowing determines whether water is flowing through the filling segment, which is activated when the filling valve for the pool is open and pH filtration is active.

Functions:

  • calculateFilterSegment() evaluates whether water filtration is occurring based on several conditions, such as the opening of valves for the pump, drainage, and the water level.
  • calculatePhFilterSegment() checks whether the water flow is passing through the pH filtration segment depending on the activity of other segments and the valve statuses.

Device profiles

In ThingsBoard, a device profile is a set of configurations and rules that define the behavior of devices using it. Device profiles simplify managing devices with similar parameters. They include a rule chain for processing incoming messages and events, transport configuration, alarm rules, and other parameters. Learn more about the device profile here.

For the “Swimming Pool SCADA system” solution template, six device profiles were created to manage the 14 operational devices. These profiles set a “Swimming Pool Device Rule Chain” as the default rule chain to our devices, the transport configuration is set to default, and define specific alarm rules for them. Such as excessively high water temperature in the pool or exceeding the power consumption of the heat pump, etc.

Alarm rules

The Swimming Pool SCADA system includes alarm configurations for key devices, allowing operators to monitor critical conditions and respond swiftly to potential issues. Alarms are triggered based on predefined thresholds and rules defined in device profiles, helping to maintain the optimal performance of the system.

Device-Specific Alarms

Heat pump: The heat pump has five alarm rules based on the following metrics:

  • Vibration levels
  • Power consumption
  • Rotation speed
  • Refrigerant pressure
  • Compressor temperature


Water pump: The water pump is monitored by four alarm rules based on:

  • Vibration levels
  • Power consumption
  • Rotation speed
  • Temperature

Sand filter: The sand filter is equipped with three alarm rules that track:

  • Vibration levels
  • Rotation speed
  • Pressure


For example, let's take a closer look at the configuration of the “Rotation speed” alarm rule for the heat pump.
This rule has two severity levels:

  • If the value of the “rotationSpeed” key is greater than or equal to 0 and less than 50, and “running” equals 1, an alarm with a severity type of “Warning” will be triggered.
  • If the value of the “rotationSpeed” key is greater than or equal to 200 and “running” equals 1, an alarm with a severity type of “Critical” will be triggered.

A separate rule is defined for clearing the alarm:

  • If the value of the “rotationSpeed” key returns to the range of greater than or equal to 50 and less than 200, the alarm will be automatically cleared.

The widget subscribes to the reminder alarm status field of the device profile it uses. This allows it to receive updates about alarm creation, its type, and severity.

If an alarm rule is executed, a warning icon appears in the bottom left corner of the heat pump. The type of the icon depends on the severity of the alarm, the rules of which are defined in the device profile, as well as the settings of the widget itself.
For example, if a heat pump widget encounters an alarm with a severity type of “Major”, “Minor”, “Warning”, or “Indeterminate”, the widget will be in a “Warning” state, and a yellow triangle will appear next to the widget. If the alarm severity level is “Critical”, the widget will be in a “Critical” state, and a red square will appear next to the widget.

Clicking on the heat pump device, you will access its state, displaying operational data alongside active alarms. The details include rotation speed, power consumption, refrigerant pressure, and more.

Switching to the “Alarms” tab will display all active and cleared alarms in the system, organized by the originating device, and their respective alarm types and severities.

The widget subscribes to the reminder alarm status field of the device profile it uses. This allows it to receive updates about alarm creation, its type, and severity.

If an alarm rule is executed, the propeller will change its color based on the widget settings and the alarm severity type defined in the device profile.
For example, if the heat pump widget detects an alarm with a severity type of “Major”, “Minor”, “Warning” or “Indeterminate”, the widget will switch to the “Warning” state, and the propeller will change its color to yellow. If the alarm severity level is “Critical,” the widget will switch to the “Critical” state, and the propeller will change its color to red and start flashing.

Clicking on the heat pump device, you will access its state, displaying operational data alongside active alarms. The details include rotation speed, power consumption, refrigerant pressure, and more.

Switching to the “Alarms” page will display all active and cleared alarms in the system, organized by the originating device, and their respective alarm types and severities.

The configuration of other alarm rules is similar to the “Rotation speed” rule of the heat pump. Please review them for yourself.

For more about alarms and how to configure them, read here.

Conclusion

The Swimming Pool SCADA template provides a ready-to-use framework for managing swimming pool components. It ensures seamless integration between sensors, and ThingsBoard, allowing real-time data collection, processing, and visualization. This setup not only enhances operational efficiency but also provides a scalable and reliable solution for centralized supervision and control of swimming pool systems.