Hello
In your code you use two sensors ? top and low sensors ? connected to pin 8 and pin 9 of uno.
I think if i use only one floot sensor at the bottom of tank, as the floot is up it mean tank is full and as soon the floot is down it mean tank is empty, this will serve my purpose as i do not need indication that tank is full.
/-----( Setup function )-----/
void setup() {
Serial.begin(9600);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
}
/-----( Loop function )-----/
void loop() {
boolean run_cycle = true;
const int lowerSersor = digitalRead(8); // lower float sensor on digital pin 8
const int topSensor = digitalRead(9); // top float sensor on digital pin 9
if (lowerSersor == LOW) { // float sensor has dropped down - tank empty
// Toggle on
if (run_cycle) {
sendSMS();
run_cycle = false;
}
}
if (topSensor == LOW) { // tank now full again - this float sensor is upside down so it float when the tank is full
// Toggle off
if (run_cycle == false) {
run_cycle = true;
}
}
}
void sendSMS() {
// Some code here to send a sms
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGF=1"); // send SMS in text mode
delay(1000);
Serial.println("AT+CMGS="+01XXXX""); //CHANGE TO Number , you'd like to receive message
delay(1000);
Serial.print("Water level is low in underground tank (attention required)"); // content of the message
Serial.write(26); // ctrl+z ASCII code
}
</>