You are on page 1of 24

By KIMERA ERIASAF 21/U/06904/EVE 2100706904

SPECIFICATION DOCUMENT FOR ARTIFICIAL EGG INCUBATOR

Project Name Artificial Egg Incubator System

Purpose To increase the production of day old chicks


for small and medium scale poultry farmers.

Inputs Electric motor, temperature sensor, ADC


Humidity sensor

Outputs LCD display 400 600

Functions Plug in into the power source

Performance humidity in the incubator is controlled by an


electric fan and the status of the incubator
displayed on an LCD screen
Manufacturing cost UGX 500000

Electric Power 500 watts

Physical size and weight egg size group of 60–69 g are best suited for
incubation

Size of 110 × 72 × 70 cm
Introduction:
 This Incubator is known as artificial hatcher, which is used in
poultry farms for providing optimum conditions at consistent
rate. It has thermostat-based operation and is provided with
digital screen for easy temperature & humidity adjustment. The
Incubator is provided with protection devices for voltage
fluctuations & fault current.
Purpose:
 To hatch eggs by controlling temperature, humidity and egg
turning throughout the 21 days of hatching period
Egg Types:
 Chicken
 Duck
Egg Quality and Quantity:
 Allows a maximum of 120 eggs to be hatched
 Damaged eggs are not allowed
 Extra sized eggs are not allowed like for ostriches
Temperature Specifications:
 Between 37.50c - 380c
 Relative Humidity 50% – 55%
Ventilation of Air:
 Developing embryos receive oxygen from the atmosphere and
release carbon dioxide to the atmosphere
Power supply:
 Voltage supply 220 - 240V
 Current 5A
 Frequency: 50/60 Hz
Features:
 Automatic humidity control
 Automatic temperature control
 LED display of temperature, humidity and turning frequency
 signaling first hatch and monitoring the baby, by detecting
sound of the baby bird once baby breaks egg shell
Other requirements:
 Battery backup is provided to power the system during power
failures
Materials:
 Temperature sensors
 Humidity sensors(hygrometer) to ensure humidity levels
 Electric fan to facilitate even heat distribution
 Tilting trays for turning eggs to prevent them from sticking to
the inside surface
Intended Users:
 Small scale farmers
 Starters
Code
// (C) 2017-2020 REUK.CO.UK - Free for non-commercial use.
// Egg incubation temperature and humidity controller with display.
// Connection to an always on motor - e.g. 6 rotations per day.
// Fan for cooling, heater for heating, humidifier to humidify.

// For the temperature sensor.


#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3

// For the non-volatile storage.


#include <EEPROM.h> //EEPROM.write(addr, val); val = EEPROM.read(address);

// For the DHT11 humidity sensor.


#include <dht.h>
dht DHT;
#define DHT11_PIN 10

//for the LCD


#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // This i2c address depends on the display.
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Setup a oneWire instance to communicate with the OneWire


// device (Dallas temperature IC)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.


DallasTemperature sensor1(&oneWire);

// Set up the input and output pins used on the Arduino.


const int button1 = 2;
const int button2 = 8;
const int heater = 9;
const int fan = 4;
const int humidifier = 5;

// Define variables to store the humidity and


// temperature readings froms sensors.
float sensorOneTemperature;
float humidity;

// Define variables for the upper and lower


// thresholds (read in from EEPROM).
float heaterOnThreshold;
float heaterOffThreshold;
float fanOnThreshold;
float fanOffThreshold;
float humidifierOnThreshold;
float humidifierOffThreshold;

// Define the memory locations of the thresholds in EEPROM.


int heaterOnEEPROM = 100;
int heaterOffEEPROM = 120;
int fanOnEEPROM = 140;
int fanOffEEPROM = 160;
int humidifierOnEEPROM = 180;
int humidifierOffEEPROM = 200;

// Set some default values for the thresholds.


const float heaterOnDefault = 37.0;
const float heaterOffDefault = 39.0;
const float fanOnDefault = 40.0;
const float fanOffDefault = 37.0;
const float humidifierOnDefault = 45.0;
const float humidifierOffDefault = 70.0;

// Define variables to keep track of the status of


// the system (0=off,1=on)
int heaterStatus;
int fanStatus;
int humidifierStatus;

void setup(void)
{
// Start up the temperature sensor library.
sensor1.begin();
// Set the temperature measurement resolution to
// 12 bit ADC (0.0625°C resolution)
sensor1.setResolution(12);

// Read in the threshold values from EEPROM.


heaterOnThreshold = EEPROM_readFloat(heaterOnEEPROM);
heaterOffThreshold = EEPROM_readFloat(heaterOffEEPROM);
fanOnThreshold = EEPROM_readFloat(fanOnEEPROM);
fanOffThreshold = EEPROM_readFloat(fanOffEEPROM);
humidifierOnThreshold = EEPROM_readFloat(humidifierOnEEPROM);
humidifierOffThreshold = EEPROM_readFloat(humidifierOffEEPROM);

// Make sure that we at least have read in values, or read in defaults.


if(isnan(heaterOnThreshold)) heaterOnThreshold = heaterOnDefault;
if(isnan(heaterOffThreshold)) heaterOffThreshold = heaterOffDefault;
if(isnan(fanOnThreshold)) fanOnThreshold = fanOnDefault;
if(isnan(fanOffThreshold)) fanOffThreshold = fanOffDefault;
if(isnan(humidifierOnThreshold)) humidifierOnThreshold = humidifierOnDefault;
if(isnan(humidifierOffThreshold)) humidifierOffThreshold = humidifierOffDefault;

// Set up the inputs and outputs on the Arduino IO


pinMode(button1, INPUT);
digitalWrite(button1, HIGH); //turn on the pull up resistor
pinMode(button2, INPUT);
digitalWrite(button2, HIGH); //turn on the pull up resistor
pinMode(heater, OUTPUT);
digitalWrite(heater, LOW);
pinMode(fan, OUTPUT);
digitalWrite(fan, LOW);
pinMode(humidifier, OUTPUT);
digitalWrite(humidifier, LOW);

// Need to keep track of the status of the heater, fan, and humidifier
// so we know whether they are on or off.
heaterStatus = 0; // Start with the heating element off (=0)
fanStatus = 0; // Start with the fan off
humidifierStatus = 0; // Start with humidifier turned off

// Set up the LCD


lcd.begin (16,2);
// Switch on the backlight.
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
// Clear the display.
lcd.clear();
delay(200);
}

void loop(void)
{
// Read in the temperature and humidity and display across
// the top line of the display.
readInAndDisplayTemperature();
readInAndDisplayHumidity();
// Display the current system status on the bottom line of the display.
displaySystemStatus();

// If heater is currently off, and temperature is low, turn on the heater.


if(heaterStatus == 0 and sensorOneTemperature < heaterOnThreshold){
digitalWrite(heater, HIGH);
heaterStatus = 1;
}

// If heater is currently on, and temperature is high, turn off the heater.
if(heaterStatus == 1 and sensorOneTemperature > heaterOffThreshold){
digitalWrite(heater, LOW);
heaterStatus = 0;
}
// If fan is currently off, and temperature is high, turn on the fan.
if(fanStatus == 0 and sensorOneTemperature > fanOnThreshold){
digitalWrite(fan, HIGH);
fanStatus = 1;
}

// If fan is currently on, and temperature is low, turn off the fan.
if(fanStatus == 1 and sensorOneTemperature < fanOffThreshold){
digitalWrite(fan, LOW);
fanStatus = 0;
}

// If humidifier is currently off, and humidity is low, turn on the humidifier.


if(humidifierStatus == 0 and humidity < humidifierOnThreshold){
digitalWrite(humidifier, HIGH);
humidifierStatus = 1;
}

// If humidifier is currently on, and humidity is high, turn off the humidifier.
if(humidifierStatus == 1 and humidity > humidifierOffThreshold){
digitalWrite(humidifier, LOW);
humidifierStatus = 0;
}

// Press and hold button1 for half a second to briefly show


// the thresholds currently set.
if(digitalRead(button1)==LOW){
int i;
for(i = 0; i < 5; i++){
delay(100);
if(digitalRead(button1) == HIGH) i = 20;
}
// If button was held for at least 1/2 second, display thresholds...
if(i < 11){
displayThresholds();
}
}

// Press and hold button2 for half a second to enter programming mode.
if(digitalRead(button2)==LOW){
int i;
for(i = 0; i < 5; i++){
delay(100);
if(digitalRead(button2) == HIGH) i = 20;
}
// If button was held for at least 1/2 second we go into programming mode.
if(i < 11){
programmingMode();
}
}
}

void programmingMode(){
// We arrive in here with the button2 currently being pressed
// and entering programming mode.
lcd.clear();
lcd.setCursor(0,0);
// Make sure that the user has released the programming button
while (digitalRead(button1) == LOW) {
delay(100);
}
lcd.print("PROGRAMMING MODE");

// Wait for button2 to be released.


do{
delay(50);
}while(digitalRead(button2) == LOW);

// FIRST of all we are going to programme in the new value


// for heaterOnThreshold
lcd.setCursor(0,0);
lcd.print("set Heater ON T ");
displayANumberDuringProgramming(heaterOnThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
heaterOnThreshold = heaterOnThreshold - 0.2;
displayANumberDuringProgramming(heaterOnThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
heaterOnThreshold = heaterOnThreshold + 0.2;
displayANumberDuringProgramming(heaterOnThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(heaterOnEEPROM, heaterOnThreshold);

// SECOND we set the new value for heaterOffThreshold.


lcd.setCursor(0,0);
lcd.print("set Heater OFF T ");
displayANumberDuringProgramming(heaterOffThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
heaterOffThreshold = heaterOffThreshold - 0.2;
displayANumberDuringProgramming(heaterOffThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
heaterOffThreshold = heaterOffThreshold + 0.2;
displayANumberDuringProgramming(heaterOffThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(heaterOffEEPROM, heaterOffThreshold);

// THIRD we are going to programme in the new value


// for fanOnThreshold.
lcd.setCursor(0,0);
lcd.print("set fan ON T ");
displayANumberDuringProgramming(fanOnThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
fanOnThreshold = fanOnThreshold - 0.2;
displayANumberDuringProgramming(fanOnThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
fanOnThreshold = fanOnThreshold + 0.2;
displayANumberDuringProgramming(fanOnThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(fanOnEEPROM, fanOnThreshold);

// FOURTH we are going to programme in the new value


// for fanOnThreshold.
lcd.setCursor(0,0);
lcd.print("set fan OFF T ");
displayANumberDuringProgramming(fanOffThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
fanOffThreshold = fanOffThreshold - 0.2;
displayANumberDuringProgramming(fanOffThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
fanOffThreshold = fanOffThreshold + 0.2;
displayANumberDuringProgramming(fanOffThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(fanOffEEPROM, fanOffThreshold);

// FIFTH we are going to programme in the new value


// for humidifierOnThreshold
lcd.setCursor(0,0);
lcd.print("set Humidi ON % ");
displayANumberDuringProgramming(humidifierOnThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
humidifierOnThreshold = humidifierOnThreshold - 2;
displayANumberDuringProgramming(humidifierOnThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
humidifierOnThreshold = humidifierOnThreshold + 2;
displayANumberDuringProgramming(humidifierOnThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(humidifierOnEEPROM, humidifierOnThreshold);
// SIXTH we are going to programme in the new value
// for humidifierOffThreshold
lcd.setCursor(0,0);
lcd.print("set Humidi OFF % ");
displayANumberDuringProgramming(humidifierOffThreshold);
for(int i = 0; i < 50; i++){
delay(100);
if(digitalRead(button1) == LOW){ // go down
humidifierOffThreshold = humidifierOffThreshold - 2;
displayANumberDuringProgramming(humidifierOffThreshold);
i = 0;
waitForButton1Release();
}
if(digitalRead(button2) == LOW){ // go up
humidifierOffThreshold = humidifierOffThreshold + 2;
displayANumberDuringProgramming(humidifierOffThreshold);
i = 0;
waitForButton2Release();
}
}
EEPROM_writeFloat(humidifierOffEEPROM, humidifierOffThreshold);
}

void waitForButton1Release(){
do{
delay(50);
}while(digitalRead(button1) == LOW);
}

void waitForButton2Release(){
do{
delay(50);
}while(digitalRead(button2) == LOW);
}

void displayANumberDuringProgramming(float theNumber){


lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(theNumber,1);
lcd.print(" ");
}

void readInAndDisplayTemperature(){
readTemperatureSensor();
displayTemperature();
}
void readTemperatureSensor(){
sensor1.requestTemperatures();
sensorOneTemperature = sensor1.getTempCByIndex(0);
}
void displayTemperature(){
// Need to deal with below zero temperatures and also
// with above 100 degree temperatures. Adjust number of
// decimal places to result in similar number of overall
// digits used.
int dp; //number of decimal places to show

// Show the temperature on the screen


lcd.setCursor(0,0);
dp = 2; //by default
if (sensorOneTemperature > 99.9) dp = 0;
if (sensorOneTemperature < 0) dp = 0;
lcd.print("T=");
lcd.print(sensorOneTemperature,dp);
lcd.print((char)223);
lcd.print("C");
lcd.print(" ");
}

void readInAndDisplayHumidity(){
readInHumidity();
displayHumidity();
}

void readInHumidity(){
// Read in the humidity from the sensor and set it
// to the global variable 'humidity'.
int chk = DHT.read11(DHT11_PIN);
humidity = DHT.humidity;
}

void displayHumidity(){
// Note - always call this function immediately
// after displaying the temperature.
lcd.print("H=");
lcd.print(humidity,0);
lcd.print("% ");
}

void displaySystemStatus(){
lcd.setCursor(0,1);
// We need to display the status of the heater, fan,
// and humidifier which can be ON or OFF. If status is
// ON, fill in character in front of device name.
if(heaterStatus == 1)
lcd.write(255);
else lcd.print(" ");
lcd.print("Heat ");
if(fanStatus == 1)
lcd.write(255);
else lcd.print(" ");
lcd.print("Fan ");
if(humidifierStatus == 1)
lcd.write(255);
else lcd.print(" ");
lcd.print("Hum ");
}

void displayThresholds(){
// Arrive here with button1 currently depressed.
// Show the six programmed thresholds on the screen
// for three seconds each.

// First of all show the heater thresholds.


lcd.clear();
lcd.print("Heater ");
lcd.setCursor(0,1);
lcd.print(heaterOnThreshold,1);
lcd.print((char)223);
lcd.print("C to ");
lcd.print(heaterOffThreshold,1);
lcd.print((char)223);
lcd.print("C ");
delay(3000);

// Now show the fan thresholds.


lcd.setCursor(0,0);
lcd.print("Fan ");
lcd.setCursor(0,1);
lcd.print(fanOnThreshold,1);
lcd.print((char)223);
lcd.print("C to ");
lcd.print(fanOffThreshold,1);
lcd.print((char)223);
lcd.print("C ");
delay(3000);

// Now show the humidifier thresholds.


lcd.setCursor(0,0);
lcd.print("Humidifier ");
lcd.setCursor(0,1);
lcd.print(humidifierOnThreshold,0);
lcd.print("% to ");
lcd.print(humidifierOffThreshold,0);
lcd.print("% ");
delay(3000);
}

//---------------------------------------------------------
// Utility functions to write float values to EEPROM and to
// read them back in again.
void EEPROM_writeFloat(int ee, float value)
{
byte* p = (byte*)(void*)&value;
for (int i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
}

float EEPROM_readFloat(int ee)


{
float value = 0;
byte* p = (byte*)(void*)&value;
for (int i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return value;
}

Thermometer code
// © reuk.co.uk - 2018

// Double Thermometer with Display.


// For the DS18B20 temperature sensors.

#include <OneWire.h> // (https://github.com/PaulStoffregen/OneWire)

#include <DallasTemperature.h> // (https://github.com/milesburton/Arduino-


Temperature-Control-Library)

// Data wires are plugged into pins 2 and 3 on the arduino.

#define ONE_WIRE_BUS 2

#define SECOND_BUS 3

// For the 1602 LCD module.

#include <Wire.h>

#include <LCD.h>

#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 // Note that some modules have address 0x3F

#define BACKLIGHT_PIN 3

#define En_pin 2

#define Rw_pin 1

#define Rs_pin 0

#define D4_pin 4

#define D5_pin 5

#define D6_pin 6

#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Setup a oneWire instances to communicate with OneWire devices.

OneWire oneWire(ONE_WIRE_BUS);
OneWire secondWire(SECOND_BUS);

// Pass our oneWire reference to Dallas Temperature.

DallasTemperature sensor1(&oneWire);

DallasTemperature sensor2(&secondWire);

float sensorOneTemperature = 0.0;

float sensorTwoTemperature = 0.0;

void setup(void)

// Start up the temperature sensor library.

sensor1.begin();

sensor2.begin();

// Set the temperature sensor resolutions to 11 bit

// ADC (12 bit is much slower but higher resolution).

sensor1.setResolution(11);

sensor2.setResolution(11);

// Initialise the LCD.

lcd.begin (16,2); // For a 16x2 character LCD

// Switch on the LCD backlight.

lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

lcd.setBacklight(HIGH);

// Clear the LCD screen.

lcd.clear();
}

void loop(void)

// Read in the temperatures of the two sensors.

sensor1.requestTemperatures(); // Read temperature of sensor1

sensorOneTemperature = sensor1.getTempCByIndex(0);

sensor2.requestTemperatures(); // Read temperature of sensor2

sensorTwoTemperature = sensor2.getTempCByIndex(0);

// Display the temperatures of the sensors on the LCD.

displayTemperatures();

void displayTemperatures(){

// Display sensor1's temperature.

lcd.setCursor(0,0);

lcd.print(" T1: ");

lcd.print(sensorOneTemperature,2);

lcd.print((char)223);

lcd.print("C ");

// Display sensor2's temperature.

lcd.setCursor(0,1);

lcd.print(" T2: ");

lcd.print(sensorTwoTemperature,2);

lcd.print((char)223);
lcd.print("C ");

Simple code for the egg incubator

#include <LiquidCrystal.h>

#include<TimerOne.h>

LiquidCrystal lcd(11, 10, 6, 5, 4, 3);

#define Heater 2

#define Cooler 8

#define Fan 12

#define Buzzer 7

#define Turning 9

#define Heater_ON digitalWrite(Heater,HIGH);

#define Heater_OFF digitalWrite(Heater,LOW);

#define Cooler_ON digitalWrite(Cooler,HIGH);

#define Cooler_OFF digitalWrite(Cooler,LOW);

#define Fan_ON digitalWrite(Fan,HIGH);

#define Fan_OFF digitalWrite(Fan,LOW);

#define Turning_ON digitalWrite(Turning,HIGH);

#define Turning_OFF digitalWrite(Turning,LOW);


#define Buzzer_ON digitalWrite(Buzzer,HIGH);

#define Buzzer_OFF digitalWrite(Buzzer,LOW);

#include "DHT.h"

#define DHTPIN 13

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

float Temperature = 0;

float Setpoint = 0;

unsigned int timer_counter = 0;

unsigned int counter1 = 0;

void setup()

pinMode(Heater, OUTPUT);

pinMode(Cooler, OUTPUT);

pinMode(Fan, OUTPUT);

pinMode(Buzzer, OUTPUT);

pinMode(Turning, OUTPUT);
lcd.begin(16, 2);

lcd.setCursor(0, 0);//cr

lcd.print("Egg Incubator");

Buzzer_ON;

delay(100);

Buzzer_OFF;

dht.begin();

delay(2000);

lcd.clear();

Timer1.initialize(100000);

Timer1.attachInterrupt( timerIsr );

lcd.clear();

void loop()

Read_temp();

Read_setpoint();

PrintTemp();
Read_DHT11();

Temperature_control();

void timerIsr()

//Turning control

timer_counter++;

if (timer_counter > 16200 && timer_counter < 16500)

Turning_ON;

else

Turning_OFF;

if (timer_counter > 16500)

{
timer_counter = 0;

void Temperature_control()

if (Temperature >= Setpoint + 0.5)

Heater_OFF;

counter1++;

if (counter1 > 20)

counter1 = 0;

if (Fan == HIGH)

Fan_OFF;

else if (Fan == LOW)

{
Fan_ON;

if (Temperature >= Setpoint + 1.5)

Cooler_ON;

else if (Temperature <= Setpoint + 0.5)

Cooler_OFF;

if (Temperature >= Setpoint + 2.0)

Buzzer_ON;

else

Buzzer_OFF;
}

else if (Temperature <= Setpoint - 0.5)

Heater_ON;

Fan_ON;

Cooler_OFF;

if (Temperature <= Setpoint - 1.0)

Buzzer_ON;

else

Buzzer_OFF;

void Read_temp()

Temperature = 0;
for (int i = 0; i < 30; i++)

Temperature += analogRead(A1) * 0.5;

delay(10);

Temperature /= 30;

Temperature;

void Read_setpoint()

Setpoint = 0;

for (int i = 0; i < 30; i++)

Setpoint += analogRead(A0) / 25.6;

delay(2);

Setpoint /= 30;

}
void PrintTemp()

lcd.setCursor(9, 0);//cr

lcd.write("S:");

lcd.print(Setpoint, 1);

lcd.setCursor(0, 0);//cr

lcd.write("T:");

lcd.print(Temperature-1, 1);

lcd.write((char)223);

lcd.write("C");

void Read_DHT11()

float h = dht.readHumidity();

lcd.setCursor(0, 1);//cr

lcd.write("H:");

lcd.print(h);
lcd.write("%");

lcd.setCursor(9, 1);//cr

lcd.write("S:");

lcd.print("86%");

//

You might also like