Full Arduino Code for Poultry Egg Incubator with Humidity Sensor

We are frequently asked for the source code used on the Arduino-based products which we design and build. Unfortunately we cannot do that for commercial reasons. However, more than 80 percent of the requests we receive are for the code used in our poultry egg incubation controllers, with almost 100 percent of those requests coming from the developing world.

Therefore, as a one-off, we are releasing the full Arduino source code for our most popular (and easiest to build with commonly available components) device of this type, our Poultry Egg Incubator with Humidity Sensor.

egg incubator with humidity sensor, fan, heater, and humidifier

egg incubator controller status summary display

This device makes use of an always on motor which turns the eggs six full turns every 24 hours. Many of our other incubators have motors which have to be set up to run for a certain length of time a certain number of times per day, but the code for these is either specific to a particular motor or far more complicated (but of course more flexible) if the end-user of the incubator is to set these timings.

This device makes use of a DS18b20 digital temperature sensor, a 1602 LCD display module, a DHT11 humidity sensor, and is based around an Arduino Pro Mini, together with some relays, resistors, buttons, terminals, and other components available everywhere – easily salvaged from old and broken electronics even.

In time we will add a circuit diagram together with a suggested parts list, but the design is very flexible in terms of the components which can be used to put it together (with exception of the sensors and display for which the code provided is specific…and which together with an Arduino Pro Mini clone can be purchased for well under US$10 total including delivery.

Click here for details on how to connect and use a DHT11 Humidity Sensor with Arduino, and here for information on using DS18B20 sensors and 1602 LCD modules with Arduino.

Here is the full Arduino sketch (source code) for the egg incubator.

// (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;
}

Poultry Egg Incubator with On Board Display and Humidity Maintenance

We have made many poultry egg incubators and timers over the last few years – devices which monitor and maintain temperature and humidity and also turn the eggs at regular intervals. Below is an image of one such incubator controller which we were recently commissioned to build which is a bit different from those.

poultry egg incubator controller

The motor is set to turn for three seconds five times per day to rotate the eggs. This is standard.

The heating element used for this incubator is a bit oversized, so we have to be careful not to overheat the eggs when it is used. When the temperature is measured to be 0.5C or more below a user set target temperature, the heater is turned on. Then, when the target temperature is reached, the heater is turned off. Because the element remains hot after being turned off, the incubator will continue to heat up to a little above target temperature while the element cools down. Therefore, there is also a fan which turns on just in case the temperature exceeds the target by 1.5C or more to cool things down long before the eggs overheat.

display for poultry egg incubation controller

Humidity management is also achieved rather differently than usual. In all previous incubators we have made which have included humidity sensing, a commercial humidifier has been switched on/off to maintain appropriate humidity levels. For this controller, when humidity is measured to be below a user set target minimum level, a pump is turned on for five second which adds water to a container in the incubator. The rapid evaporation of this water in the warmth of the incubator increases the humidity level back above the minimum rapidly. In order to prevent flooding or raising the humidity level excessively, the controller will run the pump at most once every ten minutes.

This entire system is powered by a solar charged 12V battery bank.

If you need any type of incubator (or humidor), please email neil@reuk.co.uk with details of your requirements.

Timer for Poultry Egg Incubator

Pictured below is a timer we built to accompany a Poultry Egg Incubator Controller we made recently.

timer for poultry egg incubatorWhen incubating eggs it is very important to keep track of the time since they were laid since, for example, eggs must be turned regularly until the last few days before hatching, and for some eggs the temperature and humidity ranges need minor adjustments during the incubation period.

Our timer is 12VDC powered like the incubator, and has a display to show the elapsed time since it was last manually reset. The time is shown in days:hours:minutes:seconds format.

Since eggs take anything up to 6 weeks to hatch, the time elapsed is stored in memory on the timer microcontroller every 15 minutes so that if the power to the timer is cut for any reason (e.g. flat battery or accidental disconnection of one of the power leads), when the timer is reconnected to power, it will restart from within no more than 15 minutes of where it was before the power cut.

After incubation has finished, a reset button (Reset Button 1) must be pressed for 1 second to reset the timer to 0:00:00:00 ready for the next lots of eggs to go into the incubator.resetting poultry egg incubator timer

This timer is built around an Arduino Pro Mini. The microcontroller with its on board crystal keeps time well enough for this application. (If more accuracy was required we would have added a real time clock (RTC).). Reset Button 2 on the timer resets the internal clock which is limited to 4,294,967,295 milliseconds (just under 50 days) – plenty of time for pretty much everything up to ostrich eggs, but not long enough for emperor penguin, albatross, and some cuckoo eggs. For exotic eggs with very long incubation periods, an RTC would need to be added.

If you need a timer or a poultry incubator controller, email neil@reuk.co.uk with details of your requirements.

Poultry Egg Incubator with Humidity Sensor

Pictured below is a controller we recently made for use in a poultry egg incubator, designed to keep eggs within a very narrow specific temperature and humidity range for a few weeks. This is achieved using a heater, a fan, and a humidifier.egg incubator with humidity sensor, fan, heater, and humidifierThe eggs need to be turned at least three times per day every day except for the last few days before hatching. Previously we made a Controller for Poultry Incubator which had a motor which was turned on and off at different times of the day to turn the eggs. For this new incubator, the motor used is a very slow turning 12 VAC device makes 6 full rotations every 24 hours. That motor therefore did not need to be controlled with a timer – it is just left running at all times.

egg incubator controller status summary displayThe display for this controller shows the current measured temperature from the waterproof DS18B20 digital temperature sensor (read at 12 bit resolution = 0.0625°C resolution), and the humidity from a DHT11 sensor (within 5% accuracy). The DHT11 actually has a built in thermistor, but its temperature measurements are nowhere nearly accurate enough for this type of project.

The bottom line of the display shows the three devices being controlled – heater, fan, and humidifier respectively. In the image above, the heater is marked as being on. If the humidity level gets too low, the humidifier will be switched on. If the temperature gets too hot, the fan will turn on (and of course the heater will already be turned off by then).

Setting humidity range for poultry egg incubator

The user has full control over the thresholds at which the heater, fan, and humidifier will turn on and turn off. The temperature thresholds for the heater and fan can be set in steps of 0.2°C, and the humidity thresholds in steps of 2%.

For example, the heater could be set to turn on at or below 36.4°C and off again at or above 38.4°C. Then the fan could be set to turn on at or above 38.6°C and off again at or below 37.4°C. Humidity should ideally be around 60% (raising to 65% just before hatching), so the humidifier could be set to turn on at or below 56% and off again at or above 64% relative humidity.

display for egg incubatorWith all the thresholds programmed in by the user according to the requirements of the particular type of eggs to be incubated, a button can be pressed to show in turn the values programmed in – for example, above the humidifier is shown to be set to turn on at or below 43% RH and turn off at or above 70% RH.

Feb 2020 – We have now released the full Arduino sketch (source code) for this device here: http://www.reuk.co.uk/wordpress/full-arduino-code-for-poultry-egg-incubator-with-humidity-sensor/

If you need any kind of egg incubator controller (or the electronics for a temperature and humidity controlled humidor – functionally pretty much identical to an incubator!) – please email neil@reuk.co.uk with details of your specific requirements.

Controller for Poultry Incubator

Pictured below is an automatic controller for a poultry incubator. The eggs in this incubator must be kept within a tightly regulated temperature range, they need to be automatically turned at regular intervals, and there is also a fan to be controlled.

thermostatic poultry incubator control boardThe owner of this incubator would like the temperature of the eggs to be kept between 37 and 37.5 degrees Celcius, so there is a heating element which is switched by an on board relay following the temperatures measured by a DS18B20 waterproof sensor.

The eggs are to be turned every 30,45,60, or 75 minutes, and to do this the motor must run each time for a few seconds. Both of these timing intervals can be set by the user.

The fan has three modes of operation – on, off, or automatic, and in automatic mode the user can select an interval of 5, 10, or 15, etc minutes on and minutes off repeating.

Display for thermostatic poultry incubator controllerAll of the current settings and system status are shown on a backlit 16×2 LCD display (see above), and all user settings are programmed using this display and the two buttons on the controller board.

If you need a controller of this type, please email neil@reuk.co.uk with details of your exact requirements. For details of an alternative incubator controller which also controls humidity, click here: Poultry Egg Incubator with Humidity Sensor.

Project of the Day – Egg Incubator Day Countdown Timer

Pictured below is a project we completed for a day countdown timer for an egg incubator.
Egg incubator day countdown timer

It is important to keep track of the number of days that the eggs have been in the incubator waiting to hatch. When the user turns on the incubator and puts in the eggs, he uses the button on the timer to programme in the number of days that the eggs have until they are due to hatch. The timer then starts, and every day the day count display reduces by one until it eventually gets down to zero and the eggs hatch.

In order to build this we used a standalone Arduino set up. The external clock crystal gives pretty good time accuracy (used in conjunction with the Arduino millis() function). However, it is still essential to calibrate it to confirm it will be reliable over the 30 days or less that this incubator timer is likely to have to countdown.

In order to calibrate we temporarily programmed the timer to countdown hours (3,600,000 milliseconds) instead of days and left it running for 12 hours. Using an accurate stopwatch we timed how long it took the timer to run for its ’12 hours’ to compare it with the real 12 hours of the stopwatch. We then calculated by how much we needed to increase or decrease the number of milliseconds in the Arduino ‘hour’ so that its hour would match a real hour giving a very accurate timer. With this particular Arduino chip and clock crystal combination the Arduino lost less than a second in 12 hours even before the calibration.

Display on the egg incubator day countdown timer

To display the number of days until hatching we used two 7-segment LED displays which we multiplexed. Multiplexing takes advantage of persistence in the eye. If you light up one display quickly, then the other display, then the first again, and so on, the eye sees both displays on at the same time (as does a camera if the shutter speed is slower than the time taken to light up both displays – see above!). This technique makes it possible to control lots of LED displays without needing too many output pins on the microprocessor – just seven for the LED segments which are connected in parallel, and one for each display’s ground connection (if you use common cathode LED displays).