OpenPLC Water Reserve Control

OpenPLC Water Reserve Control

Introduction

This tutorial explains how to implement an automatic water reserve control system using a NEXTuino and OpenPLC. The system monitors water levels in a cistern and an elevated tank, controlling a pump that transfers water between them. Manual pump control via start/stop buttons is also supported.

Prerequisites

  • OpenPLC software installed
  • A NEXTuino (any model)
  • Water level sensors: minimum level for cistern, minimum and maximum levels for the elevated tank
  • Two push buttons for manual control (Start and Stop)
  • Basic knowledge of ladder logic programming

Step 1: Install and Set Up OpenPLC

  1. Download OpenPLC from the OpenPLC official website and install it.
  2. Open the OpenPLC Editor.
  3. Configure your NEXTuino model in Settings > Device.
  4. Assign the correct COM port.

OpenPLC examples for NEXTuino: GitHub repository

Step 2: Configure System Inputs and Outputs

NameTypeDescriptionPin
Pool_Low_Level_SensorBOOLMinimum water level in cistern%IX0.0
Tank_High_Level_SensorBOOLMaximum water level in tank%IX0.1
Tank_Low_Level_SensorBOOLMinimum water level in tank%IX0.2
Automatic_Manual_SwitchBOOLAutomatic / manual mode selector%IX0.3
Stop_ButtonBOOLManual pump stop%IX0.4
Start_ButtonBOOLManual pump start%IX0.5
Water_PumpBOOLWater pump output%QX0.0

Step 3: Program the Ladder Logic

Download the OpenPLC project from GitHub:
water_control

Automatic Mode

The pump (Water_Pump) activates when:

  • The cistern is above its minimum level (Pool_Low_Level_Sensor is active)
  • The tank is below its minimum level (Tank_Low_Level_Sensor is active)

The pump deactivates when:

  • The tank reaches its maximum level (Tank_High_Level_Sensor is active)
  • The cistern falls below its minimum level (Pool_Low_Level_Sensor is inactive)

Manual Mode

  • Start_Button activates the pump manually
  • Stop_Button deactivates the pump manually
  • Automatic_Manual_Switch must be in manual mode to enable button control

Mode Switching

The Automatic_Manual_Switch toggles between automatic and manual modes. In manual mode, sensor readings do not affect pump operation.

Step 4: Connect the Hardware

  • Level sensors → respective input pins (DI0, DI1, DI2)
  • Mode switch → DI3
  • Stop button → DI4
  • Start button → DI5
  • Water pump → DO0 (%QX0.0)

Step 5: Test the System

  1. Upload the program to the NEXTuino via OpenPLC Editor.
  2. Test automatic mode: Ensure cistern is above minimum, lower the tank below minimum, and observe the pump activate and fill the tank to maximum.
  3. Test manual mode: Switch to manual mode, use the Start and Stop buttons to control the pump.

Troubleshooting

  • Verify sensors and buttons are connected to the correct input pins.
  • Check that variable names in OpenPLC match the physical connections.
  • Use OpenPLC debugging tools to monitor input, output, and signal states.