A Water Level Float Switch Sensor is an electromechanical device designed to indicate the level of water within a tank or container. It operates by opening or closing a circuit as the float rises and falls with the water level, making it an essential component in applications such as automatic water pumps, alarms, and other level monitoring systems.
Pin | Description |
---|---|
1 | Common (C) |
2 | Normally Open (NO) |
3 | Normally Closed (NC) |
Note: Some models may only have two wires, with one common and either a normally open or normally closed contact.
// Define the float switch pin
const int floatSwitchPin = 2; // Connect the float switch to digital pin 2
void setup() {
pinMode(floatSwitchPin, INPUT_PULLUP); // Set the float switch pin as an input
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int floatSwitchState = digitalRead(floatSwitchPin); // Read the float switch state
if (floatSwitchState == LOW) {
// When the water level is high, the switch is closed (assuming NO configuration)
Serial.println("Water level high!");
// Add code to handle high water level (e.g., turn off a pump)
} else {
// When the water level is low, the switch is open
Serial.println("Water level low.");
// Add code to handle low water level (e.g., turn on a pump)
}
delay(1000); // Wait for 1 second before reading again
}
Note: The above code assumes that the float switch is wired to provide a LOW signal when the water level is high (normally open configuration). Adjust the logic accordingly if your switch is normally closed.
Q: Can I use the float switch with AC voltage? A: Yes, but ensure the switch's voltage and current ratings are compatible with your AC circuit.
Q: How do I know if my float switch is normally open or normally closed? A: You can determine this by checking the continuity of the switch in its resting state with a multimeter.
Q: Is it possible to adjust the water level at which the switch activates? A: This depends on the design of the float switch. Some models have adjustable collars or mounting positions to set the activation level.
Remember to always follow safety guidelines when working with electrical components and consult the manufacturer's datasheet for specific information about your float switch model.