Introduction: DIY - IoT Pet Feeder
Hello to all cool people out there,
I'm back with another instructable after a freaking long time.This is my 3rd and thanks for your support.
This instructable is dedicated to all the proud pet owners out there.
Do u have a pet or an aquarium? or both?
Do u blame urself for not feeding them when u have gone out?
Then u have landed in the right place.
Even though i have no pets in my house,this idea came to me from friends who have pets.
This instructable enables u to feed ur fishes and dog/cat from anywhere in the world using the powerful and versatile IoT through ur smartphone.
If u face any hiccups during the i'ble,scroll to the last step where i have given few common problems that i encountered with its solution.
Step 1: Features
As humans,we look for features/specs for any product ,
So let me describe the features
note - from now on "pet" refers to both fishes and dog/cat
* lets you feed your pet from anywhere in the world.
* i have also designed a simple android app as an interface to control the proceedings.
* robust and small in size.
*Customisable ,to a extent on amount of food u want to dipense
Also a buzzer is set to buzz at a higher frequency (45KHz)as the dogs are sensitive to high freq.
Difficulty level for those who know to work with arduino environment is , i would say easy
and for others ,i would say intermediate.
Prerequisites - i have written this i'ble in such a way that even an newbie can do it without any knowledge in iot. Also,throughout the instructable i will be going through the concepts involved.So,if u just love ur pets,thats enough prerequisite.
Try taking the free arduino class provided by instructables here.Arduino ide is really versatile and its used by many other development boards as a programmer.And if u get the hang of it ,u can do many more stuff.Thats the reason i have suggested it.
If u want to gain some knowledge side by side ,U can enroll in other free classes provided by instructables here - instructables classes.
Step 2: Basic Idea to Implement
“Any fool can make something complicated. It takes a genius to make it simple.”
truly said by Woody Guthrie,we will first look at the basic idea to implement this
*we need two container for obvious reasons.(smaller for aquarium and bigger for dog)
*we need something that can dispense the food.(The dispensing dude)
*we need something that communicates with the boxes to tell the dispensing dude -"u have to dispense food now".(The brain dude)
*we need something that can listen to the brainy dude and react when the food is getting over(the reacting dude)
so this i'ble will be broken down into three steps and realizing the three dudes using physical and virtual technology.
**u can skip doing one of the feeder if u dont want to , as the i'ble will taking u through making both a fish feeder and a dog feeder**
Step 3: HARDWARE and SOFTWARE
Grab these stuff! all of them are readily available online and few of them are common stuff found in any hardware ,stationary shops
**For dispensing box i have used a cylindrical shuttle cock container
#Arduino motor driving shield(i am using adafruit motor driver shield ver 1)
#uart usb cable to program arduino
#micro usb cable to program nodemcu
#Jumper wires(M-M,M-F,F-F) NOTE - any motor driver works
#dc barrel jack (to connect battery to arduino)
#9V batteries(*2)(one for arduino and one for motordriver
*Tools and others
cardboard box, strong cardboard
hot glue/double sided tape , rubber bands.
normal handy tools like screw drivers,scissors
adafruit mqtt library-HERE
Also a working wifi router in ur house.
Step 4: The BRAINY Dude!
The brainy dude here is a free service called adafruit.io. This is an awesome site that every iot starter needs to visit!!
1st create a free account and log in.
follow the steps for creating the user interface for dispensing ur food.
* In the dashboard,press 'create a new block'
*choose toggle button
* name it as dog (as this will appropriately be used to feed ur dog)
* press 'create'
* now ur dashboard must be updated with the dog button.(don't panic if it is not created,adafruit
io is still in beta and may just face a hiccup few times)
*repeat the same once again but this time,name it as aquarium(as this will appropiately be used to feed ur aquarium)
* This is a very important step. Press 'your secret AIO key' and copy this code in a notepad or just write it down.We will use this code afterwards.
Now u are done with the 'brainy dude'
easy isn't it??????
Step 5: Communication
The communication between the brainy dude and the reacting dude happens by a protocol called MQTT.(Message Queuing Telemetry Transport).
In very simple words to explain how MQTT works is:
Consider YOUTUBE, It has feeds,subscriptions and publishes.
analogue to YOUTUBE,MQTT also has feeds,subscription and publishes
U can publish the sensor readings to the internet service like the way u publish something on YOUTUBE.
U can subscribe to any of the feeds in the internet service like the way u can subscribe something on YOUTUBE.
This is a simple way in which MQTT can be introduced and explained to a newbie rather than frightening him with all the technical stuff in the protocol.
Here,Adafruit.io acts as a broker,for all these subscriptions and publishes.
Also we will be subscribing to the feeds that we have set up earlier.
If u find this part interesting , u can learn about it by googling.
Step 6: The Reacting Dude!
now that we have the 'brain dude' set up.
We will go to the reacting dude
our nodemcu will be used to react to whatever the brain dude keeps sending.
There are many ways in which the nodemcu can be programmed and what we will be using is the most easiest and familiar to most of the techy people on this site,that is our arduino ide.
But first we need to do some tweaking to our arduino ide to make it work for our nodemcu
Follow these steps-how to set up ide for nodemcu
For detailed info and if you want to learn about nodemcu refer to this instructable.
There are many similar ones but this is damn good.Also, this one gave me a jumpstart in my nodemcu projects.
Step 7: The Reacting Dude! - Circuit Connections.
People who are using nodemcu for the first time,note that nodemcu is like an mini sized arduino uno with wifi shield with a output level of 3.3V.
But note that the pin numbers that has to be used in the program and the pin numbers used to physically connect is different.Note the table in the picture.
For example, if u have connected a led on pin no D7 of nodemcu,in arduino ide u should be writing it as pin 13.
Just note this,I have taken care of it in the main code,so that u need not worry about this.
Circuit connections are easy and straight forward as shown
D7 of the nodemcu -> A1 of the arduino uno
D6 of the nodemcu -> A0 of the arduino uno
D2 of the nodemcu -> buzzer
gnd of the nodemcu -> gnd of buzzer
Step 8: Dispensing Dude!
Dispensing dude consists of an container that acts as a storage for the food,dc motor to mechanize the dispensing action and an arduino uno with motor shield to control the motor.
Basically the output current offered by developing boards like arduino uno is in the order of 40mA and dc motors require a good 500mA to drive them, that is why the motor driving shield comes in.
the logic behind dispensing action is there are two layers of cardboard at the dispensing end,out of which one is fixed(half open) and the other is movable (half closed and half windowed).See the slow-motion video in next step for dispensing action
Using dc motor we rotate the movable board to windowed side to dispense.
As the fish food is needed in much smaller quality, instead of the window in the other half of the cardboard,holes are made.
Let the dispenser be a little tilted.
Make such an arrangement or customize it in any way unless the mechanism is taken into account.
*cut out the cap of the cardboard box as shown
*cut out one more cardboard piece as shown
*connect the shaft of ur dc motor to the cardboard piece as shown
*using hot glue or double sided tape ,stick the dc motor to the cut cap and secure it with rubber bands .
*make it inclined at least 60 degrees
For making the aquarium feeder,repeat the same but take a saller container and make holes in the cardboard piece
Step 9: Do Some Research Before Main Code!
Before digging into the main code , u have to play around the arduino code for sometime to get the dispensing mechanism going.
Assuming no food has been filled in the feeder,connect the dc motor to M1 channel of the motor driver.
Download this code and open it in arduino ide.
keep changing with the delay by giving different values to achieve close to perfect dispensing action.
By dispensing action i mean the motor rotates revealing the windowed part of the cardboard ,there by allowing the food to come down by the action of gravity.
(if u are finding it difficult to tune it by changing only the delay,try changing the motor.setSpeed(100);)
Also make FORWARD as BACKWARD if the motor is going the other way.But fix the motor connection.
remember this value as TIME_PERIOD1 as we need to update this in the main code.
Repeat the same for fish feeder and name it as TIME_PERIOD2.
NORMALLY TIME_PERIOD1 AND TIME_PERIOD2 WILL BE LESS THAN 1000 (IN mS)
Step 10: Main Code
Download the two codes and open them in arduino ide
One code is for nodemcu and another is for arduino uno
Remember the TIME_PERIOD1 and TIME_PERIOD2? update these values in arduino's code.
Before u upload the code into the nodemcu,carefully edit few things in the code
CONNECT DOG FEEDER MOTOR TO CHANNEL 1 OF THE MOTOR DRIVER
CONNECT FISH FEEDER MOTOR TO CHANNEL 3 OF THE MOTOR DRIVER
Remember the AIO key? update ur adafruit.io usename and AIO key
Also,update ur router/home wifi ssid and password.
Step 11: YaY! Run Everything!
After downloading and uploading the two codes
*connect battery jack for arduino and power it up.Also power the nodemcu with 3 V(not 5V ).
*Tilt the feeder to about 60 degrees if no done earlier.
*Connect the two motors to shield if not connected after testing in earlier steps.
*Download my android app from HERE.
*install it and switch on mobile data,and open the app
*click "sign in to join the open beta" and log in.
*U will see the earlier created dog and aquarium buttons.
*Whenever u want to feed ur pet,press the corresponding button.
*Refill it whenever required.
NOTE - POWER OFF THE ARDUINO WHEN U ARE TRYING TO RESET THE NODEMCU AND POWER IT ON ONLY AFTER U HAVE RESET IT.
Step 12: Common Problems Faced and How to Debug?
As a developer it is common to face problems in the project.
I have gathered a few of the problems,that i was encountered while i was doing it myself.I have also included the solution.
*my cardboard was devastated due to the weight .
choose a thick cardboard.
*Upload error while using shield.
try to not touch the shield with the UART port of arduino
*Problem in motor and motor direction .
This is the major problem i had to deal with hence i have dedicated a separate step to deal with this. Every problem associated with motor can be debugged by experimenting with the values passed to the functions
I stress upon perfecting this part.
* Problem with programming nodemcu with arduino ide even after setting everything up.
check whether nodemcu is selected as board
check if drivers are installed for nodemcu
I would suggest to first do the arduino part(dispensing part) first and move ahead to nodemcu(reacting dude)
* donno 'what is going wrong'? then figure out 'where is it going wrong?'
Simply add Serial.println statements to print "function called",wherever any function needs to be called
and "something connected", when something needs to be connected.
Hope u found it helpful!
We have a be nice policy.
Please be positive and constructive.