The idea: building an automatic food (two types of food) and water dispensing system for my Guinea pig using an Arduino Mega 2560 board.
- 1 x Arduino Mega 2560
- 1 x motor shield – I used an old version of Adafruit Motor Shield v1.2, but any other motor board will do the job as long as you can connect 2 x servo motors and 2 x stepper motors to it
- 2 x servo motor
- 2 x stepper motor
- 1 x relay
- 2 x water level sensor – I used this type http://g02.a.alicdn.com/kf/HTB1WoDUHVXXXXaaXFXXq6... but any other model will do
- 1 x RTC module – I used this type http://www.arduiner.com/2179-thickbox_default/ds1...
- 3 x big push button
- 5 x small push button
- 1 x 7 segments 4 digits LED display – I used this type http://thomas.bibby.ie/wp-content/uploads/2015/10...
- 2 x NC solenoid valve
- 1 x air suction pump
- 1 x water pump
- Soldering iron, wires, bolts and nuts, plywood, pliers, handsaw, plastic containers, etc.
- Silver (Ag) rods used as water level probes
- Hot glue gun
- PCB for building the Relay, RTC, water sensors, LED display and push buttons modules
- Guinea pig
UPDATE - 23.05.2016
Having tried different water bottle types and manufacturers, no matter what I did the water kept dripping, as the nozzle is not tight enough. Also, when my Guinea pigs knocked the bottle, and in turn that activated the relay, due to EMI (Electro Magnetic Impulse) interference, sometimes the Arduino board would get "confused" and feeding would activate at the wrong time. The RTC would get messed up as well, and the displayed time was wrong.
The improved version (as seen in the short video above)...
- Removed the high and low water level sensors
- Removed the mechanical relay
- Removed the water pump
- Removed the air suction pump
- Removed the manual water dispensing button
- Removed the second food dispensing button
- Added a knock (vibration) sensor - http://www.aliexpress.com/item/Free-shipping-Norma...
- Added an optical relay - http://www.aliexpress.com/snapshot/7371934648.html...
The water goes from the water tank to the bottle nozzle, with the NC solenoid valve in the middle (controlled by the optical relay). The vibration sensor will activate the optical relay which will open the solenoid valve accordingly. I had no problems with water dripping since.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
There are two types of food I want to dispense, once a day, at a certain hour (9am by default), from some plastic containers. The Real Time Clock (RTC) module will keep the current time, which will be displayed on the LED display. If required, either food can be dispensed manually by pushing their respective button.
The food is dispensed with the help of 4 motors (2 for each type of food): 2 x stepper, 2 x servo. The motors are driven by the Adafruit Motor Board, which is supplied with 8v from a separate power adapter.
The water level (LOW level) will be checked once a day, at the same time as the feeding time. If necessary a relay will activate a valve system that will fill the water bottle up to the HIGH water level, using the water stored in a plastic container. A pushbutton will allow to manually topping up the water – up to HIGH level if button is released, or continuously and ignoring the HIGH level sensor reading while the button is being kept pressed.
The Water valve system
The water bottle works on the principle of gravity and vacuum, which will prevent the water from dripping thru the nozzle at the bottom. Therefore no air should get into the bottle thru the insertion points of the sensors or the water inlet (water pump). When the water pump is active, the existing air in the bottle should be allowed to escape at the top, so that no pressure is applied onto the nozzle forcing the water to drip. An air vacuum pump will suck the air at the top, basically creating some negative pressure which will prevent the water from dripping thru the nozzle. When the water filling is not active, two normally closed (NC) valves will make sure that no air will get into the system (1 valve on the water inlet, and 1 valve on the air outlet).
Therefore the water valve system is composed of 2 x NC valves, 1 x water pump, 1 x air suction pump, all connected to the same relay, and supplied with 12v from a separate power adapter.
Building of the enclosure
I’m not an engineer, so I can not give very good advice on how to actually build the actual enclosure. It took me a couple of days of coming up with a system, which took me about a week to build, only to realise that it wasn’t physically working. Like... at all :-)
I only got it working as it is after a couple of trial and error sessions (with a lot of cursing...), and thinking back I could say that I have the prototype version 5. Or even 6. I don’t even want to think about the money I spent on different stuff that I’ve ended up not using or breaking. So again, I can not emphasise more: when it comes to engineering, don’t listen to my advice. Nevertheless, here are some photographs I took during the construction of the last (still working) version.
However, the idea is: when it’s feeding time, a stepper motor placed inside the plastic container, at the bottom near the hole that will allow the food to drop, will spin for some time, only to make sure that the food isn’t lodged (being prevented from dropping). Then the servo motor will move the flap (open) for some extent, allowing the food to drop into the white plastic hose, which will direct the food into the Guinea pig’s food tray. After the set time the servo motor will move the flap to closed position.
Note: if you’re wondering about the funny shape of the dropping holes (and plastic flaps), it’s got to do with the shape / size of Guinea pig’s food. After a few trial and error sessions I’ve noticed that this shape will help the food not getting blocked. Again, don’t take this as written in stone!
The water level sensors
I’ve used two water sensor modules. You will find that the metal strips on the water level module are connected to two different points on the main module board. I cut the sensors down the line (see the picture), and then on the remaining two contacts I soldered some wires which I connected to some silver (Ag) rods, used as sensor probes. The reason for using silver rods is that I wanted to reduce the oxidation of the rods due to electrolysis - https://en.wikipedia.org/wiki/Electrolysis
Obviously I need to know when the water level is at LOW level to start filling the water bottle, and again I need to know when the water has reached the HIGH level, so that the relay will disconnect the power to the valve system and stopping the water filling process.
The LED display
By default the LED display will show the current time from the RTC module. By pressing the appropriate buttons the time will be adjusted (hour and minutes). Pressing the middle button will toggle the display between showing the current time and the feeding time – the latter can be adjusted as well (by hour).
Connecting the pushbuttons
Connecting the RTC module
Connecting the relay
Connecting the motors
Everything else is history!
In the next (and last) step you will find the “schematics” of how to connect the devices (to which Arduino Mega 2560 pins), and some websites where you can find more details.
And of course, the code, which I tried to comment as clearly as possible.
Thank you for following me.
As per step 1 in this tutorial, the code has been updated accordingly
Connected device * Arduino PIN * Description
#define buttonFood1_Pin 29 // FOOD 1 pushbutton pin
#define adjustHourDown_Pin 39 // adjust hour down button
#define adjustHourUp_Pin 37 // adjust hour up button
#define LedToggle_Pin 35 // Toggle LED display between current time and feeding time
#define adjustMinuteDown_Pin 33 // adjust minute down button
#define adjustMinuteUp_Pin 31 // adjust hour up button
(Pushbutton with Arduino wiring – use a 10k resistor as per the attached image and the following tutorial)
#define shockSensorPin 25 // VIBRATION sensor pin
#define relayWater_Pin 27 // optical RELAY pin for WATER solenoid valve
#define servo1_Pin 9 // SERVO1 pin, default
(Info on Adafruit Motor Shield v1.2 - https://www.adafruit.com/products/81)
AF_Stepper myStepper1(48, 1); //create STEPPER1 object, port 1 - M1+M2
#define DS1302_SCLK_PIN 22 // Arduino pin for the Serial Clock
#define DS1302_IO_PIN 24 // Arduino pin for the Data I/O
#define DS1302_CE_PIN 26 // Arduino pin for the Chip Enable
#define dotPin 47
#define aPin 40
#define bPin 41
#define cPin 42
#define dPin 43
#define ePin 44
#define fPin 45
#define gPin 46
#define GND1 48
#define GND2 49
#define GND3 50
#define GND4 51
(Please note that each GND1, GND2, GND3, and GND4 from the LED display is connected to their respective Arduino pins thru a 1k resistor)