An automation system for mushroom production using IoT technology

Ngo Anh Tuan, Asocc. Prof. PhD. Pham Manh Thang, Pham Manh Tuan and Master. Dang Anh Viet (University of Engineering and Technology, Vietnam National University – Hanoi)


This paper introduces an automation system for mushroom production using IoT technology. This system consists of hardware components and applications software. The hardware part is integrated with environmental sensor, actuators, Arduino Mega 2560 and Raspberry Pi 3 Model B+. The software part is the combination of embedded firmware, Firebase cloud platform, HMI program, Android application, and Web interface. The process of prototyping and testing showed that this system is stable and easy to use. It is also low-cost and highly scalable with great potential for applying in mushroom production. Details of how this system was implemented and the results are presented below.

Keywords: Automation system, IoT, Raspberry Pi, Arduino, Firebase, HMI, Web, Android.

1. Introduction

Mushrooms are considered as the great functional food, which contain a variety of proteins, vitamins such as vitamins B1, B2, PP, and essential amino acids. They provide a lot of nutrients for the body but do not cause any arteriosclerosis and cholesterol-increasing in the blood. Mushrooms also have various diverse pharmacological effects such as: healing, strengthening the body's immunity, anti-cancer and antiviral, preventing and treating cardiovascular diseases, hypoglycemia, radiation, antioxidant, detoxification and protection of liver cells, sedation, very beneficial for regulating the activity of the central nervous system (Nguyen, 2015; Rathore, 2017; Chang 2004). Because of their tremendous nutritional value, mushrooms are one of the most valuable agricultural products. According to (Royse, 2017), the total value of mushroom production in the world had reached $34 billion USD in 2017, which is an enormous number. Realizing the great potential of mushroom growing industry, in 2012, the Prime Minister of the Socialist Republic of Vietnam has issued Decision 439/QĐ-TTg, putting edible mushrooms and medicinal mushrooms on the list of national products prioritized for development investment (Le, 2018).

Vietnam is the country which has great potential for producing edible and medicinal mushrooms due to the abundant source of growing materials, cheap labor source, extensive domestic market with more than 90 million people. However, the mushroom production industry in Vietnam has not yet developed to match its potential. In comparison with other mushroom producing countries in the world, mushroom production industry in Vietnam still faces many limitations in productivity, quality and product diversity. For example, according to (Le, 2018), the average total mushroom yield in Vietnam is about 270 thousand tons, which is still very modest when compared to the major mushroom producing countries in the world like China (2,850,000 tons), or America (393,400 tons) (Nguyen, 2015).  This is mainly due to the low level of mushroom cultivation techniques of Vietnamese farmers, and the lack of advanced technologies adoption in the mushroom growing process.

To address the above-mentioned problem, our research team has developed a smart automated system to monitor and control important environmental parameters affecting the growth of mushrooms. The proposed system provides an efficient, low-cost solution for mushroom production. It applies IoT technology - an innovation that makes use of Internet to collect data or control digital gadgets remotely (Aditya, 2018), with real-time monitoring function on web and android smartphone platforms, allow users to oversight the production process every time and everywhere. Besides, the system also has a function of notifying users when abnormalities occur, allowing users to control actuators remotely to regulate the environmental parameters always in ideal condition for mushroom to grow. If implemented, this system will be able to help many mushroom farms in Vietnam increase the productivity and quality of mushrooms, save time, and increase labor reduces.

2. System overview

In order to develop the proposed system, a variety of hardware and software components are integrated. Figure 1 illustrates the overall structure of the automation system for mushroom production. The hardware part of this system includes environmental sensor, actuators, Arduino Mega, and Raspberry Pi. Meanwhile, the software part consists of a website, an android application and HMI software, and they are all connected to Firebase Cloud System. (Figure 1)

Figure 1. System architecture of the proposed system


Each element in this system has its own specific function, and they will be described in detail as follows:

2.1. Environmental sensor

In this system, the environmental sensor is used to measure temperature, humidity, and the concentration of CO2 in the air. These three parameters are crucial for the growth of mushrooms. If we can regulate these parameters in an ideal threshold for mushrooms at each stage of their life cycles, we can greatly increase the yield and quality of the product.

The environmental sensor used in this system communicate with microprocessor via UART serial communication interface. The data frame used by this sensor is shown in Table 1.

Table 1. Environmental sensor’s data frame


According to CCS811 gas sensor datasheet (CCS811 datasheet), 3rd byte and 4th of the data frame are used to calculate the value of CO2 concentration in the air (ppm):caculate_1 Meanwhile, based on Si7021 humidity and temperature datasheet (Si7021-A20 Datasheet), 11th - 12th bytes of the data frame are used to calculate the value of humidity, whilst 13th - 14th bytes are used to get the temperature:


Where H is the value of humidity in percentage, and T is the value of temperature in Celsius degree.

2.2. Actuators

Actuators are used to control the environmental parameters so that mushrooms can grow in the ideal condition. The proposed system consists of 4 actuators: heater and cooler to regulate the temperature, pump to increase the humidity in the air, and fan to reduce the CO2 concentration when it goes to high.

2.3. Raspberry Pi

Raspberry Pi is a mini computer with the size of only few square inches, but it has a great processing power and supports various types of connection ports like a regular PC (Jindarat, 2015; Patchava, 2015). This system uses the Raspberry Pi Model 3+, the fastest product in the Raspberry Pi 3 range. It has a 64-bit quad core processor running at 1.4 GHz, dual-band wireless LAN, 4 USB ports, and 40-pin GPIO header. It also contains a SD card slot, which is used for booting an operating system likes Raspbian, Ubuntu, or Windows IoT. This makes Raspberry Pi a great choice for embedded system applications.

2.4. Arduino Mega 2560

Arduino is one of the most famous open-source hardware and software ecosystems. It supports different types of software tools and many hardware platforms.

Arduino Mega 2560 is a SoC board based on the Atmega2560 microcontroller. It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. Arduino Mega 2560 is suitable for applications that need to use many I / O pins, multiple serial ports while ensuring low power consumption. (Figure 2)

Figure 2.  Firebase database structure


2.5. Firebase cloud system

Firebase is Google’s mobile platform that helps users develop their products faster without spending huge amount of initial investment by providing various services such as: Cloud Firestore, ML kit, Cloud Functions, Authentication, Hosting, Cloud Storage, and Realtime Database (Li 2018).

In this proposed system, we used two services provided by Firebase: Cloud Firestore as database to store sensor data and status of actuators, and Firebase Hosting to deploy and host the web application. Figure 2 depicts the database structure used in this proposed system.

2.6. Software Applications

The proposed system contains HMI, Web interface, and Android applications. These pieces of software allow user to monitor environmental parameters in real time, analyze data through charts, and remotely control the actuators of the system. Furthermore, these applications are designed with special algorithms so that they can display environmental parameters as well as the operating status of the actuators synchronously.

3. Methodology

3.1. Hardware’s function and communication 

Figure 3. Activity diagram of Arduino controller’s firmware


The main aim of this system is to allow users to monitor and control important environmental parameters. To do so, we connect Arduino Mega 2560 with the sensor and actuators. A firmware embedded in the Arduino controller will read data from the sensor every second and send it to Raspberry Pi via serial port. Aside from that, Arduino controller constantly listen to data sent from Raspberry Pi as command from users to control the actuators. Figure 3 shows the activity diagram of the firmware in Arduino Mega 2560.

In this system, Raspberry Pi board has two functions: an Internet gateway and a host machine for HMI software. As an Internet gateway, Raspberry Pi communicates with Arduino Mega 2560 using UART protocol. It gets sensor data sent from Arduino and puts it to Firebase database. It also listens to any commands from users in Firebase database and sends those commands to Arduino to control the actuators of the system. As a host computer, Raspberry Pi runs a Python script to display an interface which displays environmental parameters and allows user to manually control the actuators. Figure 4 shows the sequence diagram of the gateway firmware.

3.2. Human-Machine Interface (HMI)

As mentioned above, HMI software of this system is a Python script running on Raspberry Pi board. To create this interface, we use a library called Guizero. Guizero is a graphic library based on Tkinter GUI library, but it is much easier to user. It supports many widgets which allow new learners to quickly and easily create GUIs for their programs.

Figure 4.  Sequence diagram of the Internet gateway firmware


The HMI is displayed on a 7-inch touch LCD connected to other hardware locating in mushroom factories. It has two sections: one displays real time environmental parameters, and the other shows the operating status of actuators and also allows users to manually turn on or off them. Whenever users change the status of an actuator, a query will be sent to Firebase Firestore to update its status on the database. This allows all applications synchronize the active status of all actuators.

3.3. Android Application

Android is an open source operating system produced by Google. It is now running on 2.5 billion devices all around the world (Google Inc. Android. The Android SDKs provides libraries which help developers easily make use of the hardware. Android operating system is chosen for this project because of its widespread popularity and the excellent compatibility with Google’s services, one of which is Firebase platform.

In this project, the Android app is designed for the purpose of simple use. It has well-structured layout, bright color, and a bottom navigation bar allowing users to easily interact with the app. Like the HMI software, the Android app has two sections: monitoring section and controlling section. The monitoring section listens to data added to Firebase database and then displays that data. Meanwhile, users can use the controlling section to turn on or off actuators by changing the operating status of actuators on the Firebase database.

3.4. Web Interface

In this proposed system, the web interface is a static website, which produces much faster response than dynamic one. It is implemented with HTML, CSS, and Javascript. HTML and CSS are used to create layout and style for the webpage. Javascript is a programming language designed to run in the browser, which enables dynamic content and interactive user interface (Ferdoush, 2014). Thanks to and Firebase Firestore services, the web application has a simple structure yet Firebase Hosting comprehensive functions.

This web interface supports full function of monitoring and analyzing data, as well as controlling environmental parameters. It contains three section: monitoring section, graph section, and controlling section. The monitoring section looks for the latest change of sensor data on Firebase database and displays it. In the graph section, we use Chart.js library for plotting. This is an open source Javascript charting library which allows developers easily create beautiful and interactive graphs. The controlling section of this web app also contains function like the HMI and Android app, but it is added the function of setting the automatic mode to regulate each environmental parameter at a particular threshold. When the automatic mode is set, the web interface will query a command to the Firebase database, this command will then send to Arduino for controlling corresponding actuators via the Internet gateway on Raspberry Pi.

4. Results

After the procedure of installation and testing, the first prototype of the monitoring system has run stably and given the positive results. Below is the results of the hardware and software components in this project.

4.1. Hardware prototype

The first prototype of this proposed system is shown in Figure 5.

Figure 5. Hardware prototype


4.2. Web application

Figure 6.  Web application


4.3. HMI program

Figure 7. HMI program running on Raspberry Pi


4.4. Android application

Figure 8. Android application


5. Discussion

This paper presents in detail about the automation system for mushroom production using IoT technology, including hardware components and software applications. The system shows many advantages such as low-cost, compact, easy to scale, and easy to install. The software applications of this system will help users a lot in the process of growing mushrooms, following by that is an increase in the yield and quality of mushrooms.

The result of this project also shows that the utilization of Firebase Firestore and Firebase Hosting services illustrating great effectiveness in developing real time applications.

In the future, we will be looking for mushroom farms in northern Vietnam to install this automation system for testing purpose. This will help us detect the errors and analyze the performance of the system in the real-life condition. After the testing phase, we will improve and complete all the aspects of this system, proceed to mass installation and production.


This work has been supported by VNU University of Engineering and Technology under the project number CN19.08.

  1. Nguyễn Hữu Hỷ, Nguyễn Duy Trình, Ngô Thị Bích Ngọc và cộng sự (2015). Thực trạng và giải pháp phát triển ngành nấm tại các tỉnh phía Nam, <>, xem ngày 4/12/2019.
  2. H. Rathore, S. Prasad, S. Sharma (2017). Mushroom nutraceuticals for improved nutrition and better human health: A review. PharmaNutrition, 5(2), 35-46.
  3. S. T. Chang, P. G. Miles (2004). Mushrooms: Cultivation, nutritional value, medicinal effect, and environmental impact. 2nd ed., CRC Press, Florida.
  4. D. Royse, J. J. P. Baars, Q. Tan (2017). Edible and Medicinal Mushrooms: Technology and Applications, 1st ed., John Wiley & Sons Ltd, West Sussex.
  5. Lê Quang Thái (2018). Hiện trạng ngành sản xuất nấm Việt Nam và giới thiệu các giải pháp công nghệ nhằm giải quyết một số vấn đề tồn tại, Ứng dụng công nghệ cao trong nông nghiệp tại Việt Nam, Hội thảo Quốc tế, Viện Ứng dụng Công nghệ ngày 10/10/2018, Bộ Khoa học và Công nghệ, 1-15.
  6. Aditya, M. Sharma, and S. C. Gupta (2018). An Internet of Things Based Smart Surveillance and Monitoring System using Arduino. International Conference on Advances in Computing and Communication Engineering (ICACCE), ECE School of Engineering on 22-23/06/2018, 428-433.
  7. AMS (2016). Ultra-Low Power Digital Gas Sensor for Monitoring Indoor Air Quality, CCS811 datasheet. [online] Available at: [Accessed 05 December 2019].
  8. Silicon Laboratories (2016). I2C Humidity and Temperature Sensor, Si7021-A20 Datasheet. [online] Available at: [Accessed 05 December 2019].
  9. S. Jindarat, P. Wuttidittachotti (2015). Smart farm monitoring using Raspberry Pi and Arduino. International Conference on Computer, Communications, and Control Technology (I4CT), Institute of Electrical and Electronics Engineers on 21-23/04/2015, 284-288.
  10. V. Patchava, H. B. Kandala, P. R. Babu (2015). A Smart Home Automation technique with Raspberry Pi using IoT. 2015 International Conference on Smart Sensors and Systems (IC-SSS), Institute of Technology Bangalore on 21-23/12/2015, 1-4.
  11. Raspberry Pi Foundation. Raspberry Pi 3 Model B+ Product Brief. [online] Available at: [Accessed 06 December 2019].
  12. Arduino. Arduino Mega 2560 Rev3. [online] Available at: [Accessed 06 December 2019]
  13. W. J. Li, C. Yen, Y. S. Lin, S. C. Tung, S. M. Huang (2018). Just IoT Internet of Things based on the Firebase real-time database. 2018 IEEE International Conference on Smart Manufacturing, Industrial & Logistics Engineering (SMILE), IEEE Beijing Section on 08-09/02/2018, 43-47.
  14. S. Ferdoush, X. Li (2014). Wireless sensor network system design using Raspberry Pi and Arduino for environmental monitoring applications. Procedia Computer Science, 34, 103-110.







Trường Đại học Công nghệ, Đại học Quốc gia Hà Nội


Bài báo này giới thiệu một hệ thống sản xuất nấm tự động tích hợp công nghệ Internet vạn vật (IoT). Hệ thống này bao gồm hai phần chính: các thành phần phần cứng và các ứng dụng phần mềm. Phần cứng được tích hợp với cảm biến môi trường, các cơ cấu chấp hành, mạch Arduino Mega 2560 và máy tính mini Raspberry Pi 3 Model B +. Ứng dụng phần mềm là sự kết hợp của phần mềm nhúng, nền tảng đám mây Firebase, chương trình giao diện giao tiếp người máy, ứng dụng Android và giao diện Web. Qua quá trình chế tạo sản phẩm mẫu và thử nghiệm, kết quả cho thấy hệ thống này hoạt động ổn định và dễ dàng sử dụng. Nó cũng có chi phí thấp và có khả năng mở rộng cao, cho thấy tiềm năng to lớn của hệ thống trong việc sản xuất nấm ứng dụng công nghệ cao. Chi tiết về cách chúng tôi xây dựng hệ thống này và kết quả được trình bày trong bài viết.

Từ khóa: Hệ thống tự động hóa, Internet vạn vật (IoT), Raspberry Pi, Arduino, Firebase, HMI, Web, Android.