Introduction: IOT Pet Feeder Using the Blynk Mobile App & an ESP8266 Module
This project uses an ESP8266 WIFI board via the Blynk Mobile app to trigger a measure of dry food for your cat or in a suitable outdoor enclosure Koi Carp pellets for your fish pond.
Only a few basic electronic components are used and any wiring is kept to a minimum.
Further details can be found on my web site here Pet Feeder Web Page
There are many Instructables on using the ESP8266 board just search this site or try this Intructable
Two old mobile phones are used as a video servers one monitors the feeding via the Blynk app and another is used as a general IP cam using IP Webcam Pro. The feeder uses the hopper from a cereal feeder and has a stepper motor attached to the feed flaps to rotate them an exact dose of dry food.
Although the hopper can feed 34 measure of food we would only really use this if we were away for the weekend. We also have neighbours/friends and family who could look in on the cat if there are any problems. Our cat has access to the utility room via a cat flap and I use a 2nd old mobile as a monitor to check she is coming and going OK.
34 individual feeds
Thermal fused for safety
Designed to be hidden away in a cupboard
Manual feed button
Start Time and Date
Last Fed Time and Date
Individual display of Manual, Timer and App feeds
Manual feed from App button
Feed bowl view from remote camera
Timer On Off control
Display of 1 st and 2nd timer feeds
Feed Hopper food level indicator
Step 1: PET Safety
Using this feeder you could probably feed your cat in an emergency for a couple of weeks (my cat has a cat flap to the garden so can come and go as she wants) but this is not recommended.
I only really use it if I will be away for the weekend and then I can always call a neighbour to look in on my cat if I have any concerns.
I also use a couple of video cameras, one to keep an eye on the feeder via the Blynk app and uses the RTSP Camera Server from Google play and one to monitor the room where my cat can access from the garden.
The cameras used to monitor the cat's room is an old mobile phone that uses an app called IP Webcam Pro and it is is available from the Google Play store. IP Webcam Pro turns your old mobile into an IP cam so you can access the camera from the internet to monitor your PET on video and audio.
The camera is mounted on a cheap car phone mount and is powered over it's charger lead.
Pic 1 IP Cam Pro running on an old S4
Pic 2 Once running and port forwarding enabled the video feed can be viewed from the internet on your mobile, tablet or laptop.
Pic 3 Make sure your pet has enough water while you are away by using one of these water dispensers.
Step 2: Parts List
Timber off cuts
2 Old mobile phones
Motor Shaft Coupler
ESP8266 WIFI board
NEMA 17 Stepper motor with integrated planetary gearbox with a 26.85:1 gear ratio
Stepper motor mounting bracket
LM2596 step down voltage converter module
Dual H Bridge Stepper Motor Drive Controller Board Module
Thermal Fuse EYP28H115
Fuse Holder with fuse
2 x capacitor and 1 resistor see schematic for details
Vero board see layout for details
I used an old Samsung S3 and S4 for this project. I had these laying around. The S4 has a cracked screen but as it is on used as an IP camera it does not matter. The feed bowl camera is powered from the feeder and the room monitor camera is powered from it's mains charging plug so if the phone batteries are naff it doesn't matter.
Pic 1 shows the S3 monitoring the cat bowl using the RTSP Camera Server from Google play
Pic 2 shows the S4 monitoring the cat's room using IP Webcam Pro also available from the Google Play store
Step 3: Design
The feeder is designed to be fitted in a kitchen base unit. Any size down to around 300mm width should be fine. Using a short length of standard 68mm down pipe cut through the base of the cabinet and a 112.5° Offset Bend to allow the pipe to exit the cabinet through the plinth and into the cat/dog bowl. Once the feeder operates gravity will take the feed down the pipe and into the bowl.
The feeder frame is made from offcuts of timber I had laying around in my workshop. A standard cereal dispenser is fitted to this wooden frame and a stepper motor is attached to the drive shaft instead of the manual control handle.
If you are feeding fish outside then a waterproof cabinet will need to be constructed on the side of the pond.
Step 4: Construction
Pic 1 The feed hopper parts are obtained from a Wall Mounted cereal Dispenser available from Ebay.
You can get them in singles doubles or triples. I ordered a triple so I had spare parts in case I damaged anything in the design/build process.
If you use the same hopper as me then you know they are easy to dismantle and re-build into this project.
Pic 2 and 3 Disassembly of the Cereal Dispenser
To take apart the old dispenser remove the dispensers from the wall mounting brackets. Then remove the brackets from the wall mount. The brackets are fixed to the plastic wall mounts by two self tapping screws, remove them all.
Pic 3 The brackets can then be re-used in the final project.
Note when fixing the brackets to the new feeder use flat head screws and don't over tighten or the plastic on the brackets could break away.
Pic 4 The old hand lever is pulled out of the dispenser with the plastic D shaft.
Pic 5 The plastic D shaft is then pulled out of the hand lever ready to be fixed to the motor coupler. The plastic handle is not used in this project.
Pic 6 Build the wooden mounting frame using timber offcuts. The sizes are shown as a guide only and the height especially can be reduced if required.
Pic 7,8,9,10 & 11 Show construction details. Note the plastic hopper bracket is fitted just below the wooden mounting bar to allow the connection of the drive shaft to the stepper motor.
Pic 12 Shows the stepper motor bracket. This is bolted to a small piece of timber screwed to the rear of wooden mounting bar. Detail in pics 8 & 11.
Pic 13 Shows the 2 plastic project boxes mounted on the wooden legs of the frame. The box on the left contains the power and stepper motor driver modules and the box on the right contains the ESP8266 module and manual feed switch.
Step 5: Electronics
Power to this project is from my common 12volt power supply. This supply can deliver 12volts at 10 amps so I always use fuses in my projects. I have also used a thermal fuse strapped to the stepper motor. This is probably overkill but this fuse will shut off power to the stepper motor and the other project components if it overheats.
The measured current draw with motor running and mobile phones running as IP servers is 250mA so you can easily power this project from a wall mounted power module if required. Depending on the safety devices in your chosen power module you may or maynot need fuses.
I have used modules where possible to keep the design and construction of this project as straight forward as possible.
Veroboard is used to mount some of the components/modules there is no PCB layout or design. I have used a fuse on the main 12v input to this project. The power cable is rated at 2 amp and I have used a 1 amp fuse. I have also fitted a thermal fuse attached to the stepper motor housing as as additional safety device.
ESP8266 module Pic 1
The ESP8266 module contains a CP2102 chip to allow direct programming via Arduino IDE from a Windows PC or Mac.
This module connects to the Blynk server via your WIFI router. The module then controls the stepper motors and provides feedback to your mobile Blynk app.
Chip Module: CP2102
Working temperature: -40 ℃ ~ + 125 ℃
Power input: 4.5V ~ 9V (10VMAX)
USB-powered Current: continuous transmission: approx. 70mA (200mA MAX)
Size: approx. 45 x 25 x 6mm/1.77 x 0.98 x 0.23'' Weight: approx. 6g
Voltage Regulator Module LM2596 Pic 2
Power for the L298N, ESP8266 module and the Samsung S3 mobile phone is delivered by a LM2596 DC to DC converter.
The 12v feed used by the stepper motor is dropped down to 5volts. The circuit uses 160mA with the mobile On (display off) and the video server app running. This rises to 250mA wit the the stepper motor running.
Voltage Regulator Module LM2596Specifications:
Rectification mode:Non-synchronous rectifier
Module property:Non-isolation buck
Output current:Rated current is 2A,maximum 3A(Additional heatsink is required)
Conversion efficiency:92%( highest )
Output ripple:30mV( maximum )
Voltage regulation:± 2.5%Load regulation:±0.5%Dimension:43mmx21mmx14mm(LxWxH)
Motor Drive Controller Board Module L298N Dual H Bridge DC Stepper Pic 3
L298N as main chip
High working voltage to 46v,large current can reach 3A MAX and continue current is 2A, power to 25w.
Can drive one 2-phase stepper motor, one 4-phase stepper motor or two DC motors. Built-in 78M05,get power from drive power, however, when drive power is over 12V, use the external 5v power as power supply.
Large capacity filter capacitance, back EMF protection diode, more stable and reliable.
Specification: Double H bridge drive Chip: L298N (ST NEW) Logical voltage: 5V Drive voltage: 5V-35V Logical current: 0mA-36mA Drive current: 2A(MAX single bridge) Max power: 25W Size:43 x 43 x 26mm(LxWxH)
Note: This module has a built-in 5v power supply, when the driving voltage is 7v-35v, this supply is suitable for power supply DO NOT input voltage to +5v supply interface, however leading out 5v for external use is available. When ENA enable IN1 IN2 control OUT1 OUT2 When ENB enable IN3 IN4 control OUT3 OUT4
Step 6: Module & Board Layouts
The modules are housed in Perspex topped boxes
Pic 1 The LN298 H Bridge stepper motor module and DC to DC converter in 1 box
Pic 2 The ESP8266 module is housed in the 2nd box
Pic 3 2nd box with ESP8266 module removed to show Vero Board layout
Pic 4 Vero Board Layout of the Fuse Board
Pic 5 Rear of Fuse Board
Pic 6 Cutaway shows position of fuse board above the stepper motor.
This allows the thermal fuse to be physically connected to the stepper motor (clamped in place by twisted copper wire)
Step 7: Stepper Motor
Pic 1 This is a short geared NEMA 17 Stepper motor. It has an integrated planetary gearbox with a 26.85:1 gear ratio, the resolution reach 0.067°step angle.
It's a good solution in applications that need very low rotation speeds and/or lots of torque. I tried an identical motor without the gearbox and it was OK until I added the pet food into the hopper then it jammed.
Pic 2 Shows the stepper motor dimensions.
The stepper motor is connected to the feeder drive shaft by a drive coupler Pic 3
Couplers come is most sizes, my motor has a 6mm shaft and the feeder has a 8mm shaft.
Pic 3 shows the stepper motor mounting bracket. Make sure your bracket has the extra inner holes for mounting to the planetary gearbox.
My Stepper Motor Specs
Manufacturer Part Number17HS13-0404S-PG27
Motor Type Bipolar
StepperStep Angle(W/O Gearbox) 1.8°
Holding Torque 3NmRated
Recommended Voltage 12-24V
Gearbox Type Planetary
Gear Ratio (Exact Gear Ratio)26 + 103/121
Backlash at No-load<=1°
Max.Permissible Torque 3Nm(425oz-in)
Moment Permissible Torque 5Nm(708oz-in)
Shaft Maximum Axial Load 50N
Shaft Maximum Radial Load 100N
Step 8: Schematic
The schematic is very simple and there is not too much wiring to do.
12v is fed to the LM2596 voltage module and stepper motor 12v input via a 1amp cartridge fuse and a 2a Thermal fuse rated at 115°C.
The LM2596 voltage module provides regulated 5v to the ESP8266 module, the stepper motor module 5v input and also 5v to power the feed bowl monitor camera.
The ESP8266 module has a manual feed switch connected to it. The input is held low via a 10K resistor to 0v when the switch is not operated.
D1 to D4 on the module connect to the Dual H bridge stepper motor module.
The Dual H bridge stepper motor module Out 1 to 4 connect to the stepper motor connector.
The Dual H bridge stepper motor module has a built-in 5v power supply, this is not used and is disabled using the link on the module.
When ENA enable IN1 IN2 control OUT1 OUT2 When ENB enable IN3 IN4 control OUT3 OUT4. Enable both these using the links on the module.
Step 9: The Blynk App
Blynk was designed for the Internet of Things. It can control hardware remotely, it can display sensor data, it can store data, visualize it and do many other things.
See the Official "how Blynk Works" page for more details.
Pic 1 The main app page shows details of each Blynk widget
Pic 2 On return from power loss or on restart the Start Date and Time and all count are reset to 0 (the Hopper count returns to 34). The Last Feed Date and Time however do not reset as it is important to know when your pet was last fed.
Pic 3 The adjust button is used to calibrate the feeder. Each time the button is pressed the feeder rotates a few degrees to set the feeder flaps in the correct start position for feeding.
Pic 4 Feeding from the Blynk App
The animation shows how the app looks when a feed is made from within the app. On pressing the feed button there is a short delay while the stepper motor rotates the feeder flaps. Once the stepper motor stops the ESP8266 module sends a signal back to update the "App Feeds" count ,take a feed off the current Hopper value and update the "Last Time & Date Fed" . The bar counter drops 1 feed level as well.
Pic 5 Clone this project
Log in to the Blynk app and press QR button in Projects gallery. After scanning the the QR code Pic 5 a new Project will be created, all the widgets, settings, layout will be cloned. You will need enough Energy Balance to clone my Project.
Pic 6 Shows the Blynk Widget settings used for this project.
Pic 7 Shows the pin numbers for each widget
Step 10: Blynk Video Stream Setup
Pic 1 Setting up the Video Stream on Blynk can be a bit tricky.
The Blynk help guide says" Simple widget that allows you to display any live stream. Widget supports RTSP (RP, SDP), HTTP/S progressive streaming, HTTP/S live streaming. For more info please follow official Android documentation. At the moment Blynk doesn’t provide streaming servers. So you can either stream directly from camera, use 3-d party services or host streaming server on own server (on raspberry for example)" I have tried many different I/P cameras but could not get them to work. I have opted to use an old Samsung S3 as a video server using an app called RTSP Camera Server from Google Play. the icon can be seen in Pic 2.
Once setup I was able to get video and sound onto my Blynk Video Streaming Widget. The settings are crucial as the video will only display if the setting are exactly right. The sound seems to play on most settings.
The table below shows the settings that worked on my setup S3 camera server and S7 running Blynk. The encoder setting will probably differ from phone to phone but try h264 if that is an option on your phone.
RTSP Camera Server Settings
Frames per Second15
Battery info On
IP Address Off
Time Stamp On
Bitrate 240 Kbits/s
Keyframe Interval 3 sec
Enable microhone On
Sampling Rate 8000
Enable recording On
RTSP Port 5560
HTTP Playlist Port 8094
Blynk Video Streaming Settings URL Address rtsp://dyndnshostname.dyndns.org:rtsp port number/camera
To test locally rtsp://camera IP address:8094/camera Set RTSP and HTTP Playlist Port to suit your network On your Hub/Router set port forwarding for your camera/phone to the RTSP Port (or HTTP Port if testing locally) Don't forget to set your Dyndns Host name and Dyndns password in the settings as well.
Step 11: Code
I have included the code for this project.
You will need to add your WIFI credentials and Blynk auth token and upload it to the ESP8266 WIFI board.
We have a be nice policy.
Please be positive and constructive.
Thanks for putting this together, can't wait for all the parts to come.
Couple things that need clarification. Is there a way to connect a physical sensor - Ultrasonic or IR sensor, to gauge hopper level more accurately? The reason I'm asking is that I'm planning to modify the dispenser I have below and not buy another.
Does the timer values stored in the ESP memory or phone?
Can it be connected to Homebridge?
Hi I don't think you would need a physical sensor to measure the hopper level. Once your system is setup fill the hopper to the top and count how many feed it takes to empty. Do this a few times and then take the average and use this for the hopper setting on the Blynk app.
You could always check the hopper level on the webcam if you have it connected.
The timer values are on the phone and sent via the Blynk app.
I am not sure what Homebridge is or how it works so I can't help you on that one.
Thank you for posting, I want to try this. I am a beginner for a lot of this so apologies for the questions. If they are too below the level, then disregard: 1. Never used a veroboard, is the "Pic 3 2nd box with ESP8266 module removed to show Vero Board layout" show basically what the soldering side of the veroboard would have setup? 2. I understand the cartridge fuse and thermal fuse, but the module on the fuse board, what is this referring to? I attached a picture circling your fuse layout. Is this 12V in? Also do you have any recommendations for what type of loose wiring to use for all the connections?
Thank you for your help.
1 Yes that is the same box with the ESP8266 removed
2 The standard and thermal fuse are on the 12 volt input. The 12 volt input goes into the big green connector then through the fuse then through the thermal fuse. The thermal fuse is strapped to the outside of the motor as protection in case it overheats.
I use 0.5mm solid wire for the main wiring. Then 2 amp multi core wire for the output to the motor from the H bridge (I think the motor has wire already attached) and also the 12v feed to the H bridge.