Sitemap / Advertise

Introduction

Feed the poultry in quotidian routine to condition them to improve egg production and hatching process.


Tags

Share

Arduino RTC Bird Feeder v2.0 for Poultry Conditioning

Advertisement:


read_later

Read Later



read_later

Read Later

Introduction

Feed the poultry in quotidian routine to condition them to improve egg production and hatching process.

Tags

Share





Advertisement

Advertisement




    Components :
  • [1]JLCPCB Custom PCB
  • [1]Arduino Nano v3
  • [1]LCD Screen (20 x 4)
  • [1]DS3231 RTC Module
  • [1]Adafruit Mini Pan-Tilt Kit
  • [2]SG-90 Servo Motor
  • [1]10K Potentiometer
  • [1]Potentiometer Knob
  • [1]Buzzer
  • [1]5mm Green LED
  • [6]220Ω Resistor
  • [4]Button (6x6)
  • [1]Power Jack

Description

I was keeping quails, chickens, and ducks in my garden before I moved, but it was struggling to manage to feed them in quotidian routine - day-to-day - to accustom them to a new egg production schedule. Also, I was trying to apply sensory preconditioning - repeated simultaneous presentations of two neutral stimuli (sound and light) - while feeding them to improve egg production rate, and it is mandatory to warn the poultry with light and sound while practicing sensory preconditioning. Hence, I had developed a bird feeder with the Arduino Nano as a budget-friendly solution to the problems I had encountered. In this project, I will discuss an enhanced version of my previous bird feeder for those who need a cheap device to practice sensory preconditioning with the poultry.

To obtain current time, date, and temperature, I used a DS3231 RTC module.

To create an interface to display the mentioned variables, check the device status, set the feeding time, and monitor the remaining time to the feeding time, I used a 20x4 LCD Screen and pushbuttons.

As the feeding mechanism with the container, I used a Pringles can attached to a mini pan-tilt kit with two servo motors (SG90).

Most importantly and not surprisingly, to apply sensory preconditioning, I added a buzzer and a 5mm green LED to the device, activated in the feeding time.

After completing my design on a breadboard and testing the code, I designed a PCB (RTC Bird Feeder V2.0) with a unique chicken shape to create a felicitous and easy-to-use accessory to any chicken coop.

Huge thanks to JLCPCB for sponsoring this project.

project-image
Figure - 51.1

Step 1: Designing and Soldering the RTC Bird Feeder V2.0 PCB

I designed the RTC Bird Feeder V2.0 PCB by using KiCad. I attached the Gerber file of the PCB below, so if you want, you can order this PCB from JLCPCB to create a stylish and easy-to-use bird feeder for applying sensory preconditioning to the poultry :)

project-image
Figure - 51.2

First of all, by using a soldering iron, I attached headers, 220Ω resistors, 10K potentiometer, the power jack, 5mm green LED, buzzer, and pushbuttons (6x6).

Component list on the PCB:

A1 (Headers for Arduino Nano)

LCD1 (Headers for 20x4 LCD Screen)

RV1 (10K Potentiometer)

Servo_1, Servo_2 (Headers for Servo Motors)

RTC1 (Headers for DS3231)

K1, K2, K3, K4 (6x6 Pushbuttons)

D1 (5mm green LED)

BZ1 (Buzzer)

R1, R2, R3, R4, R5, R6 (220Ω resistors)

J1 (Power Jack)

project-image
Figure - 51.3


project-image
Figure - 51.4


project-image
Figure - 51.5

Step 2: Programming the Arduino Nano

Download the required libraries to be able to control the modules:

DS3231 RTC Module | Library

- Include the required libraries.

- Define SDA (A4) and SCL (A5) pins.

- Define the LCD screen pins (rs, en, D4, D5, D6, D7).

- Define the servo motors.

- Create LCD characters - clock, X, smile, celsius.

- Define button, buzzer, and LED pins.

- Define menu options and variables to adjust the feeding time.

- Define a time variable to get data from the DS3231 accurately.

- Initiate the LCD screen - 20x4.

- Initiate the RTC module.

- Attach servo motors to PWM pins - D10, D9.

- In the readButtons() function, get data from pushbuttons - Right, OK, Left, Exit.

- In the get_time_rtc() function, get the current time (t) from the DS3231 and set time and date manually if needed.

- In the home_screen() function, display the home screen with Date, Time, Temperature, and DOW variables generated by the DS3231.

- In the set_feeding_time() function, turn the home screen to the feeding time setting screen if the OK button is pressed.

- Adjust the feeding time by either increasing or decreasing variables - feed_Hour and feed_Min.

- Change feed_Hour and feed_Min by pressing Right (min+) or Left (hr+) buttons to adjust the feeding hour in the 24hr format.

- In the get_remaining_time() function, turn the home screen to the remaining time screen if the Left button is pressed.

- Get the remaining time until the given feeding time.

- In the status_check() function, turn the home screen to the status check screen if the Right button is pressed.

- Check whether the feeding mechanism is activated or not.

- In the Feeding_Timer() function, check whether the feeding time is set or not. If so, activate the feeding mechanism (mini pan-tilt) and neutral stimuli (warnings) - 5mm green LED and buzzer - in the given feeding time.

- Wait 10 seconds to turn off the feeding mechanism.

project-image
Figure - 51.6


project-image
Figure - 51.7


project-image
Figure - 51.8


project-image
Figure - 51.9


project-image
Figure - 51.10


project-image
Figure - 51.11

Connections and Adjustments


// Connections
// Arduino Nano :           
//                                20x4 LCD Screen
// D7 --------------------------- rs
// D6 --------------------------- en
// D5 --------------------------- D4
// D4 --------------------------- D5
// D3 --------------------------- D6
// D2 --------------------------- D7
//                                Servo SG-90 (Joint_1)
// D10 -------------------------- 
//                                Servo SG-90 (Joint_2)
// D9  --------------------------
//                                DS3231 RTC Module
// SDA (or A4) ------------------ SDA  
// SCL (or A5) ------------------ SCL
//                                Buzzer
// D12 -------------------------- +  
//                                5mm Green LED
// D11 --------------------------   
//                                Right Button
// A3 --------------------------- 
//                                OK Button
// A2 --------------------------- 
//                                Left Button
// A1 --------------------------- 
//                                Exit Button
// A0 --------------------------- 


After completing and uploading the code to the Arduino Nano, I attached all required components to the board via headers - Arduino Nano, 20x4 LCD Screen Module, and DS3231 RTC Module.

project-image
Figure - 51.12

Then, I assembled the mini pan-tilt kit with two SG-90 servo motors and connected them to the board - Servo_1, Servo_2.

project-image
Figure - 51.13


project-image
Figure - 51.14

After finishing all connections, I fastened an old Pringles can to the mini pan-tilt kit as the container for the bird food by using screws and a hot glue gun to make joints sturdier.

project-image
Figure - 51.15

Screens and Features

1) The device displays the date, time, day, and temperature variables on the home screen. It also executes the feeding timer function on the home screen to activate the feeding mechanism within the given feeding time.

2) The device allows the user to select menu options (screens) on the home screen via control buttons:

- OK -> Feeding Time Setting Screen

- Right -> Status Check Screen

- Left -> Get Remaining Time Screen

project-image
Figure - 51.16

A. Feeding Time Setting Screen

A.1) In the 24hr format, the device lets the user set the feeding time by adjusting hour (between 0 and 23) and minute (between 0 and 59) separately.

Right -> Minute+

Left -> Hour+

project-image
Figure - 51.17


project-image
Figure - 51.18

B. Status Check Screen

B.1) If the user did not set the feeding time, the device prints Not Activated.

project-image
Figure - 51.19

B.2) Otherwise, the device prints Running and turns on the 5mm green LED.

project-image
Figure - 51.20

C. Get Remaining Time Screen

C.1) If the user did not set the feeding time, the device prints Not Activated.

project-image
Figure - 51.21

C.2) Conversely, the device evaluates and displays the remaining time to the feeding time.

project-image
Figure - 51.22

3) In the feeding time, for 10 seconds, the device:

- Displays Feeding Time!!!,

- Turns on the 5mm green LED,

- Plays a tone with the buzzer,

- Activates the mini pan-tilt to spill the bird food in the container to feed the poultry.

project-image
Figure - 51.23

Videos and Conclusion

Code

RTC_Bird_Feeder_v_2.ino

Download



         /////////////////////////////////////////////  
        //         RTC Bird Feeder v2.0            //
       //        for Poultry Conditioning         //
      //             ---------------             //
     //              (Arduino Nano)             //           
    //             by Kutluhan Aktar           // 
   //                                         //
  /////////////////////////////////////////////

// Feed the poultry in quotidian routine to condition them to improve egg production and hatching process.
// 
// For more information:
// https://www.theamplituhedron.com/projects/RTC-Bird-Feeder-v2-for-Poultry-Conditioning
//
//
// Connections
// Arduino Nano :           
//                                20x4 LCD Screen
// D7 --------------------------- rs
// D6 --------------------------- en
// D5 --------------------------- D4
// D4 --------------------------- D5
// D3 --------------------------- D6
// D2 --------------------------- D7
//                                Servo SG-90 (Joint_1)
// D10 -------------------------- 
//                                Servo SG-90 (Joint_2)
// D9  --------------------------
//                                DS3231 RTC Module
// SDA(or A4) ------------------- SDA  
// SCL(or A5) ------------------- SCL
//                                Buzzer
// D12 -------------------------- +  
//                                5mm Green LED
// D11 --------------------------   
//                                Right Button
// A3 --------------------------- 
//                                OK Button
// A2 --------------------------- 
//                                Left Button
// A1 --------------------------- 
//                                Exit Button
// A0 --------------------------- 


// Include the required libraries.
#include <DS3231.h>
#include <LiquidCrystal.h>
#include <Servo.h>

// Define SDA (A4) and SCL (A5) pins.
DS3231  rtc(SDA, SCL);

// Define the LCD screen pins(rs, en , D4, D5, D6, D7).
LiquidCrystal lcd(7,6,5,4,3,2);

// Define the servo motors.
Servo Joint_1;
Servo Joint_2;

// Create LCD characters:
byte clocK[8] = {
0b01010,
0b01010,
0b11011,
0b10001,
0b10101,
0b10101,
0b10001,
0b11111,
};

byte X[8] = {
0b00000,
0b10001,
0b01010,
0b00100,
0b01010,
0b10001,
0b00000,
0b00000,
};

byte smile[8] = {
0b00000,
0b01010,
0b00000,
0b00100,
0b10001,
0b10001,
0b10001,
0b11111,  
};

byte celsius[8] = {
0b01111,
0b01001,
0b01001,
0b01111,
0b00000,
0b00000,
0b00000,
0b00000,  
};

// Define button pins.
#define Right_B A3
#define OK_B A2
#define Left_B A1
#define Exit_B A0

int Right, OK, Left, Exit;

// Define Buzzer and LED pins.
#define Buzzer 12
#define LED 11

// Define menu options and variables to adjust the feeding time.
volatile boolean Set_Feed_Time, Get_Remaining_Time, Status_Check;
volatile boolean Activated = false;
int feed_Hour, feed_Min;

// Define a time variable to get data from the DS3231 accurately.
Time t;

void setup(){
  // Initiate the screen.
  lcd.begin(20, 4);
  
  // Initiate the RTC module.
  rtc.begin();

  // Attach servo motors to PWM pins.
  Joint_1.attach(10);
  Joint_2.attach(9);

  Joint_1.write(0);
  Joint_2.write(0);

  pinMode(Right_B, INPUT);
  pinMode(OK_B, INPUT);
  pinMode(Left_B, INPUT);
  pinMode(Exit_B, INPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(LED, OUTPUT);
} 

void loop(){
  // Create LCD characters.
  lcd.createChar(1, clocK);
  lcd.createChar(2, X);
  lcd.createChar(3, smile);
  lcd.createChar(4, celsius);

  readButtons();

  get_time_rtc();

  home_screen();

  set_feeding_time(); // OK Button on the home screen.

  get_remaining_time(); // Left Button on the home screen.

  status_check(); // Right Button on the home screen.

  Feeding_Timer();
  
}

void readButtons(){
  Right = digitalRead(Left_B);
  OK = digitalRead(OK_B);
  Left = digitalRead(Right_B);
  Exit = digitalRead(Exit_B);
}

void get_time_rtc(){
  //  Uncomment the following lines to set the date and time manually.
  /*
  rtc.setDOW(THURSDAY);     // Set Day-of-Week to Thursday
  rtc.setTime(12, 00, 00);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(1, 10, 2020);   // Set the date to October 1st, 2020
  */
  // Get the current hour and minute from DS3231. // t.hour; and t.min;
  t = rtc.getTime();
}

void home_screen(){
  lcd.setCursor(0, 0);
  lcd.print("Bird Feeder");
  // Print Date
  lcd.setCursor(12, 0);
  lcd.print(rtc.getDateStr(FORMAT_SHORT));
  // Print Time
  lcd.setCursor(12, 1);
  lcd.print(rtc.getTimeStr());
  // Write Temperature
  lcd.setCursor(0, 3);
  lcd.print(rtc.getTemp());
  lcd.write(4);
  lcd.print("C");
    // Write Dow
  lcd.setCursor(8, 3);
  lcd.print(rtc.getDOWStr(FORMAT_SHORT));
}

void set_feeding_time(){
  if(OK == HIGH){
    Set_Feed_Time = true;
    Activated = true;
    lcd.clear();
    // If selected, turn the home screen to the feeding time setting screen.
    while(Set_Feed_Time == true){
      // Adjust the feeding time by either increasing or decreasing variables - feed_Hour and feed_Min.
      readButtons();
      lcd.setCursor(0, 0);
      lcd.print("Set Feeding Time:");
      lcd.setCursor(0, 1);
      lcd.print("Time:  ");
      lcd.print(feed_Hour);
      lcd.print(" : ");
      lcd.print(feed_Min);
      // Change feed_Hour and feed_Min by pressing Right (min+) or Left (hr+) buttons.
      if(Right == HIGH){
        feed_Min++;
        delay(300);
          if(feed_Min > 59){
            // Adjust the minute between 0 and 59.
            feed_Min = 0;
            lcd.clear();
          }
      }
      if(Left == HIGH){
        feed_Hour++;
        delay(300);
        if(feed_Hour > 23){
          // Adjust the hour between 0 and 23 in 24hr format.
          feed_Hour = 0;
          lcd.clear();
        }
      }
      // If the Exit button is pressed, return to the home screen.
      if(Exit == HIGH){
        Set_Feed_Time = false;
        lcd.clear();
      }
    }
  }
}


void get_remaining_time(){
  if(Left == HIGH){
    Get_Remaining_Time = true;
    lcd.clear();
    // If selected, turn the home screen to the remaining time screen.
    while(Get_Remaining_Time == true){
      readButtons();
      // Get the remaining time until the given feeding time.
      lcd.setCursor(0, 0);
      lcd.print("Remaining Time to ");
      lcd.write(1);
      lcd.setCursor(0, 1);
      if(Activated == false){
        lcd.print("Not Activated - ");
        lcd.write(2);
      }else if(Activated == true){
        if(t.hour > feed_Hour){
          lcd.print(24 - (t.hour - feed_Hour));
        }else if(t.hour < feed_Hour){
          lcd.print(abs(t.hour - feed_Hour));
        }else if(t.hour == feed_Hour){
          if(t.min <= feed_Min) lcd.print("0");
          if(t.min > feed_Min) lcd.print("23");
        }
        lcd.print(" hours ");
        if(t.min > feed_Min){
          lcd.print(60 - (t.min - feed_Min));
        }else if(t.min <= feed_Min){
          lcd.print(abs(t.min - feed_Min));
        }
        lcd.print(" minutes ");
      }
      // If the Exit button is pressed, return to the home screen. 
      if(Exit == HIGH){
         Get_Remaining_Time = false;
         lcd.clear();
      } 
    }
  }
}

void status_check(){
  if(Right == HIGH){
   Status_Check = true;
   lcd.clear();
   // If selected, turn the home screen to the status check screen.
   while(Status_Check == true){
     readButtons();
     // Check whether the feeding mechanism is activated or not.
     lcd.setCursor(0, 0);
     lcd.print("Status Check :");
     lcd.setCursor(0, 1);
     if(Activated == false){
       lcd.print("Not Activated - ");
       lcd.write(2);
       }else if(Activated == true){
         lcd.print("Running - ");
         lcd.write(3);
         digitalWrite(LED, HIGH);
       }
     // If the Exit button is pressed, turn to the home screen.
     if(Exit == HIGH){
       Status_Check = false;
       digitalWrite(LED, LOW);
       lcd.clear();
     } 
    }
  }
}

void Feeding_Timer(){
  // Check whether the feeding time is set or not.
  if(Activated == true){
    if(t.hour == feed_Hour && t.min == feed_Min){
      // Activate the feeding mechanism and warnings:
      digitalWrite(LED, HIGH);
      tone(Buzzer, 500);
      Joint_2.write(180);
      lcd.clear();
      lcd.setCursor(0, 1);
      lcd.print("Feeding Time!!!");
      delay(10 * 1000);
      // Wait 10 seconds to turn off the feeding mechanism and warnings...
      digitalWrite(LED, LOW);
      noTone(Buzzer);
      Joint_2.write(0);
      lcd.clear();
    }
  }    
}


Schematics

project-image
Schematic - 51.1


project-image
Schematic - 51.2


project-image
Schematic - 51.3


project-image
Schematic - 51.4

Downloads

Gerber Files

Download


Fabrication Files

Download