Adah Saidi
Published © GPL3+

Just A Pet Feeder

This project was inspired and replicated from another Hackster project. It's an awesome project! But its not mine.

IntermediateWork in progressOver 1 day2,005
Just A Pet Feeder

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
2 split power buses, 10 column , 63 rows.
×1
Small Thin Speaker
Small thin speaker, 8 ohm, 0.5 W
×1
Tower Pro MG 995 servo
180 degree spin
×1
Voltage Regulator 5v
×1
electrolytic capasitor 1uF/50v
×1
Capasitor Ceramic 100nF
×1
PIR motion sensor
×1
WiFi Module ESP-8266
×1
SparkFun Logic Level Converter - Bi-Directional
SparkFun Logic Level Converter - Bi-Directional
mine is blue colored
×1
Wall Adapter 12VDC 2A
×1
Arduino UNO
Arduino UNO
×1
USB cable A to B
×1
Jumper Wires Pack M-M
male to male, the ends are pointy
×1
Jumper Wires Pack F-M
female to male, one end in pointy and the other is not
×1

Software apps and online services

Arduino IDE
Arduino IDE
to upload and modify your codes for arduino
circuito.io
circuito.io
circuito.io team gave a link to their site, you guys can view it here, where the original project is :) https://www.hackster.io/circuito-io-team/iot-pet-feeder-10a4f3

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
To solder wires and component together.

Story

Read more

Schematics

How my project looks like

A pet feeder that I plan to continue work on.

Code

Codes used

Arduino
You will get the code along the way doing this project, following circuito.io https://www.hackster.io/circuito-io-team/iot-pet-feeder-10a4f3.
// Include Libraries
#include "Arduino.h"
#include "ESP8266.h"
#include "dweet.h"
#include "PIR.h"
#include "Servo.h"
#include "PiezoSpeaker.h"


// Pin Definitions
#define ESP8266_PIN_RX	10
#define ESP8266_PIN_TX	11
#define PIR_PIN_SIG	4
#define SERVOSM_PIN_SIG	3
#define THINSPEAKER_PIN_POS	2



// Global variables and defines
const int servoSMRestPosition   = 20;  //Starting position
const int servoSMTargetPosition = 150; //Position when event is detected
unsigned int thinSpeakerHoorayLength          = 6;                                                      // amount of notes in melody
unsigned int thinSpeakerHoorayMelody[]        = {NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5}; // list of notes. List length must match HoorayLength!
unsigned int thinSpeakerHoorayNoteDurations[] = {8      , 8      , 8      , 4      , 8      , 4      }; // note durations; 4 = quarter note, 8 = eighth note, etc. List length must match HoorayLength!

// ====================================================================
// vvvvvvvvvvvvvvvvvvvv ENTER YOUR WI-FI SETTINGS  vvvvvvvvvvvvvvvvvvvv
//
const char *SSID     = "WIFI-SSID"; // Enter your Wi-Fi name 
const char *PASSWORD = "PASSWORD" ; // Enter your Wi-Fi password
//
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ====================================================================


// These Dweet tokens have been auto generated for you.
char* const inputToken  = "59c94c3a6529860020905448_input";
char* const outputToken = "59c94c3a6529860020905448_output";

// object initialization
ESP8266 wifi(ESP8266_PIN_RX,ESP8266_PIN_TX);
Dweet dweet( &wifi, inputToken, outputToken);
Servo servoSM;
PIR pir(PIR_PIN_SIG);
PiezoSpeaker thinSpeaker(THINSPEAKER_PIN_POS);



// define vars for testing menu
const int timeout = 10000;       //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup() 
{
    // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    while (!Serial) ; // wait for serial port to connect. Needed for native USB
    Serial.println("start");
    
    wifi.init(SSID, PASSWORD);
    servoSM.attach(SERVOSM_PIN_SIG);
    servoSM.write(servoSMRestPosition);
    delay(100);
    servoSM.detach();
    menuOption = menu();
    
}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop() 
{
    
    
    if(menuOption == '1') {
    // PIRGeneric - Test Code
    bool pirVal = pir.read();
    Serial.print(F("Val: ")); Serial.println(pirVal);
    
    }
    else if(menuOption == '2') {
    // ServoSM - Test Code
    // The servo will rotate to target position and back to resting position with an interval of 500 milliseconds (0.5 seconds) 
    servoSM.attach(SERVOSM_PIN_SIG);         // 1. attach the servo to correct pin to control it.
    servoSM.write(servoSMTargetPosition);  // 2. turns servo to target position. Modify target position by modifying the 'ServoTargetPosition' definition above.
    delay(500);                              // 3. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
    servoSM.write(servoSMRestPosition);    // 4. turns servo back to rest position. Modify initial position by modifying the 'ServoRestPosition' definition above.
    delay(500);                              // 5. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
    servoSM.detach();                    // 6. release the servo to conserve power. When detached the servo will NOT hold it's position under stress.
    }
    else if(menuOption == '3') {
    // Speaker05W - Test Code
    // The Speaker will play the Hooray tune
    thinSpeaker.playMelody(thinSpeakerHoorayLength, thinSpeakerHoorayMelody, thinSpeakerHoorayNoteDurations); 
    delay(500);   
    }
    else if (menuOption == '4') {
    
    //SET DWEETS
    
    dweet.setDweet("DemoKey", "DemoValue"); // replace with your own (key, value) pairs to dweet your data
    dweet.sendDweetKeys();
    
    
    //GET DWEETS  
    dweet.receiveDweetEvents();
    
    if(!strcmp(dweet.getValue() , "DemoEventName"))
    {
        Serial.println("DemoEventName received!");
        // Do something
    }
    }
    
    if (millis() - time0 > timeout)
    {
        menuOption = menu();
    }
    
}



// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{

    Serial.println(F("\nWhich component would you like to test?"));
    Serial.println(F("(1) PIRGeneric"));
    Serial.println(F("(2) ServoSM"));
    Serial.println(F("(3) Speaker05W"));
    Serial.println(F("(4) IOT"));
    Serial.println(F("(menu) send anything else or press on board reset button\n"));
    while (!Serial.available());

    // Read data from serial monitor if received
    while (Serial.available()) 
    {
        char c = Serial.read();
        if (isAlphaNumeric(c)) 
        {
            if(c == '1') 
    			Serial.println(F("Now Testing PIRGeneric"));
    		else if(c == '2') 
    			Serial.println(F("Now Testing ServoSM"));
    		else if(c == '3') 
    			Serial.println(F("Now Testing Speaker05W"));
    		else if(c == '4') 
    			Serial.println(F("Now Testing IOT"));
            else
            {
                Serial.println(F("illegal input!"));
                return 0;
            }
            time0 = millis();
            return c;
            }
        }
    }

/*******************************************************

*    Circuito.io is an automatic generator of schematics and code for off
*    the shelf hardware combinations.

*    Copyright (C) 2016 Roboplan Technologies Ltd.

*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.

*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.

*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*    In addition, and without limitation, to the disclaimers of warranties 
*    stated above and in the GNU General Public License version 3 (or any 
*    later version), Roboplan Technologies Ltd. ("Roboplan") offers this 
*    program subject to the following warranty disclaimers and by using 
*    this program you acknowledge and agree to the following:
*    THIS PROGRAM IS PROVIDED ON AN "AS IS" AND "AS AVAILABLE" BASIS, AND 
*    WITHOUT WARRANTIES OF ANY KIND EITHER EXPRESS OR IMPLIED.  ROBOPLAN 
*    HEREBY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT 
*    NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS 
*    FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND THOSE ARISING BY 
*    STATUTE OR FROM A COURSE OF DEALING OR USAGE OF TRADE. 
*    YOUR RELIANCE ON, OR USE OF THIS PROGRAM IS AT YOUR SOLE RISK.
*    ROBOPLAN DOES NOT GUARANTEE THAT THE PROGRAM WILL BE FREE OF, OR NOT 
*    SUSCEPTIBLE TO, BUGS, SECURITY BREACHES, OR VIRUSES. ROBOPLAN DOES 
*    NOT WARRANT THAT YOUR USE OF THE PROGRAM, INCLUDING PURSUANT TO 
*    SCHEMATICS, INSTRUCTIONS OR RECOMMENDATIONS OF ROBOPLAN, WILL BE SAFE 
*    FOR PERSONAL USE OR FOR PRODUCTION OR COMMERCIAL USE, WILL NOT 
*    VIOLATE ANY THIRD PARTY RIGHTS, WILL PROVIDE THE INTENDED OR DESIRED
*    RESULTS, OR OPERATE AS YOU INTENDED OR AS MAY BE INDICATED BY ROBOPLAN. 
*    YOU HEREBY WAIVE, AGREE NOT TO ASSERT AGAINST, AND RELEASE ROBOPLAN, 
*    ITS LICENSORS AND AFFILIATES FROM, ANY CLAIMS IN CONNECTION WITH ANY OF 
*    THE ABOVE. 
********************************************************/

Credits

Adah Saidi
0 projects • 0 followers
super amateur and I hate coding but I want to learn it.
Contact
Thanks to circuito.io team.

Comments

Please log in or sign up to comment.