Introduction: Make an Internet Connected Pet Feeder

First of all, you will need special hardware for making this, which you can buy in the link I'll provide. Keep in mind that this is an Arduino-like platform, so you will be able to make an almost-infinite amount of projects.

Buy Altair @ Tindie Store

In this tutorial a manual execution pet feeder will be made, although later you will be able to modify it so it can work automatically.

Step 1: Materials

We are going to use an Altair: It will have connected a AC adapter and a SERVO motor.

The actions the Altair will have are going to be:

  • Serve a little bit
  • Serve half
  • Serve a lot
  • Toggle (manual)

The only difference among the modes are the time the servo motor will take being open, also, the aperture. Additionally the manual mode was created in order to clean the system.

The material used for this tutorial was:

  • 2 Altair
  • 1 Servomotor
  • 2 Clamps
  • 1 Empty water bottle
  • 1 Cutter

Of course you can make your own design, I made it with materials I found in my house.

The other Altair will be used as the Hub, so we can interact with the Feeder via Internet.

Additionally, I used a 5V and 500mA AC Adapter plugged into the Altair

Step 2: Making Of

The explanation of the code is entirely made inside the code as comments. Whatever doubt you have, feel free to ask.

#include <Wire.h>
#include <Mesh.h> //This header is for the Aquila-only functions
#include <AquilaProtocol.h> //This header is for the Aquila-only functions<br>
#include <Servo.h> //Header needed for making use of the servo functions

Servo a; //Here, we name the servo ‘a’, so we can call it.

int pos = 0;
bool isClosed = true; //This variable is for toggle function only.

//This applies for the next 3 functions:
//a.write(N) it says that when the function begins, the servo will move until position N (knowing  that they can move from 0 to 180 degrees).
//After this, it will wait (delay) for M miliseconds; 1000ms = 1 second.
//After the delay, it will procced to write a new position to the servo, in this case is 9,for this is the grade where THIS servo in particular won’t force (this varies among servos, they don’t cover their entire 180 degrees; you’ll hear a buzz if you’re exceeding it’s limit).


bool serve1(uint8_t param, bool gotParam)
  {
    a.write(80);
    delay(1000);
    a.write(9);
  }
  
bool serve2(uint8_t param, bool gotParam)
  {
    a.write(50);
    delay(1000);
    a.write(9);
  }

bool serve3(uint8_t param, bool gotParam)
  {
    a.write(40);
    delay(650);
    a.write(9);
  }

//Toggle fuction is based on the previous functions. It "will wonder" if the servo is opened or closed. Knowing this, will proceed to close or open, accordingly.

bool toggle(uint8_t param, bool gotParam)

{

if (isClosed)

{
    isClosed = false;
    a.write(80);
  }
  else
  {
    isClosed = true;
    a.write(9);
  }
}

void setup()
{
  a.attach(9); //Servo motor plugged to Altair's pin 9.
  a.write(9); //Servo stops vibrating/buzzing at 9º, so it's initial position is 9 being closed. (It's mere coincidence that the pin and degrees are the same).
  Mesh.begin();
  Aquila.begin();
  Aquila.setClass("mx.makerlab.test");
  Aquila.setName("Feeder");

//Text among quotes is the one will appear on the hub as a button.

//Right after the quoted text is que name of the fuction that will be called whenever the button on the hub is clicked. This is an Aquila-only function
  Aquila.addAction("Serve a lot", serve1); 
  Aquila.addAction("Serve half", serve2);
  Aquila.addAction("Serve a little bit", serve3);
  Aquila.addAction("Toggle", toggle);
  
  Mesh.announce(HUB); //This line is needed in order for this Aquila appears on the hub
}

void loop()
{
  Mesh.loop();
  Aquila.loop();
}