Introduction: Solar CHICKEN DOOR With Battery

Please check my previous Instructable, this is an upgrade so it runs off grid.

https://www.instructables.com/id/Automatic-CHICKEN...

Board and stepper motor are the same, the difference is in electronics as it is battery operated with solar charging. It consumes as low as 0.1mA thanks to LowPower library and cutting LED connection on the board so it doesn't draw current.

Step 1: Materials

-FTD1232

-Arduino pro mini

-5V Step Up Module(1)

-ULN2003A board (from previous Instructable)

-Li-ion battery (such as 18650) or 2xAA (see safe operating area pic) (2)

-0.5W 5V solar cell [outputs up to 7v]

-5V1 zener diode

-battery case

(1) For more reliability use separate charging board and step up module, down in alternatives. It is important to choose step up module with low quiescent current.

(2)If you intend to use AA alkaline batteries you may need to lower chip frequency and not connect solar power. Same with rechargeable AA, as they like to be discharged fully before changing (I think).

Some optional reading on low power Arduino:

http://www.home-automation-community.com/arduino-l...

Before going furter I advise you to download LowPower library:

https://github.com/rocketscream/Low-Power

Links to materials:

https://www.aliexpress.com/item/1pcs-lot-ATMEGA328...

https://www.aliexpress.com/item/5V-Boost-Step-Up-P...

https://www.aliexpress.com/item/Portable-Mini-6V-0...

alternatives:

https://www.aliexpress.com/item/1PC-LOT-TP4056-1A-...

https://www.aliexpress.com/item/DC-DC-2V-5V-to-5V-...

https://www.aliexpress.com/item/Solar-Cells-5-5V-0...

Use this extention to get up to 7% off

https://alibonus.com/?u=429363

Step 2: Getting Ready and Soldering

Cut the LED connection with a stanley knife to cut LED power. I don't think it's necessary to remove the voltage regulator(as suggested by the link) as we will be using solar cell to charge our battery.

Okay, here you may want to connect things properly, but I've cut some shortcuts.

I've bent (-)terminal on ULN2003A board to allign with IN1 to IN4 to solder Pro Mini directly on.

I've also mounted Step up Module directly beneath Pro Mini. A1 is used only as mounting pin. A wire is used to connect +5V from Step up to ULN2003A board. GND kind of goes through ProMini.

Add programming headers from GND to DTR. These will be also used later to connect the battery.

Solder pin4 and pin3 for photocell module.

Step 3: Connect

Wiring: (my wire colors)

ProMini

pin4 - VCC photocell (red)

pin3 - D0 photocell (brown)

Gnd - GND photocell (black)

Vcc - battery(+) (red)

Gnd - battery(-) (brown)

Solder Zener 5.1V 0.5w on Solar cell, then solder it to the end of microUSB cable.

Make a box for a Solar Cell and glue it inside so it stays dry. No need to waterproof it, just so it stays off the rain.

Step 4: The Code; Don't Forget the Low Power Library

#include "LowPower.h"

int Pin0 = 9;

int Pin1 = 8;

int Pin2 = 7;

int Pin3 = 6;

int _step = 0;

int t=2300; //increase if necessary, 3000

int sensorPower = 4;

int sensorPin = 3;

int sensorVal;

int revs = 24576; //equals 6 turns

int state=1; //0 is doors closed, 1 is open

boolean dir = true;// gre

void setup()

{

pinMode(Pin0, OUTPUT);

pinMode(Pin1, OUTPUT);

pinMode(Pin2, OUTPUT);

pinMode(Pin3, OUTPUT);

pinMode(sensorPower, OUTPUT);

pinMode(sensorPin, INPUT);

}

void loop()

{

digitalWrite(sensorPower, HIGH); //sends power to sensor

delayMicroseconds(1000);

int sensorVal = digitalRead(sensorPin); //reads sensor

digitalWrite(sensorPower, LOW);

if (sensorVal==LOW && state==0)

{

for(int i=0;i

{

state=1;

dir=true;

switch (_step) {

case 0:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

case 1:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, HIGH);

break;

case 2:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 3:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 4:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 5:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 6:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 7:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

default:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

}

if (dir) {

_step++;

} else {

_step--;

}

if (_step > 7) {

_step = 0;

}

if (_step < 0) {

_step = 7;

}

delayMicroseconds(t);

}

}

if (sensorVal==HIGH && state==1)

{

for(int i=0;i

{

state=0;

dir=false;

switch (_step) {

case 0:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

case 1:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, HIGH);

break;

case 2:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 3:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 4:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 5:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 6:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 7:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

default:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

}

if (dir) {

_step++;

} else {

_step--;

}

if (_step > 7) {

_step = 0;

}

if (_step < 0) {

_step = 7;

}

delayMicroseconds(t);

}

}

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

//sleeps for 8s*7=56s

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

Step 5: Screw It in and Adjust the Trimmer

Now screw everything in and adjust the trimmer on the photocell module. Install the board in front of your coop and connect solar cell to the microUSB port and enjoy!

Automation Contest 2017

Runner Up in the
Automation Contest 2017

Make It Move Contest 2017

Participated in the
Make It Move Contest 2017

Solar Contest 2017

Participated in the
Solar Contest 2017