jaustin2930
Published © GPL3+

Fat Cat Food Guardian

A smart pet feeding system that keeps one cat's food (she has dietary restrictions) safe from the other who will/does eat anything!

IntermediateShowcase (no instructions)315
Fat Cat Food Guardian

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Load Cell & HX711
×1
HiTec RCD 33755S HS-755HB Karbonite Giant Scale Servo
×1
Dual DC Power Supply: 5vdc @ 1.5A & 9vdc @ 1.5v
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic of control circuit

Note that the outputs of the 5/9 VDC power supply will depend on how you build the kit.

Code

Load Cell Calibration Sketch

Arduino
Use this code to calibrate your load cell so that it displays an accurate weight measurement.
/*
Fat Cat Feeder Calibration sketch December 2022
Setup your scale and start the sketch WITHOUT a weight on the scale
Wait for "place known weight on scale" message, ad known weight and enter any letter and hit <ENTER>
*/

#include "HX711.h"
const int LOADCELL_DOUT_PIN = 6;
const int LOADCELL_SCK_PIN = 5;
HX711 scale;
float calibration_factor = 40; // this initial calibration factor will be adjusted according to your load cell later in sketch
float units;
float OneTime;

void setup(){
Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
                      
scale.set_scale();        //The first time you run this sketch, this should be blank i.e.  "scale.set_scale()"
                          //then divide set scale number by actual weight, add that here in later!

scale.tare(); //Reset the scale to 0
Serial.println("Place known weight on scale");
while (!Serial.available()) {};   //Type in any letter in the serial input and hit <ENTER>

OneTime=scale.get_units(10);
Serial.print ("Set Scale value is ");
Serial.println(OneTime);          //take this value and divide it by actual weight and enter it into
                                  //line 21 i.e. "scale.set_scale(260.323)"
                                  //when you run the sketch again, it should display the proper weight in grams!
}

void loop(){

}

Fat Cat Food Guardian Sketch

Arduino
This sketch runs the Fat Cat Food Guardian
/*
FatCatFeeder Version 3.0 December 2022
You will want to run the calibration sketch and get the calibration factor
for your load cell prior to running this sketch.
I have left some of the serial print statements that I used to develop this sketch.
They have been commented out.
*/

#include <HX711.h>
#include <VarSpeedServo.h>

VarSpeedServo myServo;

const int LOADCELL_DOUT_PIN = 6;  //DOUT to poin 6 of arduino
const int LOADCELL_SCK_PIN = 5;   //SCK to pin 5 of arduino
HX711 scale;
float calibration_factor = 40; // this initial calibration factor must be adjusted according to your load cell later in sketch

float units;                    //weight read from load cell in grams

float little_cat_weight=5000;   // George weights 11 lbs or ~ 5 kg
float big_cat_weight=6350;      // Lily's ideal weight is 14 lbs or ~ 6.35 kg

const int servoPin=9;          //Servo control wire to pin 9 of arduino
const int bowlOpen=15;         //value that opens servo to allow feeding/filling
const int bowlClosed=75;       //value that covers the bowl to keep George out

const int buttonPin=12;
int buttonRead;
int fillingBowl;

void setup(){
//Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

myServo.attach(servoPin);
myServo.write(bowlClosed, 20);      

pinMode(buttonRead,INPUT);
pinMode(servoPin,OUTPUT);

scale.set_scale(260.32); //Adjust to this calibration factor here by running calibration sketch first
scale.tare();            //Reset the scale to 0
}

void loop(){

buttonRead=digitalRead(buttonPin);   //Read manual opening button for filling the food bowl
if (buttonRead==0) {
  fillingBowl=1;
  //Serial.println("Filling Food Bowl");
  delay(50);
  while(fillingBowl==1){
    myServo.write(bowlOpen, 20);
    myServo.wait();
    buttonRead=digitalRead(buttonPin);
    if (buttonRead==0){
      fillingBowl=0;
      //Serial.println("Filling Completed");
      delay(50);
    }
  }
  
}

myServo.detach();             // scale.get_units call causes servo to jitter due to interrupts, need to disable servo temporarily
units = scale.get_units(), 5; // read the weight value from load cell
myServo.attach(servoPin);     // re-enable servo to allow movement
//Serial.println(units);      // display weight of cat currently on feeder

if (units < 10) {
  //Serial.println("No cat");
  myServo.write(bowlClosed, 20);
  myServo.wait();
}
if (units > 10 && units < big_cat_weight) {
  //Serial.println("Little Cat");
  myServo.write(bowlClosed, 20);
  myServo.wait(); 
}
if (units > big_cat_weight){
  //Serial.println("Big Cat");
  myServo.write (bowlOpen, 20);   // Open feeder slowly
  myServo.wait();
  delay (7000);                   //Keep bowl open for 7 seconds after load is gone

}

}

Credits

jaustin2930
0 projects • 1 follower

Comments