Mahraiel HannaAndrew Ibeh-kingsley
Published

Autonomous IoT Pet Feeder

Our Pet Feeder puts your mind at ease by ensuring that your pet is well fed while you are away from home!

IntermediateFull instructions provided30
Autonomous IoT Pet Feeder

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×7
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Dog Food Bowls
×1

Software apps and online services

Google Sheets
Google Sheets
Particle Build Web IDE
Particle Build Web IDE
SmartThings service
IFTTT SmartThings service

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

3d Printed Pet Feeder Base Model

Isometric Solid Body View

3d Printed Pet Feeder Base Model

Isometric skeleton View

Schematics

HC-SR04 Ultrasonic Wiring Diagram Setup Argon 1:

This circuit shows how the Ultrasonic Sensor is connected to the Particle Argon.

9g Micro Sservo Motor Wiring Digram Setup Argon 2

This Circuit shows how the Micro Servo Motor is connected to the Particle Argon

Code

HC-SR04 Ultrasonic Sensor Code Particle Argon 1

C/C++
Below is the Code used for Particle Argon 1. The Argon only publish "motionin" when the pet is less than 60 cm away and the function armed = true which this is the function we used for the lock out our program.
// Pin Definitions

#define HCSR04_PIN_TRIG	D2
#define HCSR04_PIN_ECHO	D6

int sound = 0;
bool armed = true; 
int timenow = 0;
int future = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
 
  pinMode(HCSR04_PIN_TRIG, OUTPUT);
  pinMode(HCSR04_PIN_ECHO, INPUT);
 
}

void loop() {
  // put your main code here, to run repeatedly:
  long timeTaken, distance;
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(HCSR04_PIN_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  timeTaken = pulseIn(HCSR04_PIN_ECHO, HIGH);//determine distance of wave
  distance = (timeTaken/2)/29.1;//using timeTaken calc distance of object

  /*determine corressponding leds to light up with respect to the distance
  of object*/


    if(distance<=60 && armed ){
       Particle.publish("MEGR3171_IOTMK","Motionin",PUBLIC);
       armed = false;
       timenow = millis();
       future = timenow + 10000; //10s in the future


    }
    else{
}
    delay(1000);
  


    if(millis() > future){  //do it again
    armed = true;
    }}
    

Micro Servo Motor Code: particle Argon 2

C/C++
Below is the Code for the Micro Servo Motor. Argon 2 reads the Publish function from Argon 1, and then it Subscribe Rotating the servo to Open the 3d printed base lid and rotating it back in a responsible time.
/ subscribes the receiver Argon to the published events from the
// mesauring argon. In the last arguement for the subscribe function, enter
// the device ID from the publishing argon.
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(D2);   // attach the servo on the D2 pin to the servo object
    
   


   
    Particle.subscribe("MEGR3171_IOTMK", b);
   
}
// converts Unix time data from subscribe functions to an integer value


void b(const char *event, const char *data) {
     
 loop();
{
  for(pos = 0; pos < 90; pos += 1)  // goes from 0 degrees to 180(now 100) degrees ; in steps of 1 degree
  {                                  
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 90; pos>=1; pos-=1)     // goes from 180 degrees(now 100) to 0 degrees
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
}}

Credits

Mahraiel Hanna

Mahraiel Hanna

1 project • 0 followers
Andrew Ibeh-kingsley

Andrew Ibeh-kingsley

1 project • 0 followers

Comments

Add projectSign up / Login