The Last Chicken

 

Hello everyone.

This post talks about the software that we use for the project “Automated Chickenhouse”.

To remind you, we are using an Arduino and a Raspberry pi.

To do that we use different IDE to code respectively in C++ and python 2.

The Arduino code:

First of all, let’s take a look on the data and the selection. As you can see we include the math.hon the top and we selected a pin in or out for the different sensors.

On the bottom, we have written the constant that we use for the sensors.

After that, in a first function we set the pins and the serial connection up.

At the beginning of the code we have a function called readDHT11

Thence, we use a loop function to read the sensors. Let’s have a closer look.

The temperature and humidity sensor:

For the temperature and humidity sensor we call the function readDHT11 and then return the data to the raspberry pi with the serial connection.

The light level :

The Arduino gets the analogic data which is a photo resistor. Thence we compare the level of brightness with the level that we had set up (here at 600) and we use this level (high or low) to activate the motors.

The counter of chickens:

We use two infrared sensors to know if the chicken goes in or out. To do so, we have an if condition in a do…while loop that is include in another if condition. All of thattakes the data from the first sensor and wait for the second. We also have a security in the loop if the chicken makes a U turn.

The water level and the seed level:

The ultrasonic sensors are set at high and then low. Then we wait for the echo and take the minute. Finally, we multiply half the time by the speed of sound in the air to have the distance. We send that final data to the raspberry pi.

The raspberry code:

Firstly, we import the Libraries that my colleague told you two videos before.

Secondly, we import the data from the Arduino by a serial connexion and get them on a table.

In the next function, we use the time of the computer to display it on the screen.

The Last function is the biggest one. In this one we create boxes for the display on the screen. Then we manage them and add text and images on the frames.

We can see the result on this image.

That’s all for today. See you soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s