“Hey google, open the chicken door”

Pics
Currently working on automating my coop using blynk and esp8266. My wife and I can turn on and off the electric fence from our phones anywhere in the country so far. Once I get everything installed and working, I'll clean up the code and stuff and post it all.
 
I started working on this when I was gifted an Alexa and felt I had no good use for it, so why not make a high tech chicken coop? I found modifying things to be overly complicated and it didn't actually make my chicken keeping any easier. I abandoned the project. If you have power to your coop and are willing to invest some $$$ it would be much more feasible.

As mentioned you need power. Additionally you need wifi to reach your coop. If you want to use your smartphone or computer to open/close the door you would simply need to plug the door opener into a smart outlet. Many auto coop doors however seem to be self-contained units with either solar or battery power. This solution only works if the door is plugged into a smart outlet. You likewise could install smart bulbs for your light. Security cameras. A smart thermostat, etc.
 
I use a Raspberry Pi 3 B to control my coop door and lighting. It opens the door (right now) at dawn and closes the door at dusk. I'm working on the code to automatically start adding 5 minutes per day of light from a date I picked until 14 hours of light is reached then stop adding extra light until the next start date. Each night when the date changes (my new code) the astral times are updated with the dawn, sunrise, sunset and dusk times (more if needed). There is really no need to try and use some bloated spyware like Google lol. The RPi does need a connection to the internet to update the astral times but you have a LAN cable out at your coop anyway for the cameras right???

@zimirken I've tried the ESP8266 and found that it was a bit flakey and not reliable to open my door. I'm not sure what caused the issues and I tried several to make sure it was not isolated to one. I assume your using the ESP8266 for the WIFI part. I've never looked at blynk before but it looks interesting. While being able to turn on and off something from somewhere else is cool I think opening and closing the door automatically at the correct time is better as you don't have to remember to do it. I've programmed my ESP8266 and the RPi to send me a text message when the door is closed or an email.

I am very interested in collaborating with anyone that wants to use the RPi for chicken automation.

My current working code to test the open and close times of the door.
Code:
#!/usr/bin/env python3

#import datetime
from datetime import date
from datetime import datetime, timedelta
import time
import astral
import pytz
import schedule

localTz = 'US/Central'
loctz = pytz.timezone('US/Central')

coordinates = ["Poplar Bluff", "USA", 36.763084, -90.413871, localTz, 110]
pbmo = astral.Location(info=(coordinates))
pbmo.solar_depression = "civil"

dateFormat = '%b %d %Y'
timeFormat = '%I:%M %p'
lastDate = datetime.date(datetime.now(loctz) - timedelta(days=1))

events = pbmo.sun(datetime.now(loctz))
dawn = events['dawn']
sunrise = events['sunrise']
sunset = events['sunset']
dusk = events['dusk']

def update():
    global events
    global dawn
    global sunrise
    global sunset
    global dusk
    events = pbmo.sun(datetime.now(loctz))
    dawn = events['dawn']
    sunrise = events['sunrise']
    sunset = events['sunset']
    dusk = events['dusk']
    now = datetime.now(loctz)
    print('Today Date {}'.format(now.strftime(dateFormat)))
    print('Update Door Open == {}'.format(now > dawn and now < dusk))
    print('Dawn {}'.format(dawn.strftime(timeFormat)))
    print('Sunrise {}'.format(sunrise.strftime(timeFormat)))
    print('Now {}'.format(now.strftime(timeFormat)))
    print('Sunset {}'.format(sunset.strftime(timeFormat)))
    print('Dusk {}'.format(dusk.strftime(timeFormat)))

def status():
    now = datetime.now(loctz)
    openDoor = now > dawn and now < dusk
    nowTime = now.strftime(timeFormat)
    print('now {}\ndawn {}\ndusk {}'.format(now, dawn, dusk))
    print('Time {} Door Open == {}'.format(nowTime, openDoor))


schedule.every(5).minutes.do(status)

try:
    while True:
        schedule.run_pending()
        today = datetime.date(datetime.now(pytz.timezone('US/Central')))
        if lastDate != today:
            lastDate = today
            update()
        time.sleep(.1)

except KeyboardInterrupt:
    # here you put any code you want to run before the program like RPi I/O cleanup
    # exits when you press CTRL+C
    print('\nKeyBoard Interrupt')

except Exception as e:
    # this covers all other exceptions
    print(str(e))

JT
 
I use a Raspberry Pi 3 B to control my coop door and lighting. It opens the door (right now) at dawn and closes the door at dusk. I'm working on the code to automatically start adding 5 minutes per day of light from a date I picked until 14 hours of light is reached then stop adding extra light until the next start date. Each night when the date changes (my new code) the astral times are updated with the dawn, sunrise, sunset and dusk times (more if needed). There is really no need to try and use some bloated spyware like Google lol. The RPi does need a connection to the internet to update the astral times but you have a LAN cable out at your coop anyway for the cameras right???

@zimirken I've tried the ESP8266 and found that it was a bit flakey and not reliable to open my door. I'm not sure what caused the issues and I tried several to make sure it was not isolated to one. I assume your using the ESP8266 for the WIFI part. I've never looked at blynk before but it looks interesting. While being able to turn on and off something from somewhere else is cool I think opening and closing the door automatically at the correct time is better as you don't have to remember to do it. I've programmed my ESP8266 and the RPi to send me a text message when the door is closed or an email.

I am very interested in collaborating with anyone that wants to use the RPi for chicken automation.

My current working code to test the open and close times of the door.
Code:
#!/usr/bin/env python3

#import datetime
from datetime import date
from datetime import datetime, timedelta
import time
import astral
import pytz
import schedule

localTz = 'US/Central'
loctz = pytz.timezone('US/Central')

coordinates = ["Poplar Bluff", "USA", 36.763084, -90.413871, localTz, 110]
pbmo = astral.Location(info=(coordinates))
pbmo.solar_depression = "civil"

dateFormat = '%b %d %Y'
timeFormat = '%I:%M %p'
lastDate = datetime.date(datetime.now(loctz) - timedelta(days=1))

events = pbmo.sun(datetime.now(loctz))
dawn = events['dawn']
sunrise = events['sunrise']
sunset = events['sunset']
dusk = events['dusk']

def update():
    global events
    global dawn
    global sunrise
    global sunset
    global dusk
    events = pbmo.sun(datetime.now(loctz))
    dawn = events['dawn']
    sunrise = events['sunrise']
    sunset = events['sunset']
    dusk = events['dusk']
    now = datetime.now(loctz)
    print('Today Date {}'.format(now.strftime(dateFormat)))
    print('Update Door Open == {}'.format(now > dawn and now < dusk))
    print('Dawn {}'.format(dawn.strftime(timeFormat)))
    print('Sunrise {}'.format(sunrise.strftime(timeFormat)))
    print('Now {}'.format(now.strftime(timeFormat)))
    print('Sunset {}'.format(sunset.strftime(timeFormat)))
    print('Dusk {}'.format(dusk.strftime(timeFormat)))

def status():
    now = datetime.now(loctz)
    openDoor = now > dawn and now < dusk
    nowTime = now.strftime(timeFormat)
    print('now {}\ndawn {}\ndusk {}'.format(now, dawn, dusk))
    print('Time {} Door Open == {}'.format(nowTime, openDoor))


schedule.every(5).minutes.do(status)

try:
    while True:
        schedule.run_pending()
        today = datetime.date(datetime.now(pytz.timezone('US/Central')))
        if lastDate != today:
            lastDate = today
            update()
        time.sleep(.1)

except KeyboardInterrupt:
    # here you put any code you want to run before the program like RPi I/O cleanup
    # exits when you press CTRL+C
    print('\nKeyBoard Interrupt')

except Exception as e:
    # this covers all other exceptions
    print(str(e))

JT

I'm using a mix of the esp8266 and the nodemcu esp board that is waaay less finnicky. The esp-01 board for the 8266 is real finnicky, because of the multiple boot modes based on pins. You have to tie reset and ch_pd to vcc. Also, GPIO2 needs to be high or left floating during startup, so you can't attach anything that might pull low even slightly on that pin.

Also, the esp pulls big current spikes when transmitting on wifi, so your 3.3v supply needs to be able to supply at least half an amp, and you need a big ~1000uF capacitor on the supply line close to the esp.


It took me a while to figure that out, but once I did, it's been pretty reliable. The nodemcu board has way more io and built in power supply, and it's still only a couple bucks a piece, but I like the small size of the esp-01 for certain things.
 

New posts New threads Active threads

Back
Top Bottom