We create a fully automatic farm

    We continue to review the activities of our Hackspace Club .

    The idea was born to make a very practical thing, an automatic farm. The fact is that we live in Siberia and often go on vacation to the Crimea. We have a mini-hotel on the seashore, and so that it wouldn’t stand idle for most of the year, we decided to make a farm near it; And since we live 4500 kilometers from the Crimea, we need to make the farm fully automated with remote control and video surveillance.



    To begin with, I think we’ll get chickens, at least my parents kept chickens, I know how to care for them.
    They decided to make the brains on the Raspberry Pi, there was no time to bother with the controller, (after a week of vacation, I’m going to the Crimea), I need to fasten the Internet to it for control. And the Raspberry Pi already has everything on board.
    Immediately set up a watchdog timer, the so-called WatchDog (watchdog), so that when the system freezes, the Raspberry Pi reboots automatically. The setup process will not be described in detail about this can be read, for example, here .

    As an engine driver and water supply valves, an assembly on the l298n chip was used. DC motors with gearbox. We use the valve for water supply from the 220 volt washing machine. Now they ordered 12 volts, it’s safer, you never know what chickens wanders about.

    It turned out like in the photo:



    There are no tricks here. Each driver receives 4 signals from the CPIO Raspberry Pi and gives an amplified logical 0 or 1 for the engine or valve.

    We used three engine driver assemblies; we got 12 outputs for connecting engines and water valves. Feedback at the initial stage of the construction of the farm is not expected. Control will be carried out by video camera. In the future, it will be necessary to control the current of the engines, so that it would be possible to automatically turn on the reverse, or stop the engine in case of a jam and control the water level in the drinker.

    The program was written in C using the WiringPi library, it is easy to find on the Internet. The program reads the system time in an endless cycle, and if it is 6 o’clock in the morning, 12 in the afternoon or at 19 p.m., it turns on the water supply valve in series - it fills the drinkers from the water pipe, the engine of one feed, the engine of the second feed and the third to diversify the diet pets.

    Program listing.

    full code can be found here.
    /*  cc -o kura kura.c -L/usr/local/lib -lwiringPi
     * kura.c:
     *     
     */
    #include 
    #include 
    #include 
    #include 
    int main (void)
    {
    for(;;)
    {
         time_t rawtime;
         struct tm * timeinfo;
         time ( &rawtime );
         timeinfo = localtime ( &rawtime );
         printf ( "datetime %s\n", asctime (timeinfo) );
        int tt_hour = timeinfo->tm_hour;
        int tt_min = timeinfo->tm_min;
        int tt_sec = timeinfo->tm_sec;
         printf ( "hour - %d\n", tt_hour);
         printf ( "min - %d\n", tt_min);
         if ((tt_hour == 06 & tt_min == 01 & tt_sec == 01) || (tt_hour == 12 & tt_min == 01 & tt_sec == 01) || (tt_hour == 19 & tt_min == 01 & tt_sec == 01))
        {
         korm(25);
         printf ( "datetime %d\n", tt_hour);
        }
    }
      return 0;
    }
    int korm (int _p)
    {
      printf("korm0\n");
    // 1 draiver motora
      int pin0 = 0;    //11 noga
      int pin1 = 1;    //12
      int pin3 = 3;    //15
      int pin4 = 4;    //16
    // 2 draiver motora
      int pin7 = 7;    //7 noga
      int pin5 = 5;    //18
      int pin6 = 6;    //22
      int pin10 = 10;  //24
    // 3 draiver motora
      int pin11 = 11;   //26 noga
      int pin12 = 12;   //19
      int pin13 = 13;   //21
      int pin14 = 14;   //23
      int i;
      if (wiringPiSetup() == -1)
        return (1);
      pinMode(pin0, OUTPUT);
      pinMode(pin1, OUTPUT);
      pinMode(pin3, OUTPUT);
      pinMode(pin4, OUTPUT);
      pinMode(pin7, OUTPUT);
      pinMode(pin5, OUTPUT);
      pinMode(pin6, OUTPUT);
      pinMode(pin10, OUTPUT);
      pinMode(pin11, OUTPUT);
      pinMode(pin12, OUTPUT);
      pinMode(pin13, OUTPUT);
      pinMode(pin14, OUTPUT);
      printf("korm1\n");
    for(i = 0; i <= _p; i++)
    {
    //    digitalWrite(pin1, 0);
    //    digitalWrite(pin2, 0);
        digitalWrite(pin0, 0);
        digitalWrite(pin1, 1);
        printf("Motor On\n");
        delay(4500);
    //    digitalWrite(pin1, 0);
        digitalWrite(pin0, 0);
        digitalWrite(pin1, 0);
    //    digitalWrite(pin14, 0);
        printf("Motor Off\n");
        delay(1500);
    }
    return (0);
    }
    


    Later it is easy to change the program, just remotely go to Raspberky Pi to kill the process and start a new program that will give, for example, one feed in the morning, another in the evening.

    I saw many designs of bunker feeders on the Internet without any electronics such as this:



    They have one big drawback, they need to be fed a variety of feeds, and with such a feeder, they will eat the most delicious food from the beginning, for example in a month, and then there will be the remaining 2 months eat another feed. Again, food caking, when it ceases to arrive at all and there are probably still disadvantages ...

    They decided to make the design of the feeder through general discussion on the basis of a vertical screw. If you just do the opening of the flapper or the horizontal auger under the hopper, then the feed can be caked, and with a vertical auger there is a chance that the feed will be stirred.



    In addition, I’ll think about putting the engine to vibrate the hopper.
    I will turn it on as a separate program, remotely, if necessary.
    The engines decided to connect, so that it would be possible to turn on the reverse. Although it is wasteful for the Raspbery Pi to use two CPIO outputs for one DC motor, there is a reverse that will allow you to do something when stuck.
    Total of 12 CPIOs - 8 for auger engines 2 for main and backup water supply and 2 for vibromotors. Maybe on the spot during the installation process we will change something.
    Next time we will go to the Crimea in July, that is, the farm should work in automatic mode for three months. We calculate the required amount of feed:
    One chicken needs an average of 150 grams of feed per day, 3 months 13.5 kg, 10 chickens eat 135 kg in 3 months. In the end, it is enough to make three feeders of 50 kg. Well, I’ll do one more for the reserve, which we will include remotely if necessary.
    I’m going to take chickens for a month or two months, they don’t carry eggs for up to 5 months, so I don’t have to pick up a robot yet.
    I’ll make the chicken coop floor out of the net, under it there is an oblique profiled sheet, along which all the waste will drain into the boil-out.
    Prepared thorough brackets for the motor. Ordered and already cooked:



    I will look for feed containers on the spot, maybe I will order a tinsmith to make huge funnels.

    Prepared several couplings and engines. Engines for 12 volts, 20-35 RPM, torque 10 kg / cm. and others at 150 RPM torque of 5 Kg / cm.



    Moreover, the imperfection of home-made couplings will benefit the feeder. Excess beating, long bolts will not allow the feed to cake.

    In the laboratory, everything is debugged, it works. How in practice this will work, some hens know. But in any case, starvation does not threaten them, if I see something is wrong on the cameras, our relatives live 30 kilometers from the mini-hotel. I’ll call, they will come and save our living creatures.

    Also popular now: