logo-mobile

ROHM

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

Arduino

Make a Smart Automatic Pet Feeder with Arduino Uno

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at May 20, 2022
Categories
  • Arduino
Tags
  • Arduino
  • arduino uno
  • automatic pet feeder
  • smart devices
  • smart home
automatic pet feeder

Originally published by Dec 31, 2016

automatic pet feeder

Table of Contents

  1. Introduction
    1. Hardware
    2. Software
    3. Tools
  2. Step 1: Connecting the light sensor
  3. Step 2: Adding the distance sensor
  4. Step 3: Determine the real time
  5. Related Articles

Do you ever get lazy feeding your pets? Sure, we love our pets, but just sometimes we wish we could make it automatic. Today we’ll make a smart automatic pet feeder using Arduino Uno! The key components of the project include an RTC module to track time and manage feeding schedule, distance sensor to monitor food level, light sensor to distinguish day/night, and RFID to identify our pet. Let’s get started!

Hardware
  • Arduino Uno
  • Light sensor TEMT6000
  • Distance Sensor Sharp GP2Y0A21YK
  • RFID MFRC522
  • Buzzer
  • Motor SG90
  • RTC DS1307
Software
  • Arduino IDE
  • https://github.com/todeilatiberia/AutomaticFeeder
Tools
  • Bottle (or any food container)
  • Metal Plate 35×25 cm

Step 1: Connecting the light sensor

We’ll be using SparkFun Ambient Light Sensor TEMT6000 to detect if it’s Day or Night. It’s important to distinguish the two in order to determine when and how often we release the food. TEMT6000 light sensor has 3 pins: SIG; GND; VCC. Wiring this sensor to the Arduino Board is quite simple: the VCC to the 5V pin; GND to board’s GND pin and the SIG needs to be connected to an Analog Input. I’ve chosen the A0 pin. The output pin SIG works as a transistor, so the greater the light applied near the sensor, the higher the voltage is on the output of the pin.

The graph below shows a relationship between the current and illuminance perceived by the TEMT6000. Illuminance is a measure of total luminous flux (i.e. visible light emitted by a source, measured in lm) divided by an area in m². Generally, 1 illuminance (Ix) = 1 Im/m². The TEMT6000 recognizes typical human visible spectrum with light wavelengths in the range of 390–700 nm.

TEMT6000 Datasheet: https://www.sparkfun.com/datasheets/Sensors/Imaging/TEMT6000.pdf?_ga=1.236184897.1967866376.1482950454

Figure 1: Collector light current vs Illuminance / ©Sparkfun

Figure 1: Collector light current vs Illuminance / ©Sparkfun

 

 

Figure 2: Wire diagram of TEMT6000 light sensor and Arduino Uno

Figure 2: Wire diagram of TEMT6000 light sensor and Arduino Uno

 

Figure 3: Connection between TEMT6000 and Arduino Uno

Figure 3: Connection between TEMT6000 and Arduino Uno

Because this sensor is connected on an analog pin, the maximum value is 1023 due to the 10 bit resolution of the analog-to-digital converter. So for example, when the sensor is subjected on the highest light from my phone flash the value read from the sensor was around 1023.

Figure 4: Arduino serial monitor showing the maximum values of the sensor

Figure 4: Arduino serial monitor showing the maximum values of the sensor

The code for the light sensor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int lightSensor = 0;
 
void setup() {
 
 Serial.begin(9600);
 
}
 
 
 
void loop() {
 
 int valueFromLightSensor = analogRead(lightSensor);
 
 Serial.println(valueFromLightSensor);
 
 
 
 delay(1000);
 
}

 

Step 2: Adding the distance sensor

To measure the distance I’ve chosen an analog sensor (Sharp GP2Y0A21YK) because it has the best results when compared to other distance sensors. The working principle of reflection is as follows: a signal is emitted and when it finds an obstacle in the way, it sends back also a signal  (a voltage value that varies depending on how near/far is the obstacle); this voltage needs to be converted into distance.

The position of GP2Y0A21YK will be above the food container, measuring the emptiness of the bottle (i.e. food level) before initiating the automatic feeder function. With this distance sensor, the system will detect if in the food container (or bottle) is full or empty. The ways this program will work:

  1. For a small distance: the automatic system will add only a small portion of food;
  2. For a medium distance: your pet will receive a half of portion of food;
  3. For a large distance: the automatic system will release full portion of food.

Here the distance implies the value from the place you mounted the distance sensor to the bottom of the food container. Because the range of the sensor is 10-80 cm, the sensor needs to be above the top of the food container with 10cm in order to read the correct value of the distance.

How to determine the best-fit line for the sensor:

From Pololu.com

The relationship between the sensor’s output voltage and the inverse of the measured distance is approximately linear over the sensor’s usable range. You can use this plot to convert the sensor output voltage to an approximate distance by constructing a best-fit line that relates the inverse of the output voltage (V) to distance (cm). In its simplest form, the linearizing equation can be that the distance to the reflective object is approximately equal to a constant scale factor (~27 V*cm) divided by the sensor’s output voltage. Adding a constant distance offset and modifying the scale factor can improve the fit of this line.

 

 

Figure 5: The characteristic of the distance sensor / ©Pololu.com

Figure 5: The characteristic of the distance sensor / ©Pololu.com

 

From Phidgets.com

Based on “typical values” from Sharp, the formula to translate SensorValue into Distance (the formula is only valid for a SensorValue between 80 to 500) is:

Distance (cm) = 4800/(SensorValue – 20)

This sensor can find the distance to objects that present a very narrow edge such as a wall at a very sharp angle.

Note: The output of this sensor will vary from unit to unit, and based on the characteristics of the target (reflectance, size, direction of motion, object alignment).

 

 

Figure 6: Wire diagram of Sharp GP2Y0A21YK to Uno

Figure 6: Wire diagram of Sharp GP2Y0A21YK to Uno

 

automatic pet feeder

Figure 7: Connection between Sharp distance sensor, TEMT6000, and Uno

 

The code:

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
int lightSensor = 0;
 
int distanceSensor=1;
 
 
 
void setup() {
 
 Serial.begin(9600);
 
}
 
 
 
void loop() {
 
 int valueFromLightSensor = analogRead(lightSensor);
 
 Serial.print("Light Value= ");
 
 Serial.print(valueFromLightSensor);
 
 Serial.println("");
 
 Serial.print("Distance Value= ");
 
 int valueFromDistanceSensor = analogRead(distanceSensor);
 
 int distance= 4800/(valueFromDistanceSensor - 20);
 
 Serial.print(distance);
 
 
 
 delay(1000);
 
}

Step 3: Determine the real time

The time will be determined using the RTC DS1307 model. A real time clock is a system whose function is to determine real time. This circuit works on the base of a crystal oscillator with a frequency of 32.768 kHz. The principle is similar to the watches. An electronic oscillator function based on mechanical resonance of crystal vibration creates a precise frequency. This frequency is used for tracking date and time from the computer.

It’s a practical module because it has a battery that provides continuity even when the system is shut down.

 

Figure 8: Wire diagram for RTC module

Figure 8: Wire diagram for RTC module

 

 

Figure 9: Connection between the RTC, Sharp distance sensor, TEMT6000, and Uno

Figure 9: Connection between the RTC, Sharp distance sensor, TEMT6000, and Uno

For an optimal usage, it is necessary to add 2 libraries for the module to work.

These 2 libraries are found on my https://github.com/todeilatiberia/AutomaticFeeder:

  • DS1307RTC
  • Time
  • Wire (this library is already included in the Arduino IDE and can be easily added)

We will run a test code in to check the module. When we upload the program to Arduino board, the serial monitor will show the current date and hour. These 2 libraries have an example code for finding date and hour, called “SetTime”.

Finding SetTime:

Click on Arduino IDE → File → Examples → DS1307RTC → SetTime

Figure 10: Finding SetTime on Arduino IDE

Figure 10: Finding SetTime on Arduino IDE

 

In Figure 11, you will see that the module works correctly as the current date and time are displayed.

Figure 11: Current date and time displayed correctly

Figure 11: Current date and time displayed correctly

For our application, we will only measure hour. To do this we need to extract from RTC module the exact hour. This will be done with the simple function of the RTC called “setSyncProvider(RTC.get)”. After implementing this function, you will be able to see the hour in serial monitor along with values from distance sensor and light sensor.

 

The code:

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
#include <Time.h>
 
#include <Wire.h>
 
#include <DS1307RTC.h>
 
 
 
int lightSensor = 0;
 
int distanceSensor=1;
 
 
 
void setup() {
 
 Serial.begin(9600);
 
 setSyncProvider(RTC.get);
 
}
 
 
 
 
 
void loop() {
 
 int valueFromLightSensor = analogRead(lightSensor);
 
 Serial.print("Light Value= ");
 
 Serial.print(valueFromLightSensor);
 
 Serial.println("");
 
 Serial.print("Distance Value= ");
 
 int valueFromDistanceSensor = analogRead(distanceSensor);
 
 int distance= 4800/(valueFromDistanceSensor - 20);
 
 Serial.println(distance);
 
 
 
 Serial.print("Hour= ");
 
 Serial.println(hour());
 
 delay(1000);
 
 
 
}

 

Figure 12: Hour displayed

Figure 12: Hour displayed

 

Continue Reading >

Related Articles

Once you’ve built your smart automatic pet feeder, explore more of our guides to discover more brilliant Arduino projects:

  1. Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)
  2. Keep cats at bay with an auto-trigger water spray and the power of an Arduino Uno
  3. How to Find Out When Your Plants Need Watering with a Soil Sensor
  4. An Arduino Plant Monitoring & Watering Device
  5. How To Make Smart Home Electronics: A Smart Mailbox
  6. Top 6 DIY Projects You Can Do to Expand Your IoT Projects
DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)
  • 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 2 – Cayenne SetupDIY Arduino Home Security System using ROHM Sensor Kit Part 2 – Cayenne Setup
  • DIY Arduino Home Security System using ROHM Sensor Kit Part 1 – MechanicsDIY Arduino Home Security System using ROHM Sensor Kit Part 1 – Mechanics
  • Latest Smart Home Products & Innovation Awards from CES 2017Latest Smart Home Products & Innovation Awards from CES 2017
  • IoT Tech Expo North America 2016: The Smart Living of IoT (Smart Homes, Cities and Cars)IoT Tech Expo North America 2016: The Smart Living of IoT (Smart Homes, Cities and Cars)
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