Tuesday, January 27, 2015

Arduino 3D Printed Fish Feeder V.2

January 27, 2015 -- HeliosLabs Version 2 of our auto-fish feeder is finally printed out and the files are now available online. It isn't perfect but it will be a good starting point for others. It is designed specifically to hang from a planter over a fish tank in an aquaponics system. In the future we might design a mounting system for a regular fish tank. If you want to use this now for a fish tank, you are free to modify and repost the files. In fact, we encourage it!

V.2 two being assembled with an Arduino Uno board visible in the electronics compartment just about the servo spacer which holds the servo in place when the cover is finally closed. The "arms" are attached to the back cover using a t-slot. Because this model was printed on a MakerBot using low resolution, the arms fit in very tight and required a little careful forcing. Once in place they will stay in place.

You can find the .stl files on MakerBot's Thingiverse here. For SketchUp users (this model was made in SketchUp) you can find an exploded view here in the 3D Warehouse, and a layout version you can use to export the files to .stl for printing. 


Here's a few design notes for those thinking about printing this version out.
1. The servo spacer and the lid might require a little sanding or light filing. Please always remember, take a little off at a time and test it often. You can always take more off, you can't put any back on.

2. The auger has a round plate toward its base. This is to line up with the hole in the hopper, leading into the electronics compartment and is designed to block food from flowing into the electronics compartment. Your servo may differ from the 9g micro servo we used. There is a base on it that you can file down. If need be (and in our case what we ended up doing) you can even drill into the auger a little bit and fit it over the servo gear. In the future, we (or you) might want to rework the auger a little to include a hole for the servo gear. Make sure to measure it carefully and allow for 0.3mm extra due to printer resolution. 

3. To assemble, most of it is straight forward. Use 16 2mm x 15mm screws. The auger should be super-glued to the servo gear, or you can put a modified adapter over the servo gear and glue that to the auger. Once the glue dries, this feeder is designed to have the whole servo and auger slide in from the back into place. Make sure the auger base plate lines up with the opening between the food hopper and the electronics compartment. 

The Electronics & Arduino Code 

For the electronics, ideally you should connect the servo to its own 5V power source and power the Arduino via a USB/DC adapter separately. The servo, if powered by the Arduino directly, might overdraw amps and reset the Arduino. This will essentially ruin the timer's accuracy and require you to reset it. You may set your feeder to work everyday at 1pm, and come back a week later to see it feeding your fish at 7am (which is what V.1 did).

The original model was created using SketchUp. Two versions were uploaded to the SketchUp 3D Warehouse, as seen above -- an exploded view and a layout version. Both will help users modify and examine how it is assembled.

The code works by feeding the fish when you first plug it in, then again whenever you've programmed it to. Our code has it feed the fish twice a day. In between feedings, the servo is detached. If you don't it will creep and buzz all day and all night because this servo has been modified to move beyond 180 degrees (see here how).

//Automatic Fish Feeder Arduino Sketch 1pm - 9pm feeding time

#include <Servo.h>

Servo myservo;

void setup() {
myservo.attach(9);
}

void loop() {
myservo.write(180);   //clockwise rotation for 1pm feeding
delay(10000);          //rotation duration in ms
myservo.detach();     //detach servo to prevent "creeping" effect
delay(28800000);      //8 hours pause between 1pm and 9pm
myservo.attach(9);    //reattach servo to pin 9
myservo.write(180);   //clockwise rotation for 9pm feeding
delay(5000);          //rotation duration in ms
myservo.detach();     //detach servo to prevent "creeping" effect
delay(57600000);      //16 hours pause until 1pm next day
myservo.attach(9);    //reattach servo to pin 9 before looping
}
Enter the code above into your Arduino developer environment and upload it to your Arduino board. Plug your fish feeder in at 1pm to begin the program. In the future, we will try to do this so it runs off a clock either online or elsewhere. If the power goes off, then comes back on, your whole system will reset and the times will be skewed.

The above code worked well with our flimsy V.1. It should work well with V.2. There is room for improvement, and it will be improved once this system is moved up into the CityFarmBKK project.

If you have any questions or comments, feel free to contact us. A lot of people's hard work helped us get this far, and we are more than happy to pay it forward to others.

For information about the electronics including how to correctly wire the servo and Arduino to separate power sources, see here.

Follow Helios Labs on Twitter @HeliosLabs or find us on Facebook here.