fallais / gocoop

GoCoop is a tool written in Golang that helps you to open and close the door of your chicken coop !
7 stars 3 forks source link
chicken-coop chickens coop golang raspberry

GoCoop

Coop

GoCoop is a tool written in Go that helps you to manage your chicken coop !

Objectives

The main objective is to protect the chickens against the hungry fox or the greedy weasel. To do so, we need to automaticaly open and close the door of the chicken coop, with two options :

If you worry about using the sun based condition, be sure that the chickens always go to sleep at sunset. As the sentence says : go to bed with the chickens.

Components

The motor

I use the Nextrox 37mm 12V 15RPM. I chose this motor because of its torque : *250 Ncm**

Nextrox

The motor driver

I use the L293D. It is capable of handling two motors.

L293D

I will be using the following pins :

The GPIO pins

Here are the GPIO pins that are used :

The GPIO of my Raspberry 3 B+ are located as follow :

GPIO

The global schema

All components are now connected together with a breadboard.

Schema

Is it tested

Sure, I tried to do my best to add package tests because chickens deserv the best ! Moreover, I have been using it for more than one year at home, it has never failed since the begining.

Interface

It also comes with an smooth interface built with Bootstrap to manage the coop. It is protected by Basic Auth with github.com/abbot/go-http-auth.

dashboard

Deployment

Note : I used to work with Docker but I recently removed it from the project as I did not think it was really relevant for a demploy on RaspberryPi.

Ubuntu

Create a file /etc/systemd/system/gocoop.service :

[Unit]
Description=GoCoop

[Service]
ExecStart=/etc/goccop/goccop -c /etc/gocoop/config.yml

[Install]
WantedBy=multi-user.target

Then download the last binary on Github and place it here in /etc/goccop/goccop. For example :

mkdir /etc/gocoop
wget https://github.com/fallais/gocoop/releases/download/v2.0.2/gocoop_2.0.2_linux_arm64.tar.gz
tar -xvzf gocoop_2.0.2_linux_arm64.tar.gz
mv gocoop /etc/gocoop/gocoop
rm gocoop_2.0.2_linux_arm64.tar.gz
touch /etc/gocoop/config.yml

Then reload the daemon.

sudo systemctl daemon-reload

Start the service with:

sudo systemctl start gocoop.service

And enable it during startup with:

sudo systemctl enable gocoop.service

You can check the status of the service with:

systemctl status gocoop.service

Configuration

The configuration file located in /etc/gocoop/config.yml must look like this below :

general:
  gui_username: admin
  gui_password: admin
  private_key: keykey
coop:
  latitude: 43.388352
  longitude: 1.277914
  opening:
    mode: "time_based"
    value: "08h00"
  closing:
    mode: "sun_based"
    value: "30m"
door:
  opening_duration: "65s"
  closing_duration: "60s"
  motor:
    type: l293d
    pin_1A: 23
    pin_1B: 24
    pin_enable1: 25
cameras:
  outdoor: http://185.39.101.26/mjpg/video.mjpg
  indoor: http://187.157.229.132/mjpg/video.mjpg

Motor types

Actually, two types of motor can be used :

door:
  openening_duration: "65s"
  closing_duration: "60s"
  motor:
    type: l293d
    pin_1A: 23
    pin_1B: 24
    pin_enable1: 2
door:
  openening_duration: "65s"
  closing_duration: "60s"
  motor:
    type: bts7960
    forward_PWM: 23
    backward_PWM: 24
    forward_enable: 2
    backward_enable: 3

Modes and values

Two modes are available :

Production ready

It is actually also used by a friend who have 160 chickens. Below an overview of how it looks like.

Door

Licence

I do not set any licence as of now. Please do not use code for commercial purpose, instead, contact me and we could work together. Chickens are against money problems..

Ideas