|
arduino IDEArduino
|
Arduino-Based Water Detection and 230V Relay Control System
This system provides a complete solution for water detection and control of 230V devices through a relay, powered by an Arduino. The integrated water sensor detects the presence of water and, when triggered, activates the relay to connect any device to the 230V household electrical supply.
The system includes a power conversion circuit that steps down the 230V AC input to a safe 5V DC output, which powers the Arduino and the relay. This ensures the entire system is safely operable using Arduino while managing the high voltage required for controlling external devices.
Three LED indicators provide real-time status:
- Power LED: Indicates that the system is powered and ready to operate.
- Relay Activation LED: Shows when the relay has been triggered by the water sensor.
- Device Activation LED: Lights up when the connected device is powered on via the relay.
This system is ideal for applications like flood prevention, automatic control of pumps, or other devices that should only operate in the presence of water, providing a simple, reliable, and safe solution for both home and industrial environments.
Use HI LINK 9 or 12 Vdc. Not 5Vdc.
If you want 5Vdc version leave a comment
#include <EEPROM.h>
const int pin_water_sensor = A4;
const int pin_relay = 7;
const int pin_water_led = 4;
const int water_threshold = 400; // Soglia di livello acqua per l'attivazione
const unsigned long pump_duration = 3000; // Durata massima accensione pompa (20 secondi)
unsigned long startMillis = 0;
int water_sensor;
// Indirizzo EEPROM per il contatore di attivazioni
const int addressActivationCount = 0; // Indirizzo per il contatore di attivazioni
// Variabile per memorizzare le attivazioni
int relayActivations = 0;
void setup() {
pinMode(pin_relay, OUTPUT);
pinMode(pin_water_led, OUTPUT);
Serial.begin(9600);
// Assicurati che la pompa e il LED siano spenti all'inizio
digitalWrite(pin_relay, LOW);
digitalWrite(pin_water_led, LOW);
// Carica il numero di attivazioni salvato dalla EEPROM
EEPROM.get(addressActivationCount, relayActivations);
if (relayActivations < 0) {
relayActivations = 0;
EEPROM.update(addressActivationCount, relayActivations);
}
Serial.print("Numero di attivazioni salvato: ");
Serial.println(relayActivations);
}
void loop() {
water_sensor = analogRead(pin_water_sensor);
Serial.println(water_sensor);
// Controllo se il livello d'acqua è sotto la soglia
if (water_sensor < water_threshold) {
if (digitalRead(pin_relay) == LOW) {
// Accende la pompa e il LED
digitalWrite(pin_relay, HIGH);
digitalWrite(pin_water_led, HIGH);
// Incrementa il numero di attivazioni e salva su EEPROM
relayActivations++;
EEPROM.update(addressActivationCount, relayActivations);
Serial.print("Numero di attivazioni aggiornato: ");
Serial.println(relayActivations);
// Inizia il timer per la pompa
startMillis = millis();
} else {
// Se la pompa è già accesa, resetta il timer
startMillis = millis();
}
}
// Spegni la pompa se è accesa da più di 20 secondi
if (digitalRead(pin_relay) == HIGH && (millis() - startMillis >= pump_duration)) {
digitalWrite(pin_relay, LOW);
digitalWrite(pin_water_led, LOW);
}
delay(1000); // Piccola pausa tra le letture
}
Arduino-Based Water Detection and 230V Relay Control System
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(2)
- Engineer Nov 28,2024
- (DIY) C64iSTANBUL Nov 08,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Giacomo Cavera
-
-
-
Black Falcon FPV EDF RC Plane! Only free on pcbway!
20 0 0 -
RCTESTFLIGHT Propeller Design Competition
62 0 0 -
-