Learning Centre

Cloud PLC - Ethernet


Cloud PLC Cloud PLC lora Cloud PLC rpi

Digital Input (High/Low)

• This program uses the Cloud_PLC library to read the state of the digital input IN1.
• It continuously checks if IN1 is HIGH or LOW and prints "HIGH" or "LOW" to the Serial Monitor accordingly, with a 2-second delay between each check.
• The setup function initializes the Cloud_PLC system and serial communication.
• The loop function handles the repeated state checking and reporting.


Wiring Diagram

Cloud PLC


Code

#include "Cloud_PLC.h"  //Include the header file for Cloud_PLC library
		  void setup()
		  {
  Serial.begin(115200);        //Initialize serial communication at 115200 baud rate
  Cloud_PLC_initialisation();  //Call the initialization function for Cloud_PLC
  }

  void loop()
 
 {  // Check the digital input state of IN1
    Serial.print("Digital input: ");

  if (Cloud_PLC_Digital_Read(DI4) == HIGH) //input channel, DI1,DI2,D13,D14,
  {
    Serial.println("HIGH");      // Print "ON" to the Serial Monitor if DI4 is HIGH
    delay(2000);
  } 
else 
  {
    Serial.println("LOW");       // Print "OFF" to the Serial Monitor 
    delay(2000);                  // Wait for 2000 milliseconds (2 seconds)
  }
}

	


Note

Cloud PLC Libraries, User Manuals and Installation guides look into the download section.
Cloud PLC Install the Cloud PLC libraries(cloudplc.h) before getting start with coding. Download
Cloud PLC Above download link, you will find all the IO functionalities included in the Cloud PLC library.
Cloud PLC In the Arduino IDE, go to the Boards Manager, select the ESP32 board, ensure that you have selected the board version is 1.0.4 and select the com port of the device.


Video