Hello,
I'm hoping I can get some advice about if its possible to use Arduino to solve a problem.
I have a hen house with a door that opens by rotating 180 degrees, operated by a T shaped handle. pictues
Is it feasible to use a servo like this to rotate and counter rotate the door? If so what would I need to construct it?
An arduino unit - which one would be suitable?
A shield?
Something to power the servo
A breadboard and connectors
Geewiz box to house it all
Supplying mains power shouldn't be a problem but if I opted for batteries would that cause more problems or are there battery modules. Assuming open and closing once per day what sort of battery life could I expect?
Opening and closing will be based on either a set time or on input from a light sensor.
I've read through some of the topics but I can't find if something like this has been done before.
How much programming are we talking about to make this all work?
I know that's a lot of questions but from looking at previous posts it's easier to give accurate information if you provide as much details as possible.
At its most basic all I want is a timer to power a servo to go one way in the morning and the reverse in the evening...
That's for the reply. For mounting the servo itself I was thinking of inverting it and having the rotational centre directly above that of the door to keep things straight forward. The servo I linked to was a 13kg load one, does that sound reasonable? The resistance to move the door would be less than it takes to turn a doorknob I'd say so hopefully 13kg will be enough.
Please excuse the proably stupid question but I've not seen the term vin mentioned, what is that?
Would I need to split power off some way to the servo or would it just be a matter of plugging the power into the arduino board and taking it through to the servo?
I'll add a RTC clock to the shopping list. I've seen various starter kits that include connectors and cables and various other bits and bobs. If there was one that came with a servo that'd be handy - at least I'd know I had everything I need.
VIN, Voltage IN. The voltage applied to the DC barrel jack. Usually between 7 and 12 volts.
Normally you would split the power to the servo and the Arduino, servos like about 6v which unfortunately is not enough to drive the Arduino so that may mean two power supplies.
If you have power then two plug packs, for batteries maybe a 7v2 battery directly to the Arduino and regulated down for the servo.
EDIT: That servo can operate up to 7v2, so it looks like you can use a battery or single plug pack for both.
That look reasonable to me. The RTC module will not be super accurate but good enough for this I would think.
Do I need anything else?
How are you going to set the time? That will probably have to be done in the field as the RTC creeps over time. This normally requires an LCD and some buttons which is a pain if that's all they are needed for.
An alternative is to have a single button that forces the time to a given value, say 6PM. So every few days/weeks or whatever you press the button at 6 o'clock.
There will be some mechanical linkages to get as well. If this is outside a good enclosure will be required.
Just a small update. I've ordered a starter kit that includes a step motor, small servo and Light dependant resistors.
The kit also has an LCD and some buttons so the time can be changed as you suggested. I know I'll need a heavier servo/motor but my thinking is if I can get it working in principle first I can drop a bigger one into the circuit later.
There's also an IR remote, being able to operate the door using that would be quite handy. I could even get really fancy and have a buzzer go off 10 minutes before the door closes to tell the chickens it's bedtime. They're quite easy to train to that sort of thing.
For testing I was wondering if I could connect a LDR to the prototype shield and have an LCD display its resistance to calibrate at what light intensity to operate the servo? If that's possible could anyone point me in the direction of a tutorial to output the reading from an LDR to an LCD?
I think I want to sketch to run along the lines of
Detect "night" or "day" every 5 minutes. If its day for 3 consecutive checks, open the door. If its night for 3 consequtive checks, close the door.
Then a button to toggle between Open, Close and Automatic.
I've never done any electronics before so I appreciate any help and advice.
Can anyone suggest an easy way to have the servo move more slowly?
#include <Servo.h>
const int THRESHOLD = 680; // an arbitrary threshold level that's in the range of the analog input
Servo myservo; // create servo object to control a servo
int LDRpin = 0; // analog pin used to connect the potentiometer
int LDRval; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
// read the value of the LDR:
int analogValue = analogRead(LDRpin);
// if the analog value is high enough, turn on the Servo:
if (analogValue > THRESHOLD) {
myservo.write(180);
}
else {
myservo.write(0); //Reset the Servo if the value is too low
}
// print the analog value:
Serial.println(analogValue);
delay(150); // delay in between reads for stability
}
I have finished (I think) the code and hardware for this and I'm now at the stage where I want a permanent power solution.
Ideally I want to take a hard wired feed from the mains. Are there any recommendations for the easiest way to power an UNO board and servo in this way?
The Arduino can run on 5V at the +5V pin or on 7-12V on the Vin pin. The servo is probably designed to run at 6V so neither choice is ideal. Perhaps you could use a hefty 7+V supply and put a few big silicon diodes in the line going to power the servos. A silicon diode has a voltage drop of 0.6 to 0.7V so add drops to bring the voltage down to about 6V.
For simple servo setups, a 7805 regulating chip can have the output voltage increased using a small diode on the chip ground pin like below. There is a noticable servo performance improvement between 5v and 5.7v
I apologise if this is a stupid question but could I supply 12v to the arduino barrel connector and take the servo power from the VIN pin through a 7805 and diode as you suggested?
In fact considering the rating of the servo is 4.8v - 7.2v would a 7806 and no diode be better?
I just want to keep things are straight forward as possible and a 12v power brick should be easy to find.
could I supply 12v to the arduino barrel connector and take the servo power from the VIN pin through a 7805 and diode as you suggested?
Yep.
would a 7806 and no diode be better?
Same horse, different colour.
The diode trick is good if you have a 7805 lying around, you could use two diodes for that matter. But if you have to buy a regulator anyway the 7806 is fewer components.