Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views6 pages

Gunawan Smart Farm RTOSv 2

This document discusses the development of a smart chicken poultry farm using an RTOS (real-time operating system) on an Arduino board. Key sensors will monitor levels of ammonia, carbon dioxide, humidity and temperature in the chicken house. Exhaust fans and a heat lamp will regulate the environment based on sensor readings to maintain optimum conditions for chicken growth. The use of an RTOS on the Arduino allows for real-time task scheduling and priority-based processing that improves response time compared to a non-RTOS system. The goal is to precisely control the farm environment for increased production while minimizing environmental impacts and risks to chicken and human health.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views6 pages

Gunawan Smart Farm RTOSv 2

This document discusses the development of a smart chicken poultry farm using an RTOS (real-time operating system) on an Arduino board. Key sensors will monitor levels of ammonia, carbon dioxide, humidity and temperature in the chicken house. Exhaust fans and a heat lamp will regulate the environment based on sensor readings to maintain optimum conditions for chicken growth. The use of an RTOS on the Arduino allows for real-time task scheduling and priority-based processing that improves response time compared to a non-RTOS system. The goal is to precisely control the farm environment for increased production while minimizing environmental impacts and risks to chicken and human health.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/340482799

Development of Smart Chicken Poultry Farm using RTOS on Arduino

Conference Paper · August 2019


DOI: 10.1109/ICSIMA47653.2019.9057310

CITATIONS READS

11 2,692

5 authors, including:

Teddy Surya Gunawan Haidawati Nasir


International Islamic University Malaysia University of Kuala Lumpur
314 PUBLICATIONS 2,705 CITATIONS 42 PUBLICATIONS 472 CITATIONS

SEE PROFILE SEE PROFILE

Mira Kartiwi Sma Motakabber


International Islamic University Malaysia International Islamic University Malaysia
191 PUBLICATIONS 2,519 CITATIONS 120 PUBLICATIONS 967 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Teddy Surya Gunawan on 26 May 2020.

The user has requested enhancement of the downloaded file.


Proc. of the 2019 IEEE 6th International Conference on Smart Instrumentation, Measurement and Applications (ICSIMA 2019)
27-29 August 2019, Kuala Lumpur, Malaysia

Development of Smart Chicken Poultry Farm


using RTOS on Arduino
Firs Teddy Surya Gunawan1,2, Mohamad Firdaus Sabar1, Haidawati Nasir3, Mira Kartiwi4, S.M.A. Motakabber1
1
Electrical and Computer Engineering Department, International Islamic University Malaysia, 53100 Kuala Lumpur, Malaysia
2
School of Electrical Engineering and Telecommunications, University of New South Wales, NSW, Australia (Visiting Fellow)
3
Department of Computer Engineering, University of Kuala Lumpur (UniKL-MIIT), 50250 Kuala Lumpur, Malaysia
4
Information Systems Department, International Islamic University Malaysia, 53100 Kuala Lumpur, Malaysia

Email: [email protected]

Abstract— The agriculture sector is one important sector in concentration of ammonia and carbon dioxide should be
either in Malaysia or over the world by cultivating plants and regulated for optimum condition.
livestock. To provide a quality livestock production, i.e. poultry,
the optimum environment must be maintained. Chicken poultry The use of single board computer (SBC) in smart farming
farm is one of the important sectors for food supply. An active has been growing tremendously. In [4], Arduino was used to
monitoring system that maintains the optimum environmental control the environment. Raspberry Pi, Arduino, and smart
conditions, such as level of ammonia, carbon dioxide, humidity, phone were used for environmental control in [5, 6]. In [7], it is
and temperature, can be developed using internet of things (IoT) stated that critical environmental parameters of poultry
for precision agriculture. In this paper, a smart chicken poultry production should be monitored by smart sensors. The use of
farm using real-time operating system (RTOS) on Arduino will smart monitoring system is not limited to poultry farming, but
be developed. The level of ammonia and carbon dioxide will be it can be extended to other livestock animals, hence the terms
sensed using various sensors and exhaust DC fans will be used to precision livestock farming [8].
regulate to the optimum level. Furthermore, the humidity and
temperature will be measured as well and will be controlled by a To improve the existing monitoring system in chicken
DC fan and heat lamp. Experimental results showed that RTOS house [4], RTOS is required to be utilized to have a real-time
on Arduino performs better compared to the non-RTOS on response based on some triggered events. In industrial
Arduino. This is due to the task priority could be assigned in application, RTOS welcomes incoming data and information to
RTOS, in which higher priority task could be completed first. support fast and knowledgeable decision-making [9, 10]. One
of the best and attractive solutions in designing safety-critical
Keywords—smart farm; precision agriculture; IoT; Arduino; real time, low power and fast response time embedded system
RTOS. is using RTOS [11]. Furthermore, FreeRTOS is free open
source, easy and compatible with Arduino microcontroller
I. INTRODUCTION [12]. This environment will make sure all task sensors created
are executed in a given time without causing failure. The
In the last century, agriculture becomes the most important
objective of this paper is to develop a smart chicken poultry
sector in order to maintain food supply due to the increasing of
farm using RTOS on Arduino. It differs with Arduino with
human population. In Malaysia, the basis of economy in the
default environment (non-RTOS), in which all tasks will be
early 21st century are agriculture, forestry and fishing [1]. To
executed in sequence. A single core in Arduino Mega [13] can
maintain the food supply either to Malaysia itself or other
only execute one task/thread at a time. The scheduler in RTOS
countries, the agriculture sector needs to be increased rapidly.
provides a deterministic execution pattern by allowing user to
In Malaysia, chicken meat is the highest poultry consumption
assign priority to each thread of execution.
due to its low price, low cholesterol, and balance nutrition. The
chicken meat consumption per person per year increases from Several sensors are used in detecting temperature,
3.46 kg in 1960 to 34.3 kg in 2005 [2]. humidity, carbon dioxide and ammonia levels [4, 7] in a
chicken house which can cause risk of hazard towards chicken
The main goal in animal farming is to increase the
and human as well. Ammonia also can damage the respiratory
production with minimum negative impact to environment and
system of baby chicks and will degrade the quality of chicken
health of the chicken. Water vapor produced by the hens could
when they are growing up. Furthermore, surrounding
create a more humid environment, in which moist manure
temperature and humidity also affect the growth of chicken
tends to produce more ammonia than dry manure. High
depending on their ages. Baby chicks need the temperature to
concentrations of ammonia are aversive to chickens and can
be about 30℃-33℃ to maintain its body temperature due to
cause damage to sensitive tissues. European Council Directive
lack of feathers. To develop proper air ventilation system and
2007/43/EC stated that the concentration of ammonia (NH3)
maintain the temperature, an exhaust DC fan and heat lamp are
should not exceed 20ppm and the concentration of carbon
used to regulate the environments.
dioxide (CO2) does not exceed 3000 ppm [3]. Therefore, the
II. REAL TIME OPERATING SYSTEM (RTOS) ON ARDUINO Arduino board has only the bootloader to load and run a
A single embedded computer cannot well function without program by default. It can do only one job or process at a time.
an operating system (OS). The function of an OS is to control To enable multitasking in Arduino, RTOS can be used. There
the execution of an application and act as communication are five well known RTOS that has been developed in order to
between the hardware of a computer and program application. make the microcontroller more efficient in term of time
There are three objectives of an OS such as to make computer executing processes. Firstly, FreeRTOS is developed by
convenience to use, to allow all resources in a computer such Arduino itself. In the Arduino IDE, there are many libraries
as main memory, file input and output units as well as file and drivers available, but it has the limitation of only two
system to be managed in an efficient manner. An OS also has functions available which are setup() and loop(). The
the ability to evolve in for future development and easiness and robustness of FreeRTOS have made Arduino can
compatibility without disturbing with services. Before, an perform multiple program or threads. Secondly, DuinOS is one
application programmer who is generating an application of RTOS created by BobotGroup. It is simple little RTOS that
system to be run in a computer is taking wholly responsible for providing simple function scheduling and basic multitasking by
controlling the computer hardware, however, one would be using a sort of round robin algorithm. It allows coding with
faced with an overwhelmingly complex undertaking. To solve multiple functions in a single time, then it will be executed in
the issue, operating system is developed to assist the creation of sequence. Next, ArduinoWill has created RTOS for Arduino
a program, files management, and the controlling I/O devices. named Pyxis OS. This OS provides a graphical interface on top
Hence, OS must able to run all these tasks precisely and of the Arduino and TouchShield platform. ArduinoMacOS has
without errors. The processing unit of a machine or devices successfully managed to port a few apps using this RTOS such
could be affected if the OS has any kind of malfunction. as canvas drawing program, calculator, GPS and games. Lastly,
However, RTOS differs from the General-Purpose Operating another light weight operating system created by Ziplock
System (GPOS) as highlighted in Table I. The RTOS have named TaOS. TaOS is a simple embedded GUI that focuses on
requirements in five general areas, including determinism, assigned blocks of code to little square such as mini
responsiveness, user control, reliability, and fail-soft operation. application. Due to its popularity and readily available library,
FreeRTOS [12] will be used in our prototype development.
TABLE I. COMPARISON BETWEEN RTOS AND GPOS
III. HARDWARE AND SOFTWARE DESIGN
Real Time Operating General Purpose Operating
Criteria
System (RTOS) System (GPOS) In this section, the hardware and software design will be
 Time deterministic
elaborated in more details.
 Non time deterministic
 Time critical system
 Not time critical system
Case Handling  Guarantee of task A. Hardware Design
 No guarantee when a task
completion in specific
is completed Fig. 1 shows the block diagram of the proposed smart
time
Task Not always based on priority chicken poultry farm using Arduino, while Fig.2 shows the
Always priority based hardware design. Arduino Mega is the main microcontroller
Scheduling (to increase throughput)
Size of applied Usually smaller for unit which connects to sensors and other output for data
Bigger
device embedded device logging. For the proper date and time stamp of the data
Speed of Usually in the range of logging, an RTC (real time clock) module is utilized.
In the range of Gigahertz
processor Megahertz Temperature sensor (DHT22) will sense the surrounding
Memory range around Megabyte more than 3 Gigabyte
all processes & threads have
temperature continuously and always comparing with the
bounded latency (will
unbounded dispatch latency desired value in the chicken hall. If there is a sudden increasing
Latency (more threads to schedule, of heat from the surrounding, an exhaust fan will blow out the
execute in a specific time
increase latency)
preemptible) heat to stabilize the temperature in the chicken hall. If the
 high end surrounding temperature is too low than desired, heat lamp will
 stand alone
Type of  general purpose, e.g. be turned on until it reaches an optimum temperature between
application  low end, e.g. ATM
Personal Computer (PC), 33℃ – 35 ℃ for baby chicks. The humidity sensor (DHT22)
machine, vending machine
workstation, server system
will sense the level of moisture from surrounding either it too
high or low. The gas sensor (MQ135) will be used to detect
RTOS must follow a certain time limitation to execute or two different harmful gasses, i.e. ammonia and carbon dioxide.
run a process. Software and hardware combined together to An exhaust fan will be used to regulate both gas concentration.
achieve the required processing time. It also runs tasks and
completes it in a given time and it will be labelled as an
unsuccessful process when it cannot complete. It guarantees to
execute and complete a task which has time constraint. RTOS
can be split into two major types which are soft real time and
hard real time. In a soft real time, several tasks are labelled
with higher priority than others, however, the time limitation
given is not strictly applied in such system. In contrary, hard
real time system guarantees the completion of critical task in a
given time constraint. Fig. 1. Block Diagram of Smart Chicken Poultry Farm
If the temperature value is higher or the gas concentration is
high, the exhaust fans will be activated.

Fig. 2. Hardware Design

Fig. 3 shows the prototype design of smart chicken poultry


cage using various sensors, heat lamps, exhaust fans, and Fig. 4. Flowchart of real-time chicken pultry farm monitoring system
Arduino microcontroller. Baby chicks are the main group of
chicken that will be focused on. Different ages of chicken have
a variety of environment condition needed such as size of hall IV. RTOS IMPLEMENTATION
and surrounding temperature. Maintaining temperature is very First, to implement FreeRTOS in Arduino, the library needs
important to produce a good quality of chicken. For baby to be downloaded from FreeRTOS website. The downloaded
chicks which just hatched, they need around 33℃ - 35℃ to FreeRTOS library must be placed in the Arduino IDE library.
grow healthily. Advanced chicken farming nowadays has used In the blank page of Arduino IDE, FreeRTOS library has been
enclosed barns in order to keep the birds safe from extreme called to use its function. The function used in normal Arduino
weather, insects, predators and diseases. The prototype chicken IDE is different in RTOS environment. However, the
cage size of 22” x 16” x 18” using woods are designed to setup() function also has been used in FreeRTOS to
accommodate 5 to 10 baby chicks. initialize the I/O pins to be either input and output. The
different for both environments is the loop(). In normal
operation of Arduino IDE, it uses this function to continuously
read or write data based on sequencing. In FreeRTOS, no need
for looping function because the RTOS must be executed based
on their task priority. The higher priority will be treated first
and followed by the lower one.

Fig. 3. Prototype of Chicken Cage

B. Software Design
Two Arduino will be used to identify the different response
from Arduino with RTOS environment and non-RTOS
environment Arduino. To differentiate the response, regular
Arduino has been used with a bootloader. The bootloader can Fig. 5. Finite State Machine of RTOS
only run a single instruction at a time. It will follow the
setup() and loop(). The program will keep looping until Figure 5 shows the finite state machine of task execution.
the power is disconnected from the board. Unlike RTOS, it will When an application has several tasks to be executed, at a
allow the highest priority to execute first although the low given time, only one task will be executed. Generally, to
priority is currently being executed. execute a task need to go through two states which are Not
Running state and Running State. The schedular will determine
Fig. 4 shows the flowchart of the proposed system. The which task will run first and treated last. When a task is in the
Arduino will acquire data from the temperature sensor, Running state the processor is executing the task’s code. When
humidity sensor and gas sensor. Then the data is compared a task is in the Not Running state, the task is dormant, its status
with the desired value that suitable in the chicken farm. If the having been saved ready for it to resume execution the next
actual value is the same with the desired value, the Arduino time the scheduler decides it should enter the Running state.
will keep read data from the sensor. If the temperature value is When a task resumes execution, it does so from the instruction
lower than the optimum value, the heat lamp will be activated. it was about to execute before it last left the Running state.
line of codes (temperature condition) then followed by the next
sequence of ‘if else’ condition. The sequence of tasks
execution in the default Arduino environment is shown in Fig.
7(a).
In initial time taken by using time module of the first loop,
the value of ammonia did not exceed 0.5 ppm to be triggered
(a) FreeRTOS library initialization but heat lamp was turned on because the temperature inside the
chicken hall is below 33℃. However, when the loop entering
the second cycle, the value of ammonia suddenly increased and
exceeded the threshold value and still did not performing the
expected output (activate exhaust fan). The bootloader still
executing the first ‘else if’ condition (low temperature) until
this task is complete then it will check next condition in
sequence. By using default Arduino environment, there will be
starvation occur on the other task which should be executed
(b) Tasks created with its priority due to loop() function. Ammonia task is kept in blocked
Fig. 6. FreeRTOS initialization and priority based tasks creation
state until temperature task is completed. This situation is not
good for a control system. Considering the ammonia level
Fig. 6 illustrates the FreeRTOS library initialization and increase rapidly without any preference output will cause death
priority-based tasks. The monitoring of ammonia level is given of baby chicks. Fig. 7(a) shows the sequence of tasks execution
the lowest priority due to the predicted slower change of in default Arduino environment.
ammonia. It will activate the exhaust fans if the ammonia
concentration is too high. Similarly, the monitoring of CO2 B. RTOS Arduino Experiment
level is given second priority. The exhaust fans will be Real Time Operating System (RTOS) has been widely used
activated if the concentration is too high. The highest priority in modern control system that require time deterministic
will be given to the temperature and humidity measurement as application. Robotic arms are the best example of application
it has the predicted faster change over time. The exhaust fans which it will take a small chip on running conveyer to be
or heat lamp will be activated depends on the sensor reading. transferred to other conveyer at specific time without fail.
RTOS also is able to do multitasking with a single core like
V. RESULTS AND DISCUSSION Arduino Mega. Technically, a single core can only run a single
This section describes the experimental results for both task at specific time. However, the addition of real time
default Arduino environment compared to FreeRTOS Arduino extension allows the scheduler to execute multiple tasks.
implementation. Two experiments will be conducted on the Priority is given to each task. Based on the coding in the
temperature and ammonia concentration at the same time. Each previous section, temperature task has the highest priority
experiment will be implemented using default Arduino compared to ammonia task and CO2 task. Unlike default
environment and FreeRTOS Arduino. For temperature task, if Arduino environment, RTOS does not need void loop()
the temperature goes below than 33 ℃ in chicken hall, then the function because it will run all tasks without causing starvation
heat lamp will be turned on. For ammonia task, if the gas to other tasks.
concentration is above 0.5 ppm, the exhaust fan will be Executing the highest priority one first is the advantage of
activated. RTOS in most application. In this experimental set up,
temperature will always run at first followed by lower priority
A. Default Arduino Experiment just after the system is started. At initial temperature (20.9℃),
Arduino microcontroller has integrated bootloader that will the scheduler was triggered by the value and provide the output
store all the program codes which decides what the controller to turn on the heat lamp. While it is running, other tasks also
should do. By implementing normal Arduino bootloader, there being executed which are controlling of CO2 and ammonia gas.
is no specific function provided to determine which task has The scheduler will respond to an appropriate output which is
higher priority than others. It is because the loop() function blowing out the fan until the level of ammonia is decreased.
is executing task based on sequence of code line. Programmer The task switching is very fast until all the task looks like
can change the sequence form the programming language, but running in parallel. Although there are two tasks are triggered,
the processor cannot recognize which task has higher priority. the system still able to work properly. The quick response
Hence, the processor will execute the task which come first, i.e. acquired by the RTOS environment is an advantage of a
first in first out. control system to deliver the best performance. Each task has
the right to be executed by processor to perform its appropriate
In this experiment, the temperature will be set to optimum output, as shown in Figure 7(b).
conditions, i.e. the temperature below 33℃ will turn on the
heat lamp, while the temperature above 35℃ will turn on the C. Discussion
exhaust fan. The next condition will set the allowable ammonia
level to be less than 0.5 ppm. Otherwise, the exhaust fan will RTOS is better compared to default Arduino environment
be activated. The Arduino bootloader will loop back to the top in terms of task switching and response time. The starvation
issue should not happen in any control system to avoid failure the actual implementation of what we have learned from the
to whole system. The response time in RTOS is just in second time-series database to optimize the chicken farming process.
after another task is triggered while default Arduino
environment took about 5 minutes to complete one task so that VI. CONCLUSIONS AND FUTURE WORKS
other task can be executed although it was triggered early. This
This paper has presented the development of smart chicken
will lead to starvation of a task. A good control system is able
poultry system. Arduino with FreeRTOS library provide a real-
to avoid the starvation to occur which can cause failure to the
time sensing, monitoring, and control of the farm environment,
whole system.
including ammonia, carbon dioxide, temperature and humidity.
Experiments showed that our proposed system has better
monitoring and control compared to the traditional Arduino
system. Future works include the connection of the Arduino
system to the Internet for remote monitoring, remote data
logging, and remote control.

REFERENCES
[1] M. M. Alam, C. Siwar, M. W. Murad, and M. Toriman, "Impacts of
climate change on agriculture and food security issues in Malaysia: an
empirical study on farm level assessment," World Applied Sciences
Journal, vol. 14, pp. 431-442, 2017.
[2] F. Q. Habib, R. Abu Dardak, and S. Zakaria, "Consumers’ preference and
consumption towards fast food: Evidences from Malaysia," Business &
Management Quaterly Review, vol. 2, pp. 14-27, 2011.
[3] E. U. C. D. /43/EC, "Laying down minimum rules for the protection of
chickens kept for meat production," Official Journal of the European
Union, vol. 182, pp. 19-28, 2007.
Fig. 7. Scheduling Diagram of Default Arduino versus FreeRTOS Arduino
[4] H. Mansor, A. N. Azlin, T. S. Gunawan, M. M. Kamal, and A. Z.
Hashim, "Development of Smart Chicken Poultry Farm," Indonesian
Considering there are high temperature, ammonia and CO2 Journal of Electrical Engineering and Computer Science, vol. 10, pp.
level in the chicken hall, if the system only can solve one task, 498-505, 2018.
the growth of chicken will be affected. From the sequence of [5] S. Jindarat and P. Wuttidittachotti, "Smart farm monitoring using
execution of the default Arduino environment, the heat lamp Raspberry Pi and Arduino," in 2015 International Conference on
Computer, Communications, and Control Technology (I4CT), pp. 284-
turned on for about 5 minutes before it blew the fan out. It is 288, 2015.
stated that the fan task is being starved for 5 minutes. Unlike in [6] R. B. Mahale and S. Sonavane, "Smart Poultry Farm Monitoring Using
the RTOS environment, each task will be executed repeatedly IOT and Wireless Sensor Networks," International Journal of Advanced
according to the level of priority. It seems to execute the tasks Research in Computer Science, vol. 7, 2016.
in parallel although a single core of Arduino Mega can only [7] G. Corkery, S. Ward, C. Kenny, and P. Hemmingway, "Incorporating
smart sensing technologies into the poultry industry," Journal of World's
run a single task at a time. RTOS environment also will keep
poultry research, vol. 3, pp. 106-128, 2013.
the processor busy to run a task to maximize processor [8] I. Halachmi and M. Guarino, "Precision livestock farming: a ‘per
utilization. To create multitasking, the priority needs to be animal’approach using advanced monitoring technologies," Animal, vol.
assigned uniquely to each task. Nevertheless, the level of 10, pp. 1482-1483, 2016.
priority could be optimized for different purposes. [9] R. R. Belleza and E. P. de Freitas, "Performance study of real-time
operating systems for internet of things devices," IET Software, vol. 12,
pp. 176-182, 2018.
D. IoT Framework Analysis [10] A. Taivalsaari and T. Mikkonen, "A taxonomy of iot client architectures,"
In [14], the IoT Framework, which can be applied for the IEEE Software, vol. 35, pp. 83-88, 2018.
[11] S. Siewert and J. Pratt, Real-Time Embedded Components and Systems
proposed smart chicken poultry farm, is discussed and divided
with Linux and RTOS, Stylus Publishing, LLC, 2015.
into several stages, including Things, Connect, Collect, Learn, [12] M. Back, "freeRTOS: A practical approach with Arduino," 2018.
Do. In our case, the Things is the IoT device and sensors for [13] T. S. Gunawan, I. R. H. Yaldi, M. Kartiwi, and H. Mansor, "Performance
the smart cage as explained in Figure 1 to 3. For the Connect Evaluation of Smart Home System using Internet of Things,"
part, it is not limited to WiFi or Ethernet but it can be other International Journal of Electrical and Computer Engineering, vol. 8, pp.
communication technologies, such as Bluetooth, Zigbee, LoRa, 400, 2018.
[14] T. Chou, Precision-Principles, Practices and Solutions for the Internet of
etc. The Collect part is the time series databases which could Things, McGraw-Hill Education, 2017.
be used to collect the machine information and environment [15] T. S. Gunawan, M. H. Anuar, M. Kartiwi, and Z. Janin, "Design of power
information, i.e. ammonia, carbon dioxide, temperature, and factor meter using internet of things for power factor improvement,
humidity, with date and time stamp [15]. The Learn part is the remote monitoring and data logging," Indonesian Journal of Electrical
machine learning process which could learn the most optimum Engineering and Computer Science, vol. 17, 2020.
condition at particular time using deep learning. The Do part is

View publication stats

You might also like