Project showcase
A.S.C.H. (Automatic Safe Chicken House)

A.S.C.H. (Automatic Safe Chicken House)

Do you have experienced? Your wife wants chickens but you say that it is too much work. This problem is now solved by our project A.S.C.H.

  • 6,979 views
  • 2 comments
  • 27 respects

Components and supplies

Apps and online services

SmartLiving

About this project

A.S.C.H. (Automatic safe chicken house)

We are Ruben Smid and Thomas De Zaeyer. We follow the fifth year industrial engineering V.T.I. in Veurne. We have realized the project A.S.C.H.  to give people  with chickens an easier life.. we automate the chicken coop First we make  sure  that the chickens come in in the evening and are not  attacked by predators. Then, we ensure that the chickens get get food and drink automatically and  sent a shortage of food and drink. It is also intended to check the freshness of the eggs by keeping track of when the eggs have been laid.

We program or systems with Arduino because it’s easy to use.

We use a daylight sensor to open the door when its day and close the door in the evening.

For the eggs-system, its simple a pushbutton and a motion sensor. When the motion sensor don’t see a chicken and the pushbutton is pushed in, there wil be blink a led.

We have also a system that detect the fresh air in the coop. when the gas sensor detect to match bad air, on your phone there will be a signal.

The food system is just a motor that we don’t have a the moment and that will rotate a mill that give the chickens just enough food for the day.

Code

A.S.C.H.Arduino
It Works
/*

Arduino UART Demo Sketch. This Sketch is made for an Genuino 101 IoT board with a Grove
UART WiFi module based on the popular ESP8266 IoT SoC to communicate to the AllThingsTalk
IoT developer cloud.
The Grove UART WiFi module has firmware installed which includes the ATT_IOT library. It
communicates through Serial1 of the Genuino 101 board.

Version 1.0 dd 26/12/2015

This sketch is an example sketch to deploy the Grove Button (101020003) to the
AllThingsTalk IoT developer cloud.


### Instructions
1. Setup the Arduino hardware
  - Use an Arduino Genuino 101 IoT board
  - Connect the Arduino Grove shield
  - Connect USB cable to your computer
  - Connect a Grove Button to pin D2 of the Arduino shield
  - Grove UART wifi to pin UART (D0,D1)
2. Add 'ATT_IOT_UART' library to your Arduino Environment
     More info can be found at http://arduino.cc/en/Guide/Libraries
3. Fill in the missing strings (deviceId, clientId and clientKey) in the keys.h file
4. Optionally, change sensor names, labels as appropiate
5. Upload the sketch

Note: for use of extra actuators, extend the callback function at the end of the sketch

*/

#include "ATT_IOT_UART.h"      // AllThingsTalk Arduino UART IoT library
#include <SPI.h>               // Required to have support for signed/unsigned long type
#include "keys.h"              // Keep all your personal account information in a seperate file

ATTDevice Device(&Serial1);
char httpServer[] = "api.smartliving.io";          // HTTP API Server host
char mqttServer[] = "broker.smartliving.io";       // MQTT Server Address

// Define PIN numbers for assets
// For digital and analog sensors, we recommend to use the physical pin id as the asset id
// For other sensors (I2C and UART), you can select any unique number as the asset id
              // Digital sensor is connected to pin D2 on grove shield

// Required for the device
#include <ATT_IOT_UART.h>
#include <SerialCommands.h>
#define PIR_MOTION_SENSOR 2//Use pin 2 to receive the signal from the module 
#define LED  4//the Grove - LED is connected to D4 of Arduino

const int buttonPin = 8;     // the number of the pushbutton pin
const int ledPin2 =  4;      // the number of the LED pin

const int switchPin = 3;
const int ledPin4 = 5;

// variables will change:
int buttonState = 0;   

bool b = 0;
#include <math.h>                    // lightsensor in A0
const int ledPin=6;                 //Connect the LED Grove module to Pin8, Digital 8
 
const int thresholdvalue=100;         //The threshold for which the LED should turn on. 
float Rsensor; //Resistance of sensor in K
int pushButton = 7;



void pinsInit()
{
  pinMode(PIR_MOTION_SENSOR, INPUT);
  pinMode(LED,OUTPUT);
}
void turnOnLED()
{
  digitalWrite(LED,HIGH);
}
void turnOffLED()
{
  digitalWrite(LED,LOW);
}

boolean isPeopleDetected()
{
  int sensorValue = digitalRead(PIR_MOTION_SENSOR);
  if(sensorValue == LOW)//if the sensor value is HIGH?
  {
    return true;//yes,return true
  }
  else
  {
    return false;//no,return false
  }
}

void callback(int pin, String& value) 
{ 
    Serial.print("Incoming data for: ");               // Display the value that arrived from the AllThingsTalk IOT developer cloud.
    Serial.print(pin);
    Serial.print(", value: ");
    Serial.println(value);
    Device.Send(value, pin);                           // Send the value back for confirmation   
}


void callback(int pin, String& value);                //this is for smartliving. we can see how bad the frsh air is.
  #define gasId 0
    
bool sensorVal = false;

void SendValue()
{
  if(sensorVal){
    Serial.println("Motion detected");               // The void for or gas sensor. It says when the sensor is false or true
    Device.Send("true", motionId);
  }
  else{
    Serial.println("Motion stopped");
    Device.Send("false", motionId);
  }
}

void setup()
{

pinMode(switchPin, INPUT);

pinMode(ledPin4, OUTPUT);

digitalWrite(switchPin, HIGH);

  Serial.begin(57600);                                 // Init serial link for debugging
  while(!Serial && millis() < 1000);                   // Make sure you see all output on the monitor. After 1 sec, it will skip this step, so that the board can also work without being connected to a pc
  Serial.println("Starting sketch");
  Serial1.begin(115200);                               // Init serial link for WiFi module
  while(!Serial1);

  while(!Device.StartWifi())
    Serial.println("Retrying...");
  while(!Device.Init(DEVICEID, CLIENTID, CLIENTKEY))   // If we can't succeed to initialize and set the device credentials, there is no point to continue
    Serial.println("Retrying...");
  while(!Device.Connect(httpServer))                   // Connect the device with the AllThingsTalk IOT developer cloud. No point to continue if we can't succeed at this
    Serial.println("Retrying");

  Device.AddAsset(gasId, "Gas sensor (MQ2)", "gas", false, "number");   // Create the sensor asset for your device


  delay(1000);                                         // Give the WiFi some time to finish everything
  while(!Device.Subscribe(mqttServer, callback))       // Make sure that we can receive message from the AllThingsTalk IOT developer cloud (MQTT). This stops the http connection
    Serial.println("Retrying");
    
  pinMode(gasId, INPUT);                               // Initialize the digital pin as an input.
  Serial.println("Gas sensor is ready for use!");
  
}


void loop() {

if(digitalRead(switchPin) == HIGH){                 //This is for the door. when 2 magnets doesn't toush each other then is the door closed.

digitalWrite(ledPin4, LOW);

}

else{

digitalWrite(ledPin4, HIGH);

}

 bool sensorVal = true;
float voltage = 5.0;
 


 pinsInit();

  int sensorValue = analogRead(0);                      //if the sensor says:'its day', a led wil turn on for 2 seconds. we don't have a motor at the moment so we use a led for exampel. 
  Rsensor=(float)(1023-sensorValue)*10/sensorValue;
  
  if((b == 0) && (Rsensor>thresholdvalue))  
  {
    b = 1;
    digitalWrite(ledPin,HIGH);
    delay(2000);
  digitalWrite(ledPin,LOW);
  }

  if((b == 1) && (Rsensor<=thresholdvalue))
  {
    b = 0;
    digitalWrite(ledPin,HIGH);
    delay(2000);
  digitalWrite(ledPin,LOW);
  }
  
  Serial.println("the analog read data is ");
  Serial.println(sensorValue);
  Serial.println("the sensor resistance is ");
  Serial.println(Rsensor,DEC);//show the light intensity on the serial monitor;
    /////////////////////////////////////////////////////////////////////////////////////////////
   


  delay(1000);
buttonState = digitalRead(buttonPin);
  
   if(isPeopleDetected() && buttonState == HIGH )//if it detects the moving people and the button is pushed in.
    turnOnLED();
  
  

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  
   else {
    // turn LED off:
    digitalWrite(ledPin2, LOW);
  }
{
  float sensor_volt; 
  float RS_air; //  Get the value of RS via in a clear air               
  float R0;  // Get the value of R0 via in H2
  float sensorValue = 0.0;
 
  for(int x = 0 ; x < 100 ; x++)                                //this is the gas sensor system. its just measurement and place its on smartliving.
  {
    sensorValue = sensorValue + analogRead(A1);
  }
  sensorValue = sensorValue/100.0;
 
  sensor_volt = sensorValue/1024*voltage;
  RS_air = (voltage-sensor_volt)/sensor_volt; // omit *RL
  R0 = RS_air/6.5; // The ratio of RS/R0 is 6.5 in a clear air from Graph (Found using WebPlotDigitizer)
 
  Serial.print("sensor_volt = ");
  Serial.print(sensor_volt);
  Serial.println("V");
 
  Serial.print("R0 = ");
  Serial.println(R0);
  delay(1000);

  Device.Send(String(R0), gasId);
  
  Device.Process(); 
}
}

Custom parts and enclosures

3D 1.png
3d%201
3D 2.png
3d%202

Schematics

Comments

Similar projects you might like

MultiFunctional Clock

Project in progress by 3 developers

  • 16,942 views
  • 2 comments
  • 28 respects

Chicken Coop Automation

Project in progress by BMic

  • 11,260 views
  • 12 comments
  • 28 respects

The Train of the Future

Project showcase by Team STT

  • 17,018 views
  • 5 comments
  • 22 respects

IoT@School: An IoT Implementation for Monitoring Air Quality

Project showcase by Koen Kempeneers

  • 7,129 views
  • 1 comment
  • 27 respects

The Inventive Toothbrush

Project showcase by Ruben Mortier

  • 12,102 views
  • 4 comments
  • 12 respects

Plant Assistant

Project showcase by Team Vitronics

  • 4,004 views
  • 0 comments
  • 37 respects
Add projectSign up / Login