logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)

Tiberia Todeila
Published by Tiberia Todeila at January 11, 2017
Categories
  • Arduino
Tags
  • Arduino
  • arduino uno
  • automatic pet feeder
  • smart devices
  • smart home
automatic pet feeder

Cont. from Part 1 Here >

Step 4: Adding the RFID

The RFID will be used as a key for the system. When your pet is close to the feeder, the RFID will read the value from the tag and will decide whether to supply more food or not. The RFID system uses SPI communication and stores the values from the tags in EEPROM memory. In this case, if the system breaks down (e.g. due to a power supply issue), the information will still be in the memory.

For more information on Arduino SPI Communication, please refer back to Arduino Communication Protocols Tutorial.

For the RFID, the following libraries must be added:

  • SPI
  • MFRC522
  • EEPROM

 

automatic pet feeder

Figure 13: Wire diagram with RDIF added

 

automatic pet feeder

Figure 14: Connection between RFID and the rest of the components

 

We have 2 RFID tags. The red one will be attached to a pet and the blue one, for the sake of testing, will be attached to an outsider (i.e. basically not your pet/something else). The system has 2 functions:

  1. Day: during 8am-8pm the feeder will release food 3 times every 4 hours. The signal that determines food arrival is a sound made by a buzzer that calls your pet to come and eat. When the sound is generated, the pet knows that it’s time for a meal and it will come closer to its bowl (food container). When the tag is near RFID reader, the food will come out.
  2. Night: no sound is made, but if the pet approaches to the RFID after 0am, it will have one-time meal.

 

automatic pet feeder

Figure 15: Tags assigned shown on serial monitor

Step 5: Adding the motor

We’ll be using servo motor SG90. It has an wide angle for servo (0-180 degrees). Our locking system will be similar to lock controlled by an angle (we will control how much food is released when the “lock” is opened/unlocked).

Here are some important points:

  • 0 degree: “Lock” is totally closed and there will be no food released;
  • 180 degree: “Lock” is totally opened and all the food will be released;
  • Between 0-180: you can choose how much food you want to release.

 

automatic pet feeder

Figure 16: Wire diagram for the whole project

 

Step 6: Building the mechanical part

Before we can talk about the programming of the motor, we need to build support for the feeder. Now is a good time to look into the mechanical part of the feeder. We’ll need the following material:

  • A metal plate (or a wooden board)- 35×25 cm
  • A bottle (or plastic container)
  • 2 x pieces of hard material for the food dispenser opening/closing

 

  1. Fix the bottle on the metal plate
    With a drill you need to make 4 holes on the metal plate, leaving space for the bowl (this distance depends on how tall your bowl/food container is. After that, you need to attach the bottle upside down with two wires connected to the plate.

 

automatic pet feeder

Figure 17: Bottle (food dispenser) attached to the metal plate using two wires

 

The “lock” system can’t stand in the air so we need to fix it with a piece of hard material. This provides a nice opening of the food dispenser. This also needs to be fixed with drills or tape it to the metal plate, so it doesn’t collapse in case you put a lot of food in the dispenser. As you can see in the picture below, the metal part is bent on the outer edge in order to prevent the misalignment of the lock.

 

automatic pet feeder

Figure 18: How to position the stand

  1. Placing the servo motor
    We need to attach the motor to the metal plate. I drilled into the metal plate to securely fasten the servo.Next, we need to connect to servo motor to the mechanical system that opens and closes the lock by sliding the cover. This is done by in the middle of the cover plate (near the outer edge) and connecting it to the motor using wires (Figure 17). You can use any material to do this, really. You just have to make sure the cover opens and closes as it’s supposed to.
automatic pet feeder

Figure 19: Finding the right place to drill a hole to wire to the motor

You’re pretty much done at this point. All you need to do is to fix the feeder wherever you wish, preferably in a safe place where your pet can’t demolish the feeder.

automatic pet feeder

Figure 20: Catching the motor near the stand

For better precision, it’s recommended that you don’t curve wire that connects the food dispenser cover to the motor because otherwise, it can diminish the force of the motor.

automatic pet feeder

Figure 21: Complete pet automatic feeder

 

automatic pet feeder

Figure 22: The final product


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#include <Wire.h>
#include <Time.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <Servo.h>
#include <EEPROM.h>     
#include <SPI.h>        
#include <MFRC522.h>
 
#define SS_PIN 10
#define RST_PIN 9
 
Servo myservo;
 
boolean match = false;        
boolean programMode = false;  
boolean replaceMaster = false;
 
int lightSensor = 0;
int distanceSensor=1;
int pos = 0;
int successRead;
 
byte storedCard[4];  
byte readCard[4];   
byte masterCard[4];
 
MFRC522 mfrc522(SS_PIN, RST_PIN);
 
void setup() {
 Serial.begin(9600);
 setSyncProvider(RTC.get);
 
 myservo.attach(9);
 
 Serial.begin(9600);
 SPI.begin();          
 mfrc522.PCD_Init();   
 if (EEPROM.read(1) != 143) {
   do {
     successRead = getID();           
   }
   while (!successRead);                  
 
   for ( int j = 0; j < 4; j++ ) {       
     EEPROM.write( 2 + j, readCard[j] );
   }
   EEPROM.write(1, 143);                 
   
 }
for ( int i = 0; i < 4; i++ ) {         
   masterCard[i] = EEPROM.read(2 + i);   
   Serial.print(masterCard[i], HEX);
 }
 
}
 
 
 
void loop() {
 
 int valueFromLightSensor = analogRead(lightSensor);
 
 int valueFromDistanceSensor = analogRead(distanceSensor);
 int distance= 4800/(valueFromDistanceSensor - 20);
 Serial.println(distance);
 
do {
   successRead = getID();  
  
 }
 while (!successRead);  
 if (programMode) {
   if ( isMaster(readCard) ) {
      programMode = false;
     return;
   }
   else {
     if ( findID(readCard) ) {
       
     }
     
   }
 }
 else {
   if ( isMaster(readCard)) {    
     programMode = true;
          int count = EEPROM.read(0);   
    
    
   }
   else {
     if ( findID(readCard) ) {
      
               if ((hour()>=8) && (hour()<=12 )){
                 if (distance>=20){
                     for(pos = 130; pos>=1; pos-=1)     
                       {
                        myservo.write(pos);              
                        delay (20);
                       }
                     for(pos = 50; pos < 180; pos += 1)  
                       {                                  
                         myservo.write(pos);              
                         delay(20);                       
                     }
                     
                 }
               delay(10000);  
               }
               
               
      if ((hour()>=12) && (hour()<=16 )){
                 if (distance>=20){
                     
                     for(pos = 130; pos>=1; pos-=1)    
                       {
                        myservo.write(pos);             
                        delay (20);
                       }
                     for(pos = 50; pos < 180; pos += 1)
                       {                                 
                         myservo.write(pos);             
                         delay(20);                      
                     }
                   
                     
                 }
               delay(10000);  
         }
         
 
if ((hour()>=0) && (hour()<=8 )){
                 if (distance>=20){
                     
                     for(pos = 130; pos>=1; pos-=1)    
                       {
                        myservo.write(pos);             
                        delay (20);
                       }
                     for(pos = 50; pos < 180; pos += 1)
                       {                                 
                         myservo.write(pos);             
                         delay(20);                      
                     }
                   
                     
                 }
               delay(20000);  
         }
         
 
         
        if ((hour()>=16) && (hour()<=20 )){
                 if (distance>=20){
                     Serial.println(distance);
                     for(pos = 130; pos>=1; pos-=1)    
                       {
                        myservo.write(pos);             
                        delay (20);
                       }
                     for(pos = 50; pos < 180; pos += 1)
                       {                                                           
 
myservo.write(pos);                                       
 
delay(20);                                          
 
  }
                     
                 }
               delay(10000);  
         }
               
               
               
               
     }
         }
 }
 
}
 
 
int getID() {
 
 if ( ! mfrc522.PICC_IsNewCardPresent()) {
   return 0;
 }
 if ( ! mfrc522.PICC_ReadCardSerial()) {  
   return 0;
 }
 Serial.println(F("Scanned PICC's UID:"));
 for (int i = 0; i < 4; i++) {  //
   readCard[i] = mfrc522.uid.uidByte[i];
   Serial.print(readCard[i], HEX);
 }
 Serial.println("");
 mfrc522.PICC_HaltA();
 return 1;
}
 
void readID( int number ) {
 int start = (number * 4 ) + 2;   
 for ( int i = 0; i < 4; i++ ) {    
   storedCard[i] = EEPROM.read(start + i);  
 }
}
 
boolean checkTwo ( byte a[], byte b[] ) {
 if ( a[0] != NULL )      
   match = true;      
 for ( int k = 0; k < 4; k++ ) {  
   if ( a[k] != b[k] )    
     match = false;
 }
 if ( match ) {     
   return true;     
 }
 else  {
   return false;      
 }
}
 
int findIDSLOT( byte find[] ) {
 int count = EEPROM.read(0);      
 for ( int i = 1; i <= count; i++ ) {   
   readID(i);               
   if ( checkTwo( find, storedCard ) ) {  
     return i;        
     break;         
   }
 }
}
 
 
boolean findID( byte find[] ) {
 int count = EEPROM.read(0);     
 
 for ( int i = 1; i <= count; i++ ) {  
   readID(i);            
 
 if ( checkTwo( find, storedCard ) ) {  
 
     return true;
     break;
   }
   else {   
   }
 }
 return false;
}
 
boolean isMaster( byte test[] ) {
 if ( checkTwo( test, masterCard ) )
   return true;
 else
   return false;
}

This concludes the first portion of this project. This device combines my passion for electronics and programming but also relieves me from having to feed my pet multiple times a day. This represents the perfect balance between a simple project and a practical invention for your home. In the next portion, we will look into advanced user interface where you can control feeding wirelessly…

Tiberia Todeila
Tiberia Todeila
Tiberia is currently in her final year of electrical engineering at Politehnica University of Bucharest. She is very passionate about designing and developing Smart Home devices that make our everyday lives easier.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Make a Smart Automatic Pet Feeder with Arduino UnoMake a Smart Automatic Pet Feeder with Arduino Uno
  • Smart Pet Feeder Part 2 – Feeding App with Speech RecognitionSmart Pet Feeder Part 2 – Feeding App with Speech Recognition
  • DIY Arduino Home Security System using ROHM Sensor Kit Part 1 – MechanicsDIY Arduino Home Security System using ROHM Sensor Kit Part 1 – Mechanics
  • DIY Arduino Home Security System using ROHM Sensor Kit Part 2 – Cayenne SetupDIY Arduino Home Security System using ROHM Sensor Kit Part 2 – Cayenne Setup
  • Latest Smart Home Products & Innovation Awards from CES 2017Latest Smart Home Products & Innovation Awards from CES 2017
  • From Fridges to Furniture: 4 Ways AI Is Coming to Your HomeFrom Fridges to Furniture: 4 Ways AI Is Coming to Your Home
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort