By incorporating IoT technology into hydroponic farming, we can create a smart indoor garden that not only meets these needs but empowers beginners to grow various plants to meet their p
OVERVIEW OF THE PROJECT
Problem Statement
Currently, science and technology are advancing rapidly, and all aspects of our lives are witnessing the results of scientific research The Internet of Things is becoming increasingly popular, and this technology is gradually becoming an indispensable part of modern homes
However, the development of various technologies and rapid urbanization has led to a decline in green spaces Therefore, the demand for home gardening on balconies and rooftops is increasing as people aim to add more greenery to their homes and have a source of fresh vegetables for their families
To meet these needs, we need to develop a system suitable for small spaces like balconies or rooftops and integrate with IoT technologies to assist users in the gardening process while increasing the productivity of the plants to meet their individual needs
Based on these needs, our team has decided to choose the topic "Smart Indoor Garden" to participate in the competition We believe this is a suitable project with great potential for future development.
Objectives of project
- Gain an understanding of hydroponic gardening technologies and systems
- Acquire knowledge and understanding of the devices, systems, and technologies used in the gardening process
- Investigate and develop a hydroponic gardening system applying IoT technology for practical use
- Participate in the IoT Challenge 2023 competition.
Implementation Idea
The main idea of the "Smart Indoor Garden" project comes from the increasing demand of urban residents who want to grow plants in limited spaces, such as apartment buildings, or simply desire to have a small garden without the time for maintenance The project aims to create a product that meets this demand through technology integration and optimal utility
The idea is based on the following key criteria:
- Automation: The Smart planter will have temperature and light intensity sensors With these data, the system can automatically adjust the amount of water and light provided to the plants, ensuring that the plants are always in the best conditions for growth without requiring much intervention from the user
- Control Application: Users can monitor and manage the smart planter through a mobile application They can check the status of the plants, set lighting schedules, and even receive notifications when the plants require special care
- Space Optimization: With its compact size, the smart planter can be placed in various locations within the house, from windowsills to work desks, optimizing the use of limited space
With the "Smart Indoor Garden" project, we hope to provide urban residents with an easy and intelligent way to grow plants, contribute to environmental conservation, and create a greener living space Moreover, this project introduces a new approach to growing and caring for greens in the current era of Industry Revolution 4.0.
Main Functions
The IoT-based hydroponic gardening system has several primary functions:
- Monitoring, supervising, and updating the environmental status of the plants based on parameters such as air temperature, humidity, pH, and nutrient density in the nutrient solution, and notifying when the water level in the reservoir is below the allowed level These parameters will be displayed on the mobile application
- Automatic adjustment of those parameters to support the plant development process without the user's intervention, such as automatic nutrient supplementation, automatic adjustment of brightness and light duration based on the actual needs of the plants, etc.
User Groups
The user groups for the "Smart Indoor Garden" include individuals and businesses demanding high-yield, time-saving, and labor-efficient plant cultivation Specifically, the user groups for the Smart Indoor Garden may include:
- Families and individuals: Due to its compact design, the "Smart Indoor Garden" can be used in apartment buildings and maisonettes to meet the demand for growing fresh vegetables and creating green spaces at home
- Businesses: This group may use the Smart Indoor Garden on a larger scale, establishing a high-yield, cost-effective, clean vegetable production system that reduces labor costs
In summary, the user groups for the Smart Indoor Garden include individuals and businesses with a need for high-yield, time-saving, and labor-efficient plant cultivation.
PRODUCT ANALYSIS AND DESIGN
User Needs Research
In today's society, as it has reached a certain level of development, people are becoming more conscious about environmental protection Therefore, in addition to using traditional gardening methods, many people also need products embedded with technology, such as IoT-enabled planters
Besides the reasons mentioned above, the increasing demand for products like "Smart Indoor Garden" is also due to the following factors:
Rapid urbanization: Urbanization is happening quickly, leading to people living in smaller apartments or homes Products like "Smart Indoor Garden" help optimize space as its design can fit in limited areas like balconies, rooftops, etc High utility and aesthetics: Smart planters integrate automation features and sensors, making it easier for users to care for their plants Additionally, these planters can be used as decorative items in living spaces
Time and effort-saving: Smart planters reduce the time and effort needed for plant care through IoT applications
Convenience for beginners: Novice planters often need help in plant care They may need to learn the correct nutrient dosages, when to add nutrients, turn off lights, etc Smart planters can provide guidance and essential information to make gardening easier for beginners
In summary, smart planters are becoming an integral part of many people's daily lives, thanks to their integration of technology and the values they bring to aesthetics and health.
Overview of Existing Products in the Market
Thanks to the advancement of science and technology and significant progress in artificial intelligence, there are increasingly more smart planter products with various features available in the market Some well-known smart planter manufacturers worldwide include AeroGarden, Click & Grow, Grobo, FarmBot, Nutritower, and others
Additionally, one can find thousands of smart planter products from various manufacturers with different designs and functions on e-commerce platforms The prices of these products range from around one million VND to tens of millions of VND, depending on the level of technology applied These products commonly employ hydroponic methods due to their high productivity, cleanliness compared to soil-based planting, ease of maintenance, and repair of components in case of malfunctions
However, most of these products are researched and manufactured by foreign companies, which has led to Vietnamese citizens not having convenient access to smart planters to meet their needs Therefore, the Smart Indoor Garden project holds great promise for future development to cater to the needs of the people in Vietnam.
Products Requirements
- Accurately read values from temperature, humidity, pH, and EC sensors
- Control the lights, water pump, and air pump without malfunctions
- Maintain stable and uninterrupted control connectivity
- The app should provide precise control and remote monitoring
- The product should have a compact and elegant design suitable for indoor placement
- The product should be user-friendly and easy to operate
- The product should effectively nurture plant growth
- The app interface should be aesthetically pleasing and user-friendly.
THEORETICAL BASIS
Communication protocol MQTT
MQTT (Message Queuing Telemetry Transport) is a lightweight publish- subscribe messaging protocol designed for constrained devices and low- bandwidth, high-latency, or unreliable networks It provides efficient communication between devices connected via the IoT, enabling the exchange of small messages with minimal network overhead
The theoretical basis of MQTT can be understood through the following key concepts:
Publish-Subscribe Model: MQTT follows a publish-subscribe messaging pattern In this model, publishers send messages, also known as "publishing" messages, to a specific topic Subscribers, on the other hand, express interest in specific topics and receive the messages published on those topics This decoupling of publishers and subscribers enables a highly scalable and flexible communication system
Topics: Topics act as message channels or categories in MQTT They are structured strings that define the nature or content of a message Publishers choose a topic when sending a message, and subscribers can subscribe to one or more topics to receive relevant messages Topics are hierarchical, allowing for the creation of a logical structure within the messaging system
Quality of Service Levels: MQTT provides three levels of message delivery guarantees, known as QoS levels:
- QoS 0 (At most once): This level ensures that a message is delivered once, but there is no guarantee of successful delivery It follows a best-effort approach and does not involve any acknowledgment or retransmission
- QoS 1 (At least once): This level ensures that a message is delivered at least once to the subscriber It involves acknowledgment and retransmission mechanisms to ensure reliable delivery
- QoS 2 (Exactly once): This level guarantees that a message is delivered exactly once to the subscriber It involves a two-step handshake process and ensures the highest level of reliability at the cost of increased overhead
Broker: The MQTT broker acts as an intermediary between publishers and subscribers It receives messages published by publishers and routes them to the appropriate subscribers based on the subscribed topics The broker manages the messaging infrastructure, including topic subscriptions, message filtering, and QoS enforcement
Lightweight and Bandwidth-Efficient: MQTT is designed to be lightweight and efficient, making it suitable for resource-constrained devices and networks The protocol uses a binary payload format, minimizing the message size Additionally, MQTT supports persistent connections and efficient message compression techniques, reducing network overhead and conserving bandwidth Connection and Session Management: MQTT supports persistent connections, allowing clients to stay connected to the broker even when they are not actively sending or receiving messages This enables efficient communication and reduces connection setup overhead MQTT also maintains a session state for clients, allowing them to resume communication from where they left off after a disconnection
Security: MQTT provides security features to protect the confidentiality, integrity, and authenticity of messages It supports Transport Layer Security (TLS) encryption for secure communication over the network Additionally, MQTT offers authentication mechanisms, such as usernames/passwords or client certificates, to verify the identity of clients and brokers
By leveraging these theoretical foundations, MQTT provides a scalable, reliable, and efficient messaging protocol for IoT applications, where constrained devices and networks are prevalent.
Communication protocol BLE
General Introduction to BLE GATT
To enable communication between the EFR32MG24 and ESP32, our team has utilized BLE technology for their connection Specifically, we have employed BLE GATT
Figure 3.1 Communicate between EFR32MG24 and ESP32 through BLE
BLE GATT is an essential part of BLE technology, providing a framework for BLE devices to communicate with each other GATT defines how data is organized and transmitted between BLE devices, enabling them to perform specific tasks like reading information from a sensor or remotely controlling a device
Some key concepts of BLE GATT:
Service: A service defines a set of Characteristics and describes specific functionality that a BLE device provides For example, a health device might have a "Heart Rate" service for measuring heart rate
Characteristic: Characteristics are fundamental components of a service, representing specific data Each Characteristic has a UUID (Universally Unique Identifier) to identify it and describes attributes like read, write, or notify
Universally Unique Identifier: A UUID is a unique number used to identify a service or Characteristic There are standard UUIDs like the UUID for the Heart Rate service, as well as custom UUIDs for specific applications Descriptors: Each Characteristic can have Descriptors that describe how the data in the Characteristic should be used or interpreted For example, a Descriptor might describe the measurement unit or value limits
Client and Server: In the GATT model, a BLE device can act as a Server or Client The Server provides services and Characteristics, while the Client requests and interacts with them
Operations: There are three main operations a Client can perform on a Characteristic: read value, write value, and register for notifications when the value changes
Notifications and Indications: A Client can subscribe to receive notifications or indications from a Characteristic This allows the Server device to notify the Client when the data changes
Attribute Table: GATT is organized as an attribute table in the memory of the BLE device This table contains a list of services and their attributes, including the values of Characteristics
Profile: A BLE profile is a collection of services and attributes that can be combined to define a specific type of device or application For example, the Heart Rate profile is a set of services and Characteristics used for heart rate monitoring
Figure 3.2 GATT Client/Server Connection
The server device advertises its presence to nearby devices This advertising packet includes information about the services it offers and their characteristics
Each service exposes one or more characteristics These characteristics can represent data to be read or written, notifications, or indications The server stores the current values of these characteristics in its attribute table
The client device scans for nearby BLE advertisements to discover available server devices Upon discovering a server device, the client device can initiate a connection by sending a connection request
Once the connection is established, the client device can explore the services and characteristics offered by the server device It does this by sending GATT requests to read or write characteristic values, enable notifications, or discover services and characteristics
The client can read values from characteristics or write values to them as needed For characteristics that support notifications or indications, the client can request to be notified when the value changes This allows for real-time updates when the server data changes.
SYSTEM DESIGN
Overall System Design
Figure 4.1 The overall system during operation
Sending Data from the product to the Server and Displaying it on the app:
• Step 1: The EFR32MG24 prokit sends data to the ESP32 module via BLE (with preconfigured UUID)
• Step 2: Configure the ESP32's Wi-Fi to connect to the home network via smart config
• Step 3: The ESP32 retrieves signals from the garden and sends them to the MQTT server via MQTT
• Step 4: The Android app retrieves server data to display on the user interface
Control via Android App or Website:
• Step 1: The Android app sends control commands to the server via MQTT
• Step 2: The server receives the control commands and forwards them to the ESP32
• Step 3: The ESP module receives the control commands, processes them, and sends them to the central processing unit via BLE
• Step 4: The central processing unit converts the received signals into on/off signals for the devices.
Functionality and Block Diagram
- Control hardware devices through the Internet via the Android app
- Display environmental parameters such as air temperature, humidity, nutrient concentration, and pH level of the water in the plant pot
- Send notifications when the water level falls below the required level for the plants
- Automatically supplement nutrients when the nutrient concentration is lower than the required level for the plants
In the block diagram, we can see the power supply block providing energy to the central processing unit, communication, sensor, and output blocks The central processing unit block will retrieve data from the sensor block, communicate with the communication block to push data to the server and display it on the app
The output block also receives commands from the central processing unit block, which can be initiated from the app or through initial settings
The Smart Indoor Garden system will have two selectable modes that can be configured through the app a) Automatic Mode
Figure 4.3 The algorithm flowchart for the Automatic Mode
When the auto mode is set, the values of the pH, EC, DHT, and XKC sensors are read, and their operating conditions are checked as follows:
- If the temperature and humidity sensors detect values outside the allowed range, a notification will be displayed
- If the Ph and EC sensors detect values outside the allowed range, the nutrient pump will be automatically activated to adjust the nutrient levels in the water
- If the water level sensor detects values outside the allowed range, a warning will be sent through the app
- The air pump will automatically turn off with a cycle of 2 hours on and 12 hours off b) Manual Mode
Figure 4.4 The algorithm flowchart for the Manual Mode
We can control the system through the app, enabling us to:
Nutrient Pump Control: Control the nutrient pump valve to dissolve nutrients into the water Each press of the button will release nutrients for 5 seconds
Light Control: Adjust the lighting of the grow lights using buttons to suit the plant's developmental stages: germination, growth, and development.
Hardware Design in the System
4.3.1.1 Silicon Labs EFR32xG24 Pro Kit
Figure 4.5 Silicon Labs EFR32xG24 Pro Kit
The EFR32xG24 Pro Kit is a compact IoT development platform based on Silicon Labs' EFR32MG24 System-on-Chip This kit is designed for prototyping and testing IoT applications using wireless protocols such as Bluetooth LE, Zigbee, Thread, and Matter in the 2.4 GHz range Its key features include a USB interface, integrated SEGGER J-Link debugger, packet trace interface, push buttons, and support for hardware expansion through mikroBus sockets and Qwiic® connectors, offering flexibility in IoT application development and testing
- Operating frequency: Typically 40 MHz or 72 MHz
- Wireless connectivity standards supported: BLE, Zigbee, Thread, Wi-Fi
- I/O interface: GPIO pins for connecting peripherals and sensors
- Communication interfaces: UART, SPI, I2C, USB, CAN, USART, PWM, ADC, DAC
- Operating system: Can run on embedded systems like Micrium, FreeRTOS, etc
Additionally, it offers low power consumption, and security features and leverages the Silicon Labs ecosystem, providing flexibility for various IoT applications
The ESP32 is a series of low-cost, low-power microcontrollers with built-in Wi-Fi and dual-mode Bluetooth support ESP32 devices are powered by the Tensilica Xtensa LX6 processor, available in both dual-core and single-core variants They come equipped with integrated antenna switches, RF balun, power amplifiers, low-noise amplifiers, filters, and power management modules Some key technical specifications:
- CPU: Xtensa Dual–Core LX6 microprocessor.
- Operating frequency: Typically 80 MHz or 160 MHz
- Wireless communication support: Wi-Fi and Bluetooth (BLE)
- I/O interface: GPIO pins for connecting and interacting with peripherals and sensors
- Embedded operating system support: It can run embedded operating systems like FreeRTOS
Figure 4.7 DFRobot Gravity pH meter V1.1
DFRobot Gravity pH meter V1.1 offers high accuracy, and a wide measurement range and is specially designed for Arduino control systems However, this sensor is intended for laboratory use an d should not be submerged in a liquid for an extended period, as it can affect measurement accuracy Nevertheless, due to its affordability, we will use the DFRobot Gravity pH meter V1.1 for this project
- Measurement Range: pH level from 0~14
- Operating Temperature: 0~60℃ The ideal operating temperature is 25℃
- Accuracy: ± 0.1pH (at ideal temperature)
- The sensor uses a BNC connection
- Sensor pH cable length to BNC connection port: 660mm
4.3.1.4 DFRobot Gravity Analog EC meter V2
Figure 4.8 DFRobot Gravity Analog EC meter V2
The sensor function to measure the nutrient concentration in a solution ’s isThe operating principle of the sensor can be explained as follows: When the density of electrolytes in the solution is higher, the solution's electrical conductivity is greater Therefore, when a constant voltage is applied to the solution, and if the current intensity passing through the solution is high, we can deduce that the solution has a high nutrient density By applying voltage between the two electrodes of the sensor submerged in the solution, we can measure the current intensity between the two electrodes through the solution The measurement result is then converted into nutrient concentration values: millisiemens/cm or microsiemens/cm.
- Dimensions: 42mm x 32mm b) Electrical Conductivity Probe
- Probe Type: Used in laboratories
- Supported Measurement Range: 0~20ms/cm
- Ideal Measurement Range: 1~15ms/cm
- Probe Lifespan: > 0.5 years (depending on usage frequency)
4.3.1.5 DHT22 Temperature and Humidity Sensor
Figure 4.9 DHT22 Temperature and Humidity Sensor
The DHT22 temperature and humidity sensor is commonly used because of its low cost and easy 1-wire communication for connecting and interfacing with microcontrollers Compared to the DHT11 temperature and humidity sensor, the DHT22 offers higher accuracy (±0.5°C compared to ±2°C) and a wider measurement range, making it suitable for the project's requirements
- Rated Current during Data Transmission: 2.5mA
- Good measurement range for humidity: 0~100%, accuracy 2~5%.
- Good measurement range for temperature: -40~80°C, accuracy ±0.5°C
- Maximum Sampling Frequency: 0.5Hz (once every 2 seconds)
Figure 4.10 XKC Y25 Liquid Level Sensor –
The XKC Y25 non-– contact liquid level sensor is used to determine whether the liquid level has reached the sensor's position and then outputs a HIGH or LOW signal along with an indicator light The sensor's probe can penetrate thick non-metallic containers and offers high durability and safety as it does not come into contact with the liquid or reside inside the container
- The thickness of the Container that Can Be Penetrated: 0~20mm
- Material of Container that Can Be Sensed: Non-metal
- Output Signal: HIGH and LOW
Figure 4.11 370CD 53kPa Air Pump
The 370CD 53kPa air pump is used with silicone tubing and air stones to aerate water in fish tanks, aquaria, and hydroponic systems, improving water oxygen levels for aquatic organisms
- Rated Voltage: 6VDC or 12VDC
- Maximum Pressure: 400mmHg equivalent to 53kPa
- Dimensions: Motor Diameter: 25mm; Length: 65mm
The RS365 pump is a high-flow pump capable of self-priming and meets the project's nutrient delivery requirement criteria
- Pump Flow Rate: 2~3 liters per minute at 12V
+ Inlet and Outlet Diameter: 0.8cm
This circuit includes 8 RGB LEDs interconnected via a 1-Wire interface, making it easy to use The circuit also has a library that supports up to 16.7 million colors and 256 different brightness levels for each LED, allowing customization
- Rated Voltage: 4~7VDC (optimal at 5VDC)
4.3.1.10 Power Block a) Overview of the Power Block
Figure 4.14 Schematic of the Power Block
- Input: 12VDC from 3s lion battery
+ When the adapter has a 220VAC power source, the output of this block is 12VDC from the adapter
+ When the adapter is disconnected (p ossibly due to a power outage), the output of this block is automatically changed to 12VDC from the battery
+ Keep the system powered even during a power outage
+ Buck module DC –DC XL4015
+ Drop 12VDC to 5VDC for sensors and led
- Input: Voltage from 1 cell of the 3S battery
- Output: Voltage for MCU to check
+ Connect the VCC of the cell to the check pin connected to the MCU
+ Check the battery's voltage to charge it when it is lower than 3.7VDC
+ The Normally Open pin is connected to the VCC of the 3S battery + The Com pin is connected to the VCC of the adapter
+ Switch signal pin connected to MCU
+ When the battery's voltage is lower than 3.7VDC, the MCU sends a signal to the relay to connect the VCC of the adapter to the VCC of the 3S battery to charge it
+ Layout of the PCB b) Layout of the Power Block’s PCB
Figure 4.15 Power Block’s PCB layout (2D view)
Embedded Programming for the System
4.4.1.1 Sequence diagram for EFR32MG24
Figure 4.16 Initialize diagram for the main board, ESP32, sensors, and actuators
Figure 4.17 System processing to get data and send to ESP32 through BLE protocol
4.4.1.2 Programming for Sensors and Actuators a) Programming the Sensor Control
+ Design a library for the sensor (as there is no suitable pre-existing library for the main board)
+ The library includes functions for reading temperature and humidity data
+ After initializing the sensor, data is read through one GPIO pin and transmitted to the ESP32 via the BLE protocol
+ Comments: The data is read with acceptable accuracy, but environmental noise may sometimes affect it
+ Develop a library for the sensor
+ After initializing the sensor, data is read through one GPIO pin and transmitted to the ESP32 via the BLE protocol
+ Comments: It may be necessary to add an XKC – Y25 sensor to avoid exceeding the maximum water level
+ Design a library for the sensor (as there is no suitable pre-existing library for the main board)
+ Use the iADC library available in Simplicity Studio 5 to convert the analog signal from the sensor to digital for processing
+ The library includes functions for reading pH data
+ After initializing the sensor, data is read through a specific pin configured as an iADC pin and transmitted to the ESP32 via the BLE protocol
+ Develop a library for the sensor
+ Use the iADC library available in Simplicity Studio 5 to convert the analog signal from the sensor to digital for processing
+ The library includes functions for reading EC data
+ After initializing the sensor, data is read through a specific pin configured as an iADC pin and transmitted to the ESP32 via the BLE protocol b) Programming the Control of Actuators
- 370CD Air Pump and RS265 Pump:
+ Activation based on various cases: The user presses a button on the device, interacts through the app (BLE GATT Write properties), automatic shutdown based on water quality data such as pH and EC (only for the nutrient pump)
+ Synchronize various cases and send machine states to the ESP via BLE GATT Read properties
+ Control of LED on/off and color adjustment based on various cases: user interaction through the app (BLE GATT Write properties), automatic shutdown based on actual plant growth time to apply appropriate modes
+ Synchronize various cases and send machine states to the ESP via BLE GATT Read properties c) Communication between EFR32MG24B and ESP32
- BLE is a wireless protocol commonly used for connecting and transmitting data between mobile devices, sensors, and other smart devices
- Use Simplicity Studio 5 to program BLE communication for the EFR32MG24B
- Use Silicon Labs' BLE support libraries to create a BLE service (Smart Garden) and start advertising information via this service
- Set up the necessary BLE Characteristics and Descriptors:
+ DHT22 TEMP HUD – (Read + Notify)
+ Neopixel 8 RGB LED (Read + Write)
- Program to handle connection requests from the ESP32 device and establish a connection when necessary
- Once the connection is established, we can send and receive data via BLE
- Use BLE data packets to transmit information between the two devices
- Ensure proper error handling and power-saving mechanisms when the application is inactive
Figure 4.18 Sequence diagram for ESP32
- Initially, NVS is initialized to configure the system as well as open storage space
- Next, WiFi is initialized (to connect to the MQTT broker)
- Initialize esp_bluroid (to connect BLE with EFR32MG24)
- Initialize esp_netif (used to configure custom WiFi settings)
- Data from sensors and the status of actuators are registered with UUIDs ESP32 can identify the UUIDs defined in the code and can read each value of sensors or status through the ble_read_characteristic function
- Then, sensor data and status are stored in two different arrays to be published to MQTT via the predefined MQTT broker address
- This data is retrieved by the app by subscribing to the MQTT broker and displayed on the app
- Regarding information transmitted from the app, when we press a button on the app with a certain function, the system will publish our command to MQTT
- ESP32 will receive these control commands by subscribing
- These commands will be written to EFR32MG24 to control actuators via BLE GATT.
Softwater Design
In the frontend design section, to facilitate information processing and user- friendliness, our app is designed to have 4 main screens:
Login Screen: Allows each user to log in to their account with their respective plant data
Store Interface: Enables users to conveniently connect with the store and purchase essential items for their plants
Garden Interface: Assists users in selecting the plants they want to grow from the available options
Plant Monitoring Interface: Helps users monitor, control, and observe the status of their plants
App Integration with MQTT Broker
To set up the MQTT Broker, we use HiveMQ Public Broker as the primary MQTT Broker for the product
- No need to set up or maintain a server for continuous connectivity
- Full support for common connection ports
- Difficult to scale the system
- Lower security capabilities compared to creating your server
4.5.2.2 Connection between the App and MQTT Broker
We use the paho-mqtt library to connect the App to HiveMQ Cloud We can set up the paho-mqtt to connect the App to HiveMQ Cloud through the following steps:
Step 1: Add paho-mqtt to the App
Install paho-mqtt: Open the Terminal (Powershell) and navigate to the root directory of the App Run the command: `npx expo install paho-mqtt` Wait for the installation to complete Then import paho mqtt into the App.-
Step 2: Initialize the connection between the App and the HiveMQ broker Step 2.1: Initialize the App as a client:
Create a client object with the following parameters: the broker's URL (broker.hivemq.com), the connection port to the broker (Number(8000)), and the client's ID (clientID)
Step 2.2: Subscribe the App to MQTT Broker: Initialize a function to handle subscriptions
Use `useEffect` to initialize the `client.connect` function with two fields:
`onSuccess` returns a log confirming the connection to the MQTT Broker, then subscribes to channels Finally, use the `onMessageArrived` function with the `message` parameter to return information in string format formatted through functions like `onValueMessage`, `onColorMessage`, `onStateMessage`, etc
`onFailure` receives an `error` parameter to return a connection error message
Step 2.3: Initialize the publish functions for the App
- Initialize the `state` variable and `setState` as "On"
- Create the `toggleState` function to handle the pump state (On/Off)
- Initialize the `newState` variable as a ternary operator comparing the initial `state` and "On" This ternary operator returns "On" if true and
- Create a message using the `new Paho.message()` function with
- Change the `destinationName` field of the message to the name of the receiving topic
- Finally, use the `client.send()` function with the `message` parameter to send the message to the broker
- Initialize the `color` variable and `setColor` as "Red"
- Create the `changeColor` function to handle the LED state (Red/Blue/Green)
- Initialize the `newColor` variable as "Red"
- Create conditional logic with a `switch` statement and pass `newColor` as the parameter Then create cases to change the value of the `newState` variable
- Change the `destinationName` field of the message to the name of the receiving topic
- Use the `client.send()` function with the `message` field to send the message to the broker.
Evaluation
Advantages
+ The power supply conversion module works well + Well-designed, easy-to-make connections.
+ Neat and organized frame and devices
+ Devices respond correctly to commands from the app
+ Sensor libraries work well and are accurately adjusted t real-world conditions
+ Actuators are controlled accurately, as intended + BLE is successfully communicating with ESP32 ESP32:
+ SmartConfig: Successfully automates WiFi connection when entering credentials on ESP32
+ BLE: Reads values from EFR32MG24 and receives notifications through BLE
+ MQTT: Successfully creates arrays to transmit sensor d via MQTT to the app
+ Displays basic interfaces like login, control, and plant information
+ Can perform desired actions such as login, logout, and sending data via MQTT
+ Designed as intended and user-friendly
+ Can link data to the backend via Django.
Disadvantages
+ Still some delay when receiving commands from the ap + Wiring design needs improvement
+ Temporary designs are not yet confirmed and are o aesthetic
+The entire program's code optimization and synchroniz are lacking
+ Sensors occasionally encounter issues when reading da + BLE occasionally loses or misinterprets data
+ Sometimes encounters data reception issues from EFR + MQTT connection is intermittent and lacks d synchronization
+ The entire code lacks cleanliness and consistency App + Some delays when executing commands from the app
+ Django integration is incomplete, making the challenging to use.
Conclusion and Future Development
Conclusion
The system has successfully implemented essential functions, including sensor data acquisition, actuator control, remote app control, and seamless Wi-Fi connectivity, among other functions Throughout the competition journey, our team conducted exhaustive testing and parameter evaluations to ensure sensor data accuracy, thereby delivering reliable plant monitoring insights Moreover, in our pursuit of an aesthetically pleasing design, we delved into various design concepts and prototypes to elevate the overall product experience
Despite these accomplishments, the product does exhibit certain limitations and unforeseen functionalities Nevertheless, we view these challenges as opportunities for future improvements, with our unwavering commitment to delivering an outstanding product.
Future development
1 Create an additional server/cloud for storing, processing, and securing data
When we add a replacement server instead of MQTT, the data will be better streamlined, processed more accurately, and enhanced security for both the system and users2
Figure 6.1 Creating an additional server/cloud open
2 Introducing Various Design Styles to Suit Indoor Plant Systems
Given the system's capability to control multiple indoor plant devices, diversifying design styles for arranging them in different locations is crucial This includes designs for wall-mounted systems, desktop setups, and more
Figure 6.2 Controlling multiple indoor plant devices