Betsy Farris
Published

Automatic or Remote Dog Feeder

Cheap and easy way to feed the dog from anywhere via your phone.

BeginnerShowcase (no instructions)3 hours5,660
Automatic or Remote Dog Feeder

Things used in this project

Hardware components

Adafruit Feather HUZZAH with ESP8266 WiFi
Adafruit Feather HUZZAH with ESP8266 WiFi
×1
DC motor (generic)
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Drill Taps
OpenBuilds Drill Taps
Drill holes big enough to fit screws for motor mount (depends on motor)

Story

Read more

Custom parts and enclosures

Motor/Shaft Hardware

Picture of how I mounted the motor

Bill of Materials

Links for hardware

Schematics

Wiring Diagram (breadboard)

Via Fritzing-- I kept the system on a breadboard for easy changes.

BlockDiagram

How system works

Blynk Setup Explanation

How to setup the blynk app and which widgets to include (see code for virtual pin numbers)

Code

DogFeed_AdafruitFeather_Blynk

Arduino
Code to set up a schedule or manually feed dog (move motor); include BlynkSimpleEsp8266.h library
//Created by Betsy Farris (betsyfarris.com)
//Main inspiration and hardware choices: https://www.instructables.com/id/Internet-Enabled-Raspberry-Pi-Pet-Feeder/
//codes used/edited  https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/RTC/RTC.ino
//Thanks to Kyle Greer (Robo-Farmer-Extraordinaire) for his stylistic comments and help with the Blynk code.
/*****setup on Blynk (manual tab)****/
//V5=slider for cups to feed (0-100)
//V3= time lcd
//V4= date lcd
//V1= push button for manual feeding
// include real-time clock with current timezone
/*****setup on Blynk (scheduler tab)****/
//V8= scheduler on/off push button
//V6 morning feed time (set to start/stop for 1sec)
//V7 evening feed time (set to start/stop for 1sec)
//include notification widget (hardware notify off, low priority)

#define BLYNK_PRINT Serial


#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>


/******* delcare functions****/
void clockDisplay();  
void schedulechecker();

/********************* WIDGET SETUP **********************/

//LCDs
WidgetLCD lcd(V3);
WidgetLCD lcd1(V4);

// RTC
BlynkTimer timer;
WidgetRTC rtc;


/********************* WifiSettings **********************/
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "********************************";

// Your WiFi credentials.
// Set password to "" for open networks.
//char ssid[] = "w212lab";
//char pass[] = "testarduino";

/****numbers***/
int motorPin = 12;
int scheduler=0;
int timeornot=0; //initialize feed timer to be off
int motorturns=10000; //default time to dispense 10 s



/******** CLOCK DISPLAY *******/
void clockDisplay() //not sure if I really need this but it updates the serial monitor
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}


/************** SETUP SETUP SETUP SETUP SETUP *****************/
void setup()
{
  Serial.begin(9600); //baude rate of monitor
  pinMode(motorPin, OUTPUT); // digital pin (12) on huzzah

  /******** Connect Blynk ***********/  
  Blynk.begin(auth, ssid, pass);
  rtc.begin();

setSyncInterval(10 * 60); // Sync interval in seconds (10 min)
timer.setInterval(100L, clockDisplay);
}

/************ LOOP  LOOP   LOOP   LOOP   LOOP********/


void loop()
{
  Blynk.run(); //runs all Blynk functions
  timer.run(); // Initiates Timer
  schedulerchecker(); //looks for the button for using the schedules times and if the timers get pinged
}


BLYNK_WRITE(V1) //Button Widget is writing to pin V1, manual feed
{
  int food = param.asInt(); 
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(month()) + "/" + day() + "/" + year();
  
  if (food==HIGH){
  digitalWrite(motorPin, HIGH);
  Serial.println("Feeding");
  delay(motorturns); 
  Blynk.virtualWrite(V1, LOW);
  lcd.clear();
  lcd1.clear();
  lcd.print(0,0, "Time Last Fed: ");
  lcd.print(0,1, currentTime);
  lcd1.print(0,0, "Date Last Fed: ");
  lcd1.print(0,1, currentDate);
//turn of motor
  digitalWrite(motorPin, LOW); //stop feeding
  Serial.println("Fed");
} 
}
///****Scheduler****/
BLYNK_WRITE(V6) //morning pin
{ if  (param.asInt() == 1)
  {timeornot=1;
  }
  if (param.asInt()==0)
  {timeornot=0;
  }
}

BLYNK_WRITE(V7) //evening pin
{ if  (param.asInt() == 1)
  {timeornot=1;
  }
    if (param.asInt()==0)
  {timeornot=0;
  }
}

BLYNK_WRITE(V8) // scheduler on or off
{
  if (param.asInt() == 1) {
    scheduler=1;
    timeornot=0;
    Serial.println("Scheduler is ON");
  }
  if (param.asInt() == 0){
    scheduler=0;
    Serial.println("Scheduler is Off");
    }
}

void schedulerchecker()
{
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(month()) + "/" + day() + "/" + year();
  
  if (scheduler==1 && timeornot==1) //autofeed times
{ Blynk.notify("Auto Fed @"+ currentTime);
  digitalWrite(motorPin, HIGH);
  Serial.println("Scheduled Feeding");
  delay(motorturns); 
  Blynk.virtualWrite(V1, LOW);
  lcd.clear();
  lcd1.clear();
  lcd.print(0,0, "Time Auto Fed: ");
  lcd.print(0,1, currentTime);
  lcd1.print(0,0, " Date Auto Fed: ");
  lcd1.print(0,1, currentDate);
//turn of motor
  digitalWrite(motorPin, LOW); //stop feeding
  Serial.println("Fed");
  
}
timeornot=0;
}


/****FOR DEMO ONLY (dispense candy; not needed to feed dog)***/
BLYNK_WRITE(V5)
{ int cup_slider= param.asInt(); //percentage of 1 cup (e.g. 100=1cup)
 motorturns=15*(cup_slider)*10; //cup_slider/100*15*1000 for milliseconds, cancels out to *10 for integers
}

DogFeeder_AdafruitFeather_Blynk

Arduino
Upload to a feather and include the "BlynkESP8266-master" library. Set up Blynk app accordingly (in comments and listed other places in this project).
//Main inspiration and hardware choices: https://www.instructables.com/id/Internet-Enabled-Raspberry-Pi-Pet-Feeder/
//codes used/edited  https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/RTC/RTC.ino
//Thanks to Kyle Greer (Robo-Farmer-Extraordinaire) for his stylistic comments and help with the Blynk code.
/*****setup on Blynk (manual tab)****/
//V5=slider for cups to feed (0-100)
//V3= time lcd
//V4= date lcd
//V1= push button for manual feeding
// include real-time clock with current timezone
/*****setup on Blynk (scheduler tab)****/
//V8= scheduler on/off push button
//V6 morning feed time (set to start/stop for 1sec)
//V7 evening feed time (set to start/stop for 1sec)
//include notification widget (hardware notify off, low priority)

#define BLYNK_PRINT Serial


#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>


/******* delcare functions****/
void clockDisplay();  
void schedulechecker();

/********************* WIDGET SETUP **********************/

//LCDs
WidgetLCD lcd(V3);
WidgetLCD lcd1(V4);

// RTC
BlynkTimer timer;
WidgetRTC rtc;


/********************* WifiSettings **********************/
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "********************************";

// Your WiFi credentials.
// Set password to "" for open networks.
//char ssid[] = "w212lab";
//char pass[] = "testarduino";

/****numbers***/
int motorPin = 12;
int scheduler=0;
int timeornot=0; //initialize feed timer to be off
int motorturns=10000; //default time to dispense 10 s



/******** CLOCK DISPLAY *******/
void clockDisplay() //not sure if I really need this but it updates the serial monitor
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}


/************** SETUP SETUP SETUP SETUP SETUP *****************/
void setup()
{
  Serial.begin(9600); //baude rate of monitor
  pinMode(motorPin, OUTPUT); // digital pin (12) on huzzah

  /******** Connect Blynk ***********/  
  Blynk.begin(auth, ssid, pass);
  rtc.begin();

setSyncInterval(10 * 60); // Sync interval in seconds (10 min)
timer.setInterval(100L, clockDisplay);
}

/************ LOOP  LOOP   LOOP   LOOP   LOOP********/


void loop()
{
  Blynk.run(); //runs all Blynk functions
  timer.run(); // Initiates Timer
  schedulerchecker(); //looks for the button for using the schedules times and if the timers get pinged
}


BLYNK_WRITE(V1) //Button Widget is writing to pin V1, manual feed
{
  int food = param.asInt(); 
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(month()) + "/" + day() + "/" + year();
  
  if (food==HIGH){
  digitalWrite(motorPin, HIGH);
  Serial.println("Feeding");
  delay(motorturns); 
  Blynk.virtualWrite(V1, LOW);
  lcd.clear();
  lcd1.clear();
  lcd.print(0,0, "Time Last Fed: ");
  lcd.print(0,1, currentTime);
  lcd1.print(0,0, "Date Last Fed: ");
  lcd1.print(0,1, currentDate);
//turn of motor
  digitalWrite(motorPin, LOW); //stop feeding
  Serial.println("Fed");
} 
}
///****Scheduler****/
BLYNK_WRITE(V6) //morning pin
{ if  (param.asInt() == 1)
  {timeornot=1;
  }
  if (param.asInt()==0)
  {timeornot=0;
  }
}

BLYNK_WRITE(V7) //evening pin
{ if  (param.asInt() == 1)
  {timeornot=1;
  }
    if (param.asInt()==0)
  {timeornot=0;
  }
}

BLYNK_WRITE(V8) // scheduler on or off
{
  if (param.asInt() == 1) {
    scheduler=1;
    timeornot=0;
    Serial.println("Scheduler is ON");
  }
  if (param.asInt() == 0){
    scheduler=0;
    Serial.println("Scheduler is Off");
    }
}

void schedulerchecker()
{
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(month()) + "/" + day() + "/" + year();
  
  if (scheduler==1 && timeornot==1) //autofeed times
{ Blynk.notify("Auto Fed @"+ currentTime);
  digitalWrite(motorPin, HIGH);
  Serial.println("Scheduled Feeding");
  delay(motorturns); 
  Blynk.virtualWrite(V1, LOW);
  lcd.clear();
  lcd1.clear();
  lcd.print(0,0, "Time Auto Fed: ");
  lcd.print(0,1, currentTime);
  lcd1.print(0,0, " Date Auto Fed: ");
  lcd1.print(0,1, currentDate);
//turn of motor
  digitalWrite(motorPin, LOW); //stop feeding
  Serial.println("Fed");
  
}
timeornot=0;
}


/****FOR DEMO ONLY (dispense candy; not needed to feed dog)***/
BLYNK_WRITE(V5)
{ int cup_slider= param.asInt(); //percentage of 1 cup (e.g. 100=1cup)
 motorturns=15*(cup_slider)*10; //cup_slider/100*15*1000 for milliseconds, cancels out to *10 for integers
}

Credits

Betsy Farris

Betsy Farris

1 project • 0 followers
Bike nerd, engineer, amateur crafter, nap & cookie-eating expert

Comments