vilaswkhade
Published © LGPL

IoT - Eggs Incubator

IoT - Eggs incubtor over the internet, with data collection using CavyIoT service

IntermediateFull instructions provided9,355
IoT - Eggs Incubator

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Arduino UNO
Arduino UNO
×1
100 w Bulb filament type
×1
Servo MG995
×1
CPU fan 12 volt
×2
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
LED (generic)
LED (generic)
×1
Humidifier
×1

Story

Read more

Schematics

Circuit connection details

Code

IoT-Incubator.ino

C/C++
Code for Arduino UNO
#include <Servo.h> 
#include <DHT.h> // library of DHT11 temperature and humidity sensor
#include <CavyIoTdevelopmentBoard.h>
//----------------------Servo Connection---------------------------------------------
#define SERVO 9
Servo myservo;
//----------------------DHT11 connection------------------------------------
DHT dht(8, DHT11);
//--------------------------------------------------------------------------

//---------------For communication with DevBoard ----------------------------
#define rx 10
#define tx 11
#define rst 13
//---------------------------------------------------------------------------
CavyIoT myIoTdevice;       //Create instance of CavyIoT Object.
//---------------------------------------------------------------------------
//----------------Timer and Scheme of Eggs Tray Router-----------------------
int routerScheme=1;
long int current_time;
long int start_time=millis();
long int Interval=6*60*60*1000;//Timer Six hour
//Interval=60000;//Uncomment for checking servo functions TimerOne minute.
//---------------------------------------------------------------------------
//--------------------- Sensor Variables ------------------------------------
float temp;
float hum;
int  angle;
//--------------------------------------------------------------------------
void setup()
  {
   Serial.begin(9600);
   myIoTdevice.SetPort(rx,tx,rst);
   dht.begin();
   myservo.write(45);
   myservo.attach(9);
    myservo.detach();
     
//--------------------- Button Labels----------------------------------------   
  Serial.println("Setting device buttons!.");             
   myIoTdevice.DefineButtonLables
               ( "Heat",   "on",  "off",
                 "Humid",  "on",  "off",
                 "E-Fan",  "on","  off",
                 "I-Fan",  "on",  "off"
                 );
  Serial.println("Wait for a while to connect!");
  /*------To start Device replace your own credentials here-----------------------------*/ 
  myIoTdevice.StartDevice
  /*Your Wi-Fi router->*/("WiFi-SSID","WiFi-password",
   /* CavyIoT------>*/"Username","password","Device");//
 //--------------------------------------------------------------------------
   }

void loop()
  {
    current_time=millis();                                   
    myIoTdevice.loop();  //Updates the Status variable.                           
   //--------------------------------------------------------------------- 
    /* Prints the current status of Buttons & working mode of device from          control panel on  Serial monitor.*/
   Serial.println("Device Status:-"+myIoTdevice.Status);
   
   //---------Read values from sensor and angle of servo---------------------
  
   temp=dht.readTemperature();
   hum=dht.readHumidity(); 
  
   //----------------Sending data to server----------------------------------
   myIoTdevice.UpdateSensorData
      ( "Temperature",String(temp),  "C",
         "humidity",  String(hum),   "Rh",
        "Tray-Angle", String(angle), "deg"
      );
 //-------------------Check timer for router scheme-------------------------
   if(current_time-start_time>Interval)
        { myservo.attach(9);
         rotateTray(routerScheme);
         start_time=current_time;
         //Uncomment for debug 
         //Serial.print("Servo is working ,router scheme :");
         //Serial.println(routerScheme);
         
        } 
 //-------------------------------------------------------------------------
 

}//End of loop
 //-----------------------------------------------------------------------  

/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////  
void rotateTray(int scheme)
{ int current_position=myservo.read();

  if (scheme==0)
  {     
    for(current_position;current_position <=45;current_position+= 1) 
     {  angle= current_position;                               
      myservo.write(current_position);  // tell servo to go to position                                              // variable 'current_position' 
     delay(50);                     // for smoother movement of Servo.
      
     }
     
  }
if (scheme==1)
  {
    for(current_position;current_position <=90;current_position+= 1) 
     {angle= current_position;                                    
      myservo.write(current_position);  // tell servo to go to position                                              // variable 'current_position'
     delay(50);                         // for smoother movement of Servo.
     
     }
  }
if (scheme==2)
  { 
    for(current_position;current_position >=45;current_position-= 1)
     { angle= current_position;                                  
      myservo.write(current_position);   // tell servo to go to position                                              // variable 'current_position' 
     delay(50);                          // for smoother movement of Servo.
     
     }
  }
 if (scheme==3)
  {
    
    for(current_position;current_position >=0;current_position-= 1) 
     {
      angle= current_position;                                   
      myservo.write(current_position); // tell servo to go to position                                              // variable 'current_position'
     delay(50);                        // for smoother movement of Servo.
     
     }
   }
   
  routerScheme=routerScheme+1;
  myservo.detach();
  if(routerScheme>3)routerScheme=0;  
}

Credits

vilaswkhade

vilaswkhade

3 projects • 15 followers

Comments