Brandon KrahnHunter Soper
Published © GPL3+

Automated Dog Food Dispenser

Utilizes IFTTT Google Calendar to operate a servo motor, and sends data to another particle photon to tabulate the data.

IntermediateFull instructions provided6 hours1,772
Automated Dog Food Dispenser

Things used in this project

Hardware components

Photon
Particle Photon
×2
ControlEverything.com I2C Shield
×1
ControlEverything.com ADS1115 I2C 16-Bit Analog-Digital Converter
×1
Winrida 11lb 5kg Digital Kitchen Food Scale,1g/0.01oz Resolution,Calibration Supported, LCD Display,White
×1
Tower Pro MG996R Robot Servo 360° Rotation
×1
Zevro KCH-06121/GAT200 Indispensable Dry Food Dispensers
×1
Basswood
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Calendar
Particle IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Drill
Screwdriver

Story

Read more

Schematics

Feed Dog Graph

Graphical representation of dog feeding schedule. The data points near the ordinate were not representative of actual data points as they were obtained while adjusting the scale in ThingSpeak. The data points that expand beyond the y-axis are representative of actual data points.

Final Schematic

This is the wiring diagram for the final design

Code

mobicle_servo

C/C++
DO NOT USE THIS CODE! This is example code of attempting to add functions to create buttons on mobicle.io.
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(D0);  // attaches the servo on the D0 pin to the servo object
  // Only supported on pins that have PWM
}
int servo(String command) {

void loop()

// Finally, we will write out our ledToggle function, which is referenced by the Particle.function() called "led"



    if (command=="on") {
        digitalWrite(myservo,HIGH);
          for(pos = 0; pos < 360; pos += 1)  // goes from 0 degrees to 360 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(0);                       // waits 0ms for the servo to reach the position
  }
        return 1;
    }
    else if (command=="off") {
        digitalWrite(myservo,LOW);
          for(pos = 0; pos < 0; pos += 0)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(0);                       // waits 15ms for the servo to reach the position
  }
        return 0;
    }
    else {
        return -1;
    }

ThingSpeak and LED Code

C/C++
Code used for the photon that subscribed to the particle cloud that graphed data points on ThingSpeak and flashed the D7 LED for five seconds.
int led = D7;

void setup() {
    
    pinMode(led, OUTPUT);
    digitalWrite(led, LOW);
    
    Particle.subscribe("Feed_Dog", Confirm_Feed_Dog, "550038000a51353531343431");
    
}

void Confirm_Feed_Dog(const char *event, const char *data)
{
    digitalWrite(led, HIGH);
    delay(5000);
    digitalWrite(led, LOW);
    String Feed_Dog = String(random(0,100));
    Particle.publish("Feed Dog", Feed_Dog, PRIVATE);
    delay(10000);
}

Analog Voltage Readout

C/C++
This code was used in an attempt to directly read output voltages from the load cell without the use of an ADC.
int analogvalue1 = 0;
int analogvalue2 = 0;
int analogdiff = 0;
int digival1 = 0;
int digival2 = 0;
int digidiff = 0;
char *message = "my name is particle";
String aString;

void setup()
{
  // variable name max length is 12 characters long
  Particle.variable("analogvalue1", analogvalue1);
  Particle.variable("digival1", digival1);
  Particle.variable("digival2", digival2);
  Particle.variable("digidiff", digidiff);
  Particle.variable("analogvalue2", analogvalue2);
    Particle.variable("analogdiff", analogdiff);
  if (Particle.variable("mess", message)==false)
  {
      // variable not registered!
  }
  Particle.variable("mess2", aString);

  pinMode(A0, INPUT);
}

void loop()
{
  // Read the analog value of the sensor (TMP36)
  analogvalue1 = analogRead(A0);
   analogvalue2 = analogRead(A1);
   analogdiff = (analogvalue1 - analogvalue2);
   digival1 = digitalRead(D0);
   digival2 = digitalRead(D7);
   digidiff = digival1 - digival2;
  //Convert the reading into degree celcius
  //tempC = (((analogvalue * 3.3)/4095) - 0.5) * 100;
  delay(200);
}

IFTTT Servo Driver Code

C/C++
This code subscribes to the event published by IFTTT in conjuction with the Google Calendar event and subsequently drives the servo to operate the food dispenser.
int servoPin = D0;
Servo myservo;
int servoPos = 0;
void setup() {
    myservo.attach( D0 );
Particle.subscribe("Feed_Dog", myHandler);
}

void loop()
{}
  
void myHandler(const char *event, const char *data)
{
    if(strcmp(data,"Feed_Dog")==0)
    {
       Particle.publish("Feed_Dog", "Confirm_Feed_Dog");
myservo.write(180);
delay(2500);
myservo.write(0);
}
}

Credits

Brandon Krahn

Brandon Krahn

1 project • 0 followers
Hunter Soper

Hunter Soper

1 project • 0 followers

Comments