Introduction
In this case, we are using a basic water digital sensor. This sensor is very useful to detect if it's raining or if we have liquid water at some point in our installation. The sensor is digital and will provide us a logic 1 when it's dry and a logic 0 when the sensor detects liquid water.
Requirements
Ethernet PLC or 20 I/Os PLC:Ethernet PLC
20 I/Os PLC
Water Sensor
Industrial Shields boards: How to use the mapping pins of Industrial Shields boards
Connections

Sensor Pin | M-Duino Pin |
VCC | 5V |
GND | GND |
SIG | PIN 2 |
Software
This software is very simple. We are just reading the value in our Pin 2 and displaying it in the serial monitor through the Serial functions.
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup(){
Serial.begin(9600L);
pinMode(2, INPUT);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop(){
int water_level = digitalRead(2);
Serial.print("Water level: ");
Serial.println(water_level);
delay(1000);
}
void setup(){
Serial.begin(9600L);
pinMode(2, INPUT);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop(){
int water_level = digitalRead(2);
Serial.print("Water level: ");
Serial.println(water_level);
delay(1000);
}
Water sensor using Arduino based PLC