When it comes to industrial applications, flexibility is as important as capability. There’s a treasure trove of data that can be used to power industrial automation—if you have the right hardware for the task.
In this article, we’ll explore five powerful ways to program logic on a ControlByWeb® controller, including practical examples using our firmware. Read on to learn how you can expand your data capture capabilities.
1. Conditional Logic
Conditional logic allows you to create automated events based on specific conditions. This is particularly useful for applications where actions need to be taken based on sensor readings or other inputs. For example, you can set up a ControlByWeb module to monitor the level of a water tank and control a pump accordingly.
Example: Tank Level Control
Using the X-412™ analog input controller, you can create conditional tasks to manage a water pump. First, connect your tank level sensor to the X-412 and access the device’s firmware via its IP address. Navigate to the “Control/Logic” tab and click “Add Conditional Task +.” Here, you can create tasks such as:
- Turn the pump off when the tank level is at or above 80%.
- Turn the pump on when the tank level falls below 50%.
In the “IF” section, set the condition to “Tank Level” analog input value “Equal to or Greater Than” 80%. This ensures the pump turns off when the tank is sufficiently full. Read our Programming the No-Code IoT Controller article for more details of this example.
2. Scheduled Logic
Scheduled logic is ideal for tasks that need to occur at specific times or set intervals. This can include turning lights on and off, activating alarms, or performing routine maintenance tasks.
Example: Scheduled Lighting Control
With the X-410™ edge-programmable controller, you can set up a scheduled task to control lighting. Access the “Control/Logic” tab and click “Add Scheduled Task.” Set the start time to 8:00 a.m. and the end time to 5:00 p.m. and configure the task to repeat daily. This setup ensures that the lights turn on in the morning and off in the evening, providing automated lighting control for your facility.
For exterior night lighting, logic can be used to set a start time for 30 minutes before sunset with an end time at 1:00 a.m. Then, another scheduled task could be used to turn the lighting on again at 4:00 a.m. and turn off 30 minutes after sunrise.
Determine the best products for your application with our Sales Engineers.
3. Automatic Reboot
Automatic reboot functionality is crucial for maintaining the reliability of networked devices. ControlByWeb controllers can monitor devices and reboot them if they become unresponsive.
Example: Automatic Router Reboot
Any ControlByWeb relay device can be used to set up automatic reboot for a router. For this example, we’ll use the X-400™ modular controller. Connect the X-400 to an X-11S™ expansion module, which can connect to the power source of the router. Then configure the X-400 to send periodic ping requests (pinging the IP address of the router). If the router fails to respond to a preset number of pings, the X-400 will trigger a reboot. This ensures continuous network connectivity without manual intervention.
4. API & Protocols

ControlByWeb controllers feature an open REST API, allowing seamless integration with third-party systems and custom software. This flexibility is perfect for advanced users who need to access and control devices programmatically. With the REST API, you can poll data from a ControlByWeb module and log it remotely. Use HTTP GET requests to retrieve sensor data and control relay states. This method is particularly useful for applications requiring remote monitoring and data analysis.
In addition to the REST API, our controllers also support MQTT (Message Queuing Telemetry Transport), a lightweight messaging protocol ideal for IoT applications. MQTT allows for efficient, real-time data transmission between devices.
Example: Remote Data Logging with MQTT
- Set Up MQTT Broker: Configure an MQTT broker (such as HiveMQ or Mosquitto) to handle message routing between the controller and your remote logging system.
- Publish Sensor Data: Program the controller to publish sensor data to specific MQTT topics. For example, temperature data could be published to the topic “sensors/temperature.”
- Subscribe to Topics: On the remote logging system, subscribe to relevant MQTT topics to receive real-time updates. This allows you to log sensor data as it is published.
- Control Relays: You can also control relay states by publishing messages to specific topics. For example, publishing ON or OFF to the topic “relays/relay1” can control the state of relay 1.
5. Scripting
For advanced logic and custom applications, ControlByWeb controllers support scripting. You can write scripts in BASIC (or LUA for the X-600M™) to perform complex tasks that go beyond the standard configuration options.
Example: Custom Alarm System
Using BASIC scripting, you can create a custom alarm system. Write a script that activates a relay when multiple conditions are met, such as both input1 and input2 being on. This script can also send email notifications if a door is opened outside of business hours. A full BASIC script tutorial is available on our knowledge base.
The ControlByWeb® Difference
ControlByWeb controllers offer a range of programming options, features, I/O combinations, and communication protocols to suit various automation needs. Whether you’re using conditional logic for responsive control, scheduled logic for routine tasks, automatic reboot for reliability, API for integration, or scripting for custom solutions, these controllers provide the flexibility and power to enhance your control systems.
How do you use our products? We’d love to learn more about the inventive ways ControlByWeb fits into your IoT solutions. If you’d like to learn more and see how we can help with your industrial application, contact our team or schedule a 15-minute product demo.
Subscribe to Our Newsletter
Subscribe to Our Newsletter
Sign up for our newsletter to receive information regarding new products and exclusive offers.