Introduction: Lewekas - a Homemade Incubator

About: Student NMCT at Howest (Kortrijk Belgium)

Hello reader,

In this instructable i will try to show you in a few steps how i made my very own incubator. This incubator comes with an application (run on a Raspberry Pi) that will let you start and end cycles with the incubator. You chose the sort of egg you will put in the incubator and the incubator knows what temperature and humidity is best for that sort of egg. It will adjust it's temperature automatically. It will send an e-mail to you if the humidity becomes to low / if the motion sensor detects movement (eggs hatching*). On the application you can see every bit of information regarding a current cycle. There is also a LCD-screen on the incubator that cycles between current temperature and humidity.

The cost of building this will be around 280 euro's. I recycled most of the used materials so i only spend around 120 euro's. The cost will also vary, depending where you buy the needed materials.

I included a Bill of Materials so you can see what i recycled, bought and stores where everything can be bought. Keep in mind that there are some local stores in that list that may or may not deliver international.

My code is available here on Github.

Step 1: Materials & Tools

To make this incubator you'll need alot of materials. In the lists below you can find everything i used to make this. I've put the exact dimensions of the plates i used between brackets. You can ofcourse use plates with other dimensions. Just make sure the plates are big enough to make everything.

Parts for the incubator

  • Plates of plywood (9mm thick) (i bought 1 plate: 122 x 244 x 9mm)
    • 2 x 55 x 46 (floor/roof)
    • 2 x 46 x 39,7 (left/right-sides)
    • 1 x 53,2 x 39,7 (back)
    • 1 x 53 x 39,5 (door)
    • 2 x 42,2 x 39,7 (left/right-sides inside)
  • Plates of plywood (5mm thick) (i bought 1plate: 61 x 122 x 5mm)
    • 2 x 37,4 x 39,5 (floor/roof inside)
    • 1 x 37,4 x 39,7 (back inside)
  • Hardwood battens (1 x 1,5)
    • 4 x 40,9 cm long (roof/floor)
    • 2 x 39,7 cm long (back)
    • 4 x 39 cm long (support shelves)
  • Hardwood battens (1,5 x 1,5)
    • 4 x 38,8 cm long (shelves)
    • 4 x 37,2 cm long (shelves)
  • Styrofoam plates (20mm thick) (i bought 2 plates: 60 x 120 x 20mm)
    • 2 x 42,2 x 39x7 (left/right-sides)
    • 2 x 37,4 x 39,5 (floor/roof)
    • 1 x 53 x 39,5 (door)
    • 1 x 37,4 x 39,7 (back)
  • A roll of chickenwire ( mesh: 6mm )
  • 2 door hinges (small ones)
  • 1 bolt lock ( i used 2)
  • Plexiglass (2mm thick)
    • 2 x 37,2 x 34,5 (door-window)
    • 1 x dimensions to fit inside a junction box
  • bolts, screws and wood glue

Electronic parts

  • 1 heating element (230V)
  • 2 fans (12V)
  • 2 lightbulbs
  • 1 raspberry Pi, model B with a micro SD-card (16G)
  • 1 transformer (230V AC to 12V DC)
  • 1 relayboard (you need 3 relays)
  • 1 DHT22 (temperature- and humidity sensor)
  • 1 door switch ( a little but strong button will do)
  • 1 motion sensor
  • A bunch a cables
  • A socket
  • A plug
  • A couple of standoffs
  • An electric cable (for the plug)
  • An electric junction box
  • 1 LCD-screen with a potentiometer (i used 1K)

Tools

  • Screwdrivers
  • Soldering iron with tin
  • A saw or other tool to saw the wooden planks
  • Pliers
  • A drill
  • A knife
  • An extra pair of hands

Optional

  • Paint

Step 2: Making the Case

I started by making the outer box. To do this i used plywood (9mm thick).

You'll need the following parts:

  • top & bottom panels (55 x 46)
  • left & right side panels (46 x 39,7)
  • back panel (53,2 x 39,7)

First i put the top, bottom, left and right side together. When the glue on those parts dried, i put the back panel in. This should fit perfectly inside the 4-part casing. I used screws and glue to put these parts together.

We now have a box without a front-panel (door).The door will be placed later to be able to work easier inside the box.

It's time to start on the inside. First i placed the battens (1 x 1,5) 5cm from the sides (see picture). The battens with a length of 39,7 cm should be attached on the backpanel (1 left & 1 right). After that i placed the battens with a length of 40,9 cm on the top and floor panels. I used glue to stick these into place.

Step 3: Making the Inner Box

For the moment we have our case (without door) with battens on the inside placed 5 cm from the left and right side. These battens will keep the inner box in place. We now need to make the panels for the inner box. To do this we need the following:

  • all plywood panels (5mm thick) (2 x 37,4 x 39,5) (1 x 37,4 x 39,7)
  • both plywood panels (9mm thick) (42,2 x 39,7)
  • corresponding styrofoam panels (the same dimensions).

First i glued the 5 plywood panels onto the 5 corresponding styrofoam panels. When the left and right side dried i drilled a hole through these. This hole should be the same diameter as the fans you will use. Make sure the holes are not to high or to low. I recommend drilling the hole 5 - 6 cm from the top, depending what size the fans are. On these side panels i also glued the 4 remaining battens (1 x 1,5). There should be 2 on each side. These will be used as support for the shelves. Because these will need to carry weight, i also used screws for these. You can chose how high or low you place them. Make sure they are not TO high tho (to close to the heat source). I placed the lowest battens 6 cm of the bottom and i left 4 cm of space in between them.

When these parts are dry, place the left & right panels inside the case (see picture). You may need an extra pair of hands to hold these, when you fit the back panel in between them. After the back panel, you can fit the bottom panel in to. The styrofoam should always be on the outside. I didn't use any glue or screws to keep the sides and bottom into place. Then place the top panel in, and use screws to attach it at the ceiling of the case. By doing this all the other panels should not be able to move anymore.

Step 4: Making the Door and Shelves.

There should still be a 3cm gap between the inside box and the front of the outer case (picture). This is for the door.

First we need to cut a square hole in the remaining plywood panel (9mm thick) (53 x 39,5). I made the hole 25 cm wide and 15,5 cm heigh. I used these dimensions to be able to make the window in the middle of the door. When the hole has been made, place a piece of plexiglass (37,2 x 34,5) over the hole. Take the styrofoam plate with the same dimensions as the door and cut the same hole in the same place as in plywood. Then glue the styrofoam over the plexiglass on the door panel. When it's dry, take the second piece of plexiglass (37,2 x 34,5) and attach it to the styrofoam, over the hole. I used screws to do this last part.

The door is then complete. To fit the door in the case, i may need to scuff some styrofoam away. Don't scuff away to much or else it won't isolate as good anymore. When you get a good fit, attach the door on the case with the hinges and attach the bolt lock on the door.

When the door is done we can start with the shelves. We need to use all 8 battens (1,5 x 1,5). I made my shelves 38,8 cm long and 37,2 cm wide, but your shelves may vary on how precisely you made the inner box. When you have the 'squares', cut the chickenwire in the same dimensions and staple it on the frame.

Congrats, you now finished your case!

Step 5: Schematics

These are the schematics i made and used to connect all the hardware with the Raspberry Pi.

Step 6: Add the Hardware

With the case done we can start adding some hardware. First we will need to remove the ceiling panel. In this panel i first drilled a little hole in the middle. I attached the heating element over the hole with screws and put the wires through the hole. then i drilled 2 bigger holes (1 right and 1 left) to fit the lightbulbs. The motion sensor i placed between the lights. On the other side of the panel i cut away the styrofoam to be able to lay the wires. On the front right i placed the door button. At the left and right side i made little holes for the wires from the fans and in the back left corner i made a little hole for the wiring for the DHT22. Then i made one bigger hole through the case to put all the wires through.

Step 7: Connecting Everything

With all the wires in place i first attached the ceiling panel back on the top. I then placed a big junction box on top of the case to store all the electronics and keep them safe.

Now i cut and placed plexiglass in the junction box. I used this to attach the Raspberry Pi, the Relay board, the tranformer and the socket. I connected all the wires like it's been described in the schematics.

I also added an LCD-display 16 * 2 by cutting a hole in the junction box. I used glue to keep it in place. unfortunately i didn't add this to the schematics. But here you can learn how to connect this to your raspberry pi. These are the GPIO pins i used to connect the LCD:

  • RS--------------------9
  • E----------------------11
  • DB4 to DB7--------6, 13, 19, 26

Step 8: Installing Raspbian Jessie

To use our Raspberry Pi, we need Raspbian Jessie on the SD card. You can find and download raspbian here. I chose for Raspbian Jessie with Pixel. To install this on the SD card, i used Win32DiskImager. After installing Win32DiskImager, open it up, select the raspbian image that you just downloaded and select the SD card (mine was M). Then all you need to do is press WRITE and let it do it's thing.

Step 9: Configuring Raspbian & Installing Required Software

We now have a SD card with raspbian installed on it. Open the folderstructure on your computer and add a file called 'ssh' without extension. This will enable you to connect with the pi through SSH.

Plug the SD card in the pi and boot it up. Connect the pi with ethernet and now you should be able to find it's IP-address on your router. Once you know it's IP, you can connect to the pi with Putty. The default user is 'pi' and the password is 'raspberry'.

(If you don't have an ethernet cable at hand you can also directly connect a screen and mouse / keyboard with the pi.)

When you are logged in the first thing you'll want to do is change your password. This can be done by typing:

sudo raspi-config

You can also change the name of the pi here. After you changed your password reboot the system. Next step is to update your system. You can do this by typing:

sudo apt-get update && sudo apt-get upgrade

After this is completed you should install the following packages:

  • python3
  • flask
  • flask-mail
  • netifaces
  • Adafruit_DHT
  • mysql-server
  • mysql-client
  • mysql-connector

After installing mysql you will be prompted to give and confirm a password. Don't forget this!

Step 10: Configuring Mysql

To open mysql type the following:

mysql -uroot  -p

You will need to enter the password you chose in the previous step. Now we will create a new user by typing the following:

CREATE USER '[username]'@'%' IDENTIFIED BY '[password]';
GRANT ALL PRIVILEGES ON *.* TO '[username]'@'%';

After this you will want to flush the privileges to make sure they take effect:

FLUSH PRIVILEGES;

Now we will create a database. I called mine 'lewekas'

CREATE DATABASE lewekas;

To make the actual database i recommend you use MySQL Workbench. Try and make the database as it's shown in the picture. Make sure everything is named correct and everything is on the right row in the tables.

You'll need to insert data into 3 different tables: user, incubators and species. You'll find the required data on Github under Db_Table_Data. If you want you can change the data in the user table to change your username, password and email address. The password is encoded with base64. With a quick google search you can find many sites that let you encode and decode this.

Step 11: Installing Lewekas Software

You can download the code by typing the following:

git clone <a href="https://github.com/JonasBoecquaert/Lewekas.git"> https://github.com/JonasBoecquaert/Lewekas.git</a>

Before you can use the code you will need to edit some files first. First you will need to edit DbClass.py. There you need to change the user (username you chose), the password and if necessary the database-name (picture).

Then you'll need to open Lewekas.py. Here you'll want to insert your mailserver, port, your email address and your password. At the end of the script you'll once more need to insert your email address. It's possible your email uses something other then TLS. In that case you'll need to change MAIL_USE_TLS to 'False' and add the following line:

MAIL_USE_SSL=True

More information about this you can find here.

Now you may or may not want to change the following. If you want to use the pi with Wifi then you should change something in the Lewekas_Script.py. On line 36 you'll need to change 'eth0' to 'wlan0'. When you use the incubator with ethernet you should let this unchanged. Also if you used other GPIO pins to connect your LCD-display you'll need to change those on line 28 in Lewekas_Script.py.

To make these scripts start at boot, edit rc.local. You can do this by typing the following command:

sudo nano /etc/rc.local

Add the following lines just above exit 0:

sleep 5
python3 /path/Lewekas_Script.py > /path/output_Lewekas_Script.txt &
python3 /path/Lewekas.py > /path/output_Lewekas.txt &

I included the '> /path/output.txt' because if something goes wrong, you'll find what in these textfiles. I recommend you use these, because if you forget to change an emailaddress or password somewhere the script won't work. With this you'll be able to find the problem.

Now reboot the pi. After a while the IP address should appear on the LCD-screen.

Step 12: The Code

I'll explain some of the code here.

The website - Flask

I used python - flask as a framework to get HTML and CSS content on pages. I used Javascript to make the site update some variables every second so you'll see the most recent data regarding your current incubator cycle. To make the website i used bootstrap.

The main script

I used python to write the main script. It works as follows. First i declare al needed variables. After this is done i start an unending loop. In this loop i write the current IP-address to the LCD-display so the user knows where to find the website. In the database i'm keeping the active state of the incubator. If a user changes this state from 0 to 1 (by using the website), then a second loop starts. First i declare some more variables that have to be set back to default once a cycle is complete.

In the second while loop i look in the database which species the user has chosen. There i can also find optimal temperature and humidity for that species. I read the current temperature/humidity in the incubator and i match it with the target. If the temperature is to low, lamps and heating element will turn on. If the humidity keeps to low/high for a certain amount of cycles then an email will be send to the user. So this cycle continues. temperature goes up until it reaches the target, then everything shuts down, temperature drops, and after a while lamps go back on to raise the temperature again.

If the door opens i turn off the heating element for safety. You rather not burn yourself on that. I put the lights on to see better.

Every second all the data will be send to the database, where the site can reach it and display it on the pages.

I also keep looking at the state in the database. From the moment the user presses STOP in the website, the state will go back to 0, the loop will end and will go back to the first loop.

All the code can be found on Github.

Step 13: Using the Website

When you enter the IP-address shown on the LCD in your browser you should get the following login screen. There you will need to enter the username and password you edited in the database. If you left it default it should be 'admin' for both the username and password.

When you login, you'll be on the homepage. Here you can see the 9 or less last cycles ( if you have them) and you can start a new cycle. When you want to start a new cycle press start and this will open a popup. Here you can chose a species and the number of eggs you want to place inside the incubator. If you swap the species, you'll see in the right side that the data displayed there will change accordingly. When you press start the incubator should start running. On the left you can see all information regarding the current cycle. When your eggs hatched and you want to stop the incubator, simply press stop.

I also included a contact page (this does nothing but put your message in the database) and a bird list page. Here you can find all species included in the database with their corresponding data. If you want to add birds to this list you can by simply adding them to your database.

Step 14: How Do I Use This?

Plug and play!

Well not actually, just plug the incubator in, and wait for the IP-address to appear. Then go to the website (explained in previous step) and start incubating your eggs! :D

Step 15: Problems I Faced

This project wasn't easy to build and certainly wasn't build without any errors or bugs.

I had/have alot of problems with the door. Because the incubator is made of wood, it kinda lives. The door fitted perfectly in the beginning. But after a while i had to use alot of musclepower to open or close the door. My doorsensor also didn't always connect with the door, which means that even if the door was closed, it still said it was open. Which as a result meant my heating turned off. I now have 2 bolt locks to make sure the door keeps shut.

The incubator isn't at all good at keeping the heat in. I had to let the program drop the temperature 0.5 °C below the target because otherwise the lightbulbs would go on and off every 15 seconds, which is not a good thing for the relays.

Sometimes the LCD (for no apparent reason) decides to print *alien*language and stop working. I broke my head over this and didn't find a solution. Luckily it seems, that when this happens, after a while the LCD sees reason in my coding and starts printing the things it should.

I also had trouble writing the code for the website and the javascript part. Luckily i had help from 2 mates from who i learned alot.