Pet water fountain with water sensor + push notification

Hello experts!
I want to start a project for my kitties' water fountain and I will need your assistance =^_^=

Basically it will be a Wi-Fi board connected to a water sensor that will stop or start the water pump (connected to a 5V relay) depending on how low the water level is. Additionally, it will send a push notification to my mobile device.

More or less I have the wiring clear (tried to build a schema and post it here, but I'm struggling with the editor) but I still don't know what water sensor to use.

This one is being discarded, because the water will be used to drink, and I read in other topics that it's not suitable for drinking:

Other option would be this contactless sensor:

Any other idea about what kind of sensor can I use for this project?

Many thanks!

A sensor using a float and an optic sensor registering when the float is laying to low.
A float carrying a magnet and a Hall sensor is another option.
That requires some mechanic preparation but regarding health, it can be made safe.

1 Like

Kittens play with everything so this may not work well. When kitty drinks there is a face in the bowl and the water is turbulent. That may be hard to deal with, too.

Best way to deal with all of that is to place the sensor or float inside a tube with the bottom cut out and air vent hole in the top.
Simple............ :upside_down_face:

1 Like

interesting... what kind of sensor are we talking about?

These work fine, one for lower limit, and one for upper limit and stop filling.

1 Like

looks interesting, my only problem is that is a ceramic water fountain, with this do you need to make a hole?

Yes.

Might work without a hole.

1 Like

thanks for your feedback, so I have the hardware, sensors and relay, coded everything, now the key piece I'm missing is the push notification. Anyone experienced on this?

I checked pushsafer, no success, other choice is firebase.

Hello sarilla
Place the ceramic water fountain on an Arduino based scale.

You could use IFTTT.

Or send yourself an email. Or email yourself a text.

Hi,

Do you have that working?
Don't go any further until this stage of you project is working properly.

Have you got any code working?
If so, can you please post your code?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Here you have, the code is quite simple, since I'm new programming and forgive the begginners errors.

The sensor is connected to pin2
Relay to pin3

The board used is WIFI UNO Rev2

At the moment it is connecting to a Firebase database and stores a bit based on changes only, that's why I declared 2 variables: LiquidNew and LiquidOld.

Happy to hear your feedback!

#include <Config.h>
#include <Firebase.h>
#include <Firebase_Arduino_WiFiNINA.h>
#include <Firebase_TCP_Client.h>
#include <WCS.h>
#include <LiquidCrystal.h> 
#include <WiFiClient.h>
#include <WiFiNINA.h>

//LDC
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int analogPin = A0;  //Define the A0 as analogPin as integer type.

//INPUT SENSOR
#define Liquid_Detection_Pin 2     
// OUTPUT RELAY
int relay = 3; // relay

//Sensor status for firebase
int LiquidOld = 0;
int LiquidNew = 0;

//WIFI

char ssid[] = "MY_WIFI";             //  your network SSID (name) between the " "
char pass[] = "MY_PASWORD";      // your network password between the " "
int status = WL_IDLE_STATUS;      //connection status


/*WiFiClientSecure client;*/

// Insert Firebase project API Key
#define API_KEY "API_KEY"

// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "URL.firebasedatabase.app"
#define FIREBASE_AUTH "SECRET_KEY"
#define WIFI_SSID "MY_WIFI"             
#define WIFI_PASS "MY_PASSWORD" 


//Define Firebase Data object
FirebaseData firebaseData;



void setup ()
{
  lcd.begin(16, 2);            // set the lcd type: 16-character by 2-lines
  lcd.clear();                        // LCD screen clear
  lcd.print("Smart Fountain");      // Send the ASCII code to the LCD for 
                                      // displaying the message
  pinMode(10, OUTPUT);                // sets backlight pin-10 as PWM output
  analogWrite(10, 125);               // Set backlight to 50% brightness 
    
//CONNECT WIFI
  enable_WiFi();
  connect_WiFi();
  printWifiStatus();

//SENSOR
  pinMode(Liquid_Detection_Pin, INPUT);

//RELAY - OFF
  pinMode(relay, OUTPUT);
  digitalWrite(relay,LOW);

//Connect Firebase    
  Firebase.begin(DATABASE_URL, FIREBASE_AUTH, WIFI_SSID, WIFI_PASS);

    delay(5000);

}

void loop()
{
                                      
 if (digitalRead(Liquid_Detection_Pin)) {
   LiquidNew = 1;
   lcd.clear();
   lcd.setCursor(0, 0);
    lcd.print("Liquid Detected!");
    digitalWrite(relay, HIGH);
    if(LiquidOld != LiquidNew) {
Firebase.setFloat(firebaseData, "Arduino1" ,1);
      
      }
    LiquidOld = 1;

  }
  else {
    LiquidNew = 0;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("No Liquid!");
      digitalWrite(relay,LOW);
      if(LiquidOld != LiquidNew) {
Firebase.setFloat(firebaseData, "Arduino1" ,0);
      

      }
      else{
        
      }
LiquidOld = 0;
  }
  delay(1000);
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
   lcd.clear();
    lcd.setCursor(0, 0);
  lcd.print("SSID: ");

    lcd.setCursor(1, 0);
  lcd.print(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
   lcd.clear();
    lcd.setCursor(0, 0);
  lcd.print("IP Address: ");

    lcd.setCursor(1, 0);
  lcd.print(ip);

  // print the received signal strength:
  // long rssi = WiFi.RSSI();
  // lcd.print("signal strength (RSSI):");
  // lcd.print(rssi);
  // lcd.print(" dBm");

}

void enable_WiFi() {
  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
     lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") {
    lcd.print("Please upgrade the firmware");
  }
}

void connect_WiFi() {
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
     lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Attempting to connect to SSID: ");
    lcd.setCursor(1, 0);
    lcd.print(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.