1. Trang chủ
  2. » Luận Văn - Báo Cáo

Research on bluetooth low energy (ble) and implement a control application using ble

83 8 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Research on Bluetooth Low Energy (BLE) and Implement a Control Application Using BLE
Tác giả Tran Cao Bao An, Le Hieu Phuong, Ngo Nguyen Thuan
Người hướng dẫn Ph.D Nguyen Tran Huu Nguyen, Ph.D Pham Hoang Anh
Trường học Ho Chi Minh City University of Technology
Chuyên ngành Computer Engineering
Thể loại University Thesis
Năm xuất bản 2021
Thành phố Ho Chi Minh City
Định dạng
Số trang 83
Dung lượng 3,74 MB

Cấu trúc

  • 1.1 Bluetooth Low Energy (11)
    • 1.1.1 Overview (11)
    • 1.1.2 Benefits of BLE (12)
    • 1.1.3 Limitations of BLE (12)
    • 1.1.4 Thesis proposal requirements (12)
    • 1.1.5 Thesis goal (13)
  • 2.1 Bluetooth Low Energy (14)
    • 2.1.1 Operating mode (14)
    • 2.1.2 Basic Operations of BLE (16)
    • 2.1.3 Frequency characteristics and transmission data structure of BLE 8 (18)
    • 2.1.4 BLE Stack (22)
    • 2.1.5 BLE Protocol and BLE Profile (24)
  • 2.2 Universal Asynchronous Receiver/Transmitter (UART) (27)
  • 2.3 System architecture (30)
  • 2.4 nRF52833 Development Kit (31)
    • 2.4.1 Kit content (31)
    • 2.4.2 Interface MCU (31)
  • 2.5 Segger Embedded Studio (32)
    • 2.5.1 Overview (32)
    • 2.5.2 Installation and setting up (33)
  • 2.6 SoftDevices (33)
    • 2.6.1 Overview (33)
    • 2.6.2 Compatible SoftDevices (34)
  • 2.7 Software Development Kit (SDK) (34)
    • 2.7.1 Overview (34)
    • 2.7.2 Get started (34)
    • 2.7.3 Other components (35)
  • 2.8 Nordic nRF Toolbox app (35)
  • 2.9 Android Studio (38)
  • 2.10 Hterm and Arduino serial monitor (39)
    • 2.10.1 Hterm (39)
    • 2.10.2 Arduino serial monitor (39)
  • 3.1 Introduction (40)
  • 3.2 System feature base on aquaponic model (40)
  • 3.3 Implementation idea and system feature (41)
  • 4.1 Android Application (43)
    • 4.1.1 User guide (43)
    • 4.1.2 BLE Communication (45)
  • 4.2 Printed Circuit Board Design (46)
    • 4.2.1 Hardware Components description (46)
    • 4.2.2 Hardware Design (56)
    • 4.2.3 Implement the board (63)
  • 4.3 Programming micro-controller (65)
    • 4.3.1 Arduino Uno (65)
    • 4.3.1. a Timer (65)
    • 4.3.1. b Interrupt (67)
    • 4.3.1. c Current Sensor ACS712 (67)
    • 4.3.1. d Water Sensor (69)
    • 4.3.1. e Moisture Sensor (71)
    • 4.3.2 nRF52833 (72)
    • 4.3.3 Functionality (75)
  • 4.4 Communication between application and board (77)
  • 6.1 Achievements (80)
  • 6.2 Limitations (80)
  • 6.3 Future plan (80)
  • 6.4 Conclusion (81)

Nội dung

Bluetooth Low Energy

Overview

Bluetooth Low Energy (BLE), also known as "Bluetooth Smart," is a wireless personal area network technology developed by the Bluetooth Special Interest Group (Bluetooth SIG) for innovative applications in healthcare, fitness, beacons, security, and home entertainment Launched with BLE 4.0, BLE Smart operates alongside traditional Bluetooth, each catering to different technical requirements Despite the availability of various wireless technologies, BLE remains widely utilized in numerous projects due to its high compatibility with multiple platforms, particularly mobile systems like iOS, Android, and Windows Phone.

There are two types of BLE devices: Bluetooth Smart and Bluetooth Smart Ready:

• Bluetooth Smart (Single mode): only communicate with Bluetooth Smart or Blue- tooth Smart Ready devices.

• Bluetooth Smart Ready (Dual mode): can communicate with Bluetooth devices such as Bluetooth Smart, Bluetooth Smart Ready and Classic Bluetooth.

Every technology has its own benefits and limitations, and BLE is no exception.

We illustrate some pros and cons of BLE to determine whether BLE is suitable for our specific application which we will discuss later.

Benefits of BLE

Bluetooth Low Energy (BLE) offers significantly lower power consumption compared to other low power technologies By minimizing radio usage and transmitting small data packets at reduced speeds, BLE optimizes energy efficiency This capability enables devices to operate for months or even years on a single coin-cell battery, making it an ideal choice for long-lasting applications.

Accessing official specification documents comes at no cost, unlike many other wireless protocols and technologies that require membership in the corresponding official group or consortium to obtain such specifications.

• Lower cost of modules and chip-sets, even when compared to other similar tech- nologies.

• Most importantly, its existence in most smartphones in the market.[2]

Limitations of BLE

The data throughput of Bluetooth Low Energy (BLE) is constrained by the physical radio layer's (PHY) data rate, which varies based on the Bluetooth version For Bluetooth 4.2 and earlier, the transmission rate is fixed at 1 Mbps In contrast, Bluetooth 5 and later versions offer variable rates, allowing for 1 Mbps or an increased rate of 2 Mbps when utilizing the high-speed feature, depending on the selected mode and PHY configuration.

Bluetooth Low Energy (BLE) was specifically designed for short-range applications, which inherently limits its operational range Several factors contribute to this limitation, affecting the effectiveness of BLE in various environments.

– BLE operates in the 2.4 GHz ISM spectrum which is greatly affected by obsta- cles that exist all around us such as metal objects, walls, and water (especially human bodies).

– Performance and design of the antenna of the BLE device.

– Physical enclosure of the device.

To enable data transfer from a BLE-only device to the Internet, a second BLE device with an IP connection is essential This device receives the data and subsequently relays it to another IP device or directly to the Internet, ensuring seamless connectivity.

Thesis proposal requirements

• Learn how BLE works in basic

• Learn how nRF52833 development kit communicates with Android App.

• Connecting the nRF52833 DK to smart phone using UART.

• Decide what application will be implemented, its specification.

• Make a PCB that utilize the Bluetooth LE modules.

• Write an application that has an application running on an Android Phone commu- nicate with a circuit using BLE.

Thesis goal

• Summarize basic knowledge about Bluetooth Low Energy and some related knowl- edge such as nRF52833 DK documents, supported software, etc.

• Design and implement the structure of aquaponic system using nRF52833 DK and Arduino Uno.

• Connecting the nRF52833 DK to smart phone using UART.

• Researching and programming the main code of BLE based on source code pro- vided by Nordic Semiconductor using Segger Embedded Studio.

• Researching and programming the main code of the aquaponic system using the Arduino Uno board and Arduino software.

• Research and determine devices, IC components and sensors for aquaponic system.

• Create the mobile application which can interact directly with nRF52833 DK and arduino board using Android Studio software.

• Design and implement the printed circuit board for aquaponic system using Altium Designer.

Bluetooth Low Energy

Operating mode

Bluetooth Low Energy (BLE) operates in four distinct modes: Peripheral, Central, Observer, and Broadcaster While most devices typically function in a single mode, certain specialized applications allow devices to operate in multiple modes simultaneously.

BLE devices utilize two primary mechanisms for communication: Broadcasting and Connection, as defined by the Generic Access Profile (GAP) Each mechanism offers distinct advantages, enabling effective interaction between devices.

Figure 2: The architecture of Peripheral/Central BLE

BLE Central acts as the initiating device that actively seeks connections with other Bluetooth Low Energy (BLE) devices, including smartphones and tablets Once a successful connection is established, BLE Central is referred to as the BLE master, taking control of synchronous operations to maintain the connection and facilitate data transmission.

A BLE Peripheral is a device, such as a refrigerator, fan, or light, that accepts connection requests and becomes a BLE Slave upon successful pairing This means that these devices synchronize with the master device to maintain a stable connection and facilitate data transmission.

BLE Central devices can connect to multiple BLE Peripherals, depending on the BLE chip, while a BLE Peripheral can only connect to one BLE Central Once a connection is established, the BLE Peripheral ceases to broadcast packets Due to their distinct operating modes, Central and Peripheral devices exhibit different characteristics.

BLE Central BLE Peripheral Before connection

Get the identification information from surrounding devices

Broadcast device identification information Currently connection

Send a connection request to the device which we want to connect

Receive a connection request and decide whether to connect or not After connection

Submit a request about the types of information and possibly provided BLE Peripheral devices

Submit the types of information that the device can provide data transfer process

Receive updates from BLE Peripheral device to perform application functionality

Send data to the BLE Central device when there is an update in the device

After 2 BLE devices are connected, the relationship between Peripheral and Cen- tral hasn’t existed and we have a new concept: BLE Server and BLE Client:

• BLE Server: server devices (such as BLE sensors) have a local database and access control methods, and provide resources to the remote client Usually, the slave is also the server.

• BLE Client: client devices (such as smartphones, tablets) access remote resources over a BLE link using GATT protocol Usually, the slave is also the master.

BLE Central/Peripheral and BLE Server/Client are distinct concepts in Bluetooth Low Energy (BLE) communication Before a connection, BLE Central/Peripheral defines the roles of the devices, while BLE Server/Client describes the data exchange once connected After establishing a connection, a BLE Central device can function as either a BLE Server or a BLE Client, depending on whether it sends or receives data Similarly, a BLE Peripheral can also operate as a BLE Server or BLE Client post-connection.

Another communication network model for BLE is broadcasting and observing:

• BLE Observer is BLE Central but only receives identification data of surrounding devices but never creates a connection (continuously scans at the preset frequency to receive advertising packets when connected).

Figure 3: The structure of Broadcaster/Observer

• BLE Broadcaster is the BLE Peripheral that only transmits identity data but never accepts connection requests from BLE Central (Send connectionless broadcasts to any device that can receive it).

This communication method enables a device to simultaneously transmit data to multiple devices quickly and easily, making it ideal for transferring small amounts of information However, it is important to note that this approach does not ensure data security, which makes it unsuitable for sending sensitive information.

After gaining some knowledge about the concept of BLE Central/Peripheral and BLE Broadcaster/Observer, we should know some advantages of connection towards broad- casting:

• The ability to establish secure encrypted federated connection

The Generic Attribute Profile (GATT) enables efficient data organization by utilizing additional protocol layers, allowing for the arrangement of data with various attributes This structured approach revolves around defined services and characteristics, enhancing data management capabilities.

Basic Operations of BLE

According to standard BLE definition, there are 4 basic operations in BLE devices:[4]

• Advertising: is the act of broadcasting the basic identification data of the BLEPeripheral device to the surrounding environment before connecting.

• Scanning: is the operation of BLE Central device to collect identification data of many surrounding BLE Peripheral devices.

Connecting involves the interaction between BLE Central and BLE Peripheral devices The BLE Central device initiates the process by sending a Scan Request for additional identification information In response, the BLE Peripheral sends back a Scan Response containing the requested data The BLE Central then verifies this identity information from both the Advertising data and Scan Response before sending a Connection Request Ultimately, the BLE Peripheral device responds with either an acceptance or rejection of the connection through a Connection Response.

Discovering is the process undertaken by a BLE Client device after establishing a connection, allowing it to gather information about the various data types available from the BLE Server device For example, a BLE Server may offer data such as accelerometer readings or temperature and humidity levels, which the BLE Client needs to identify in order to understand what data it can receive.

The connection process of BLE devices is shown in the following figure:

Figure 4: The connection process of BLE devices

Frequency characteristics and transmission data structure of BLE 8

Operating frequency of BLE devices:

BLE devices can operate in a frequency range from 2402MHz to 2480MHz and this frequency range is divided into 40 transmission channels where BLE chips can use 1 of

40 frequency channels to transmit data The frequency value of each channel is calcu- lated as follows: fn = 2402 + 2*n (MHz) which 0≤n≤39.

These frequency channels will be used as follows:

• The 2402MHz, 2426MHz and 2480MHz channel are three channels which only used to transmit BLE Peripheral identification data before connection and they are calledAdvertising Channels.

• All remaining 37 channels will be used to transfer application data between BLE devices after connection and they are calledData Channels.

To enable simultaneous communication between a BLE Central device and multiple BLE Peripheral devices, it is essential to utilize three Advertising channels and 37 Data channels With only one Advertising channel, the BLE Central can either receive data from just one BLE Peripheral at a time or face inaccuracies in data reception if multiple peripherals attempt to use the same channel simultaneously.

Figure 5: 3 Advertising channels and 37 Data channels

The connecting process of BLE devices

To establish a connection between two Bluetooth Low Energy (BLE) devices, the BLE Central device receives advertising data from nearby BLE Peripheral devices Both devices periodically transmit and receive data to conserve energy, rather than doing so continuously The BLE Central employs a scanning interval, waking up to receive identification data from the three Advertising Channels after each interval Likewise, the BLE Peripheral utilizes an advertising interval, waking up to transmit advertising data on the same three channels, specifically sending Advertising Packets each time it wakes up.

In summary, we can see the factors affecting the fast/slow when BLE Central rec- ognizes the surround BLE Peripheral devices:

Choosing a low Scanning Interval for BLE Central allows for more frequent wake-ups to gather additional advertising data, enabling quicker identification of suitable BLE Peripherals; however, this approach also leads to increased energy consumption.

Selecting a low Advertising Interval for BLE Peripheral results in frequent wake-ups and increased data broadcasting, enhancing the chances of data reception by BLE Central However, this approach also leads to higher energy consumption, as more Advertising Packets translate to a greater volume of transmitted data.

Figure 6: The scanning and Advertising process of BLE

The diagram demonstrates the scanning process of BLE Central alongside the advertising process of BLE BLE Peripheral activates and transmits advertising data across three advertising channels BLE Central receives this advertising data at intervals of 0 ms, 20 ms, 0 ms, 100 ms, and 120 ms, allowing it to establish a connection at one of these specified times.

Data structure of Advertising data

Advertising data is crucial for BLE (Bluetooth Low Energy) communication, enabling BLE Central devices to identify and connect with BLE Peripheral devices During the Advertising Interval, the BLE Peripheral transmits three identical advertising packets across three advertising channels Each advertising packet can contain up to 31 bytes of identification data, with a total capacity of 47 bytes, which includes 16 bytes dedicated to the advertising data structure and up to 31 bytes for the specific advertising data of the BLE Peripheral device.

Figure 7: Data structure of Advertising packet

The Advertising Channel PDU (Packet Data Unit) contains essential identification data for the BLE Peripheral device, which must be configured in the code Other components of the Advertising Packet, including the Preamble, Access Address, and CRC, are automatically generated by the BLE chip at the hardware level.

The parameters of the Advertising Channel include two main parts: the Header and Payload

The Headeris 2 bytes long includes these information:

• PDU Type(4 bits) is information about the functionality of the Advertising Packet.

The scanning and advertising processes of BLE Central and BLE Peripheral utilize three advertising channels, with the PDU type indicating the specific packet type Detailed information can be found in the table below.

• RFU (Reserved for Future Use) (4 bits) are unused bytes and are reserved for future mission.

• TxAdd (1 bit) determines whether the MAC address of BLE device is Public or Random.

• RxAdd(1 bit) determines whether this Advertising Packet has a beacon function.

• Length (6 bits) determine the length of the data in the payload of the Advertising Packet.

The identification data transmitted by the BLE Peripheral and allows the BLE Central to send connection request

The identification data transmitted by the BLE Peripheral and only accepts connection requests from a specific BLE Central

The identification data transmitted by BLE Peripheral but will not accept any request by BLE Central (Broadcaster mode)

The request is sent from BLE Central to BLE Peripheral to request additional identification information (Scanning Request)

The data transmitted by BLE Peripheral in response to BLE Central’s Scanning Request (Scanning Response)

The connection request is send from BLE Central to 1 BLE Peripheral after fully receiving identification data

Similar to ADV NOCONN IND (BLE Peripheral will not accept any connection request) but BLE Peripheral will reply Scanning Response if BLE Central requests

The Payload of Advertising Packet contains identification information of BLE Peripheral device in the following structure:

• The first 6 bytes contain the hardware address (MAC address).

The subsequent 31 bytes are organized to outline a structure for identification data types, consisting of a data length (1 byte), an identification information type (1 byte), and the corresponding identification information data, along with additional identification information within the same 31 bytes.

So we just focus on some identification information in Advertising Data and Scan- ning Response used in almost BLE application:

A UUID (Universal Unique Identifier) serves as a distinctive identifier for various types of information applications, such as temperature, humidity, and motion sensors, provided by a BLE (Bluetooth Low Energy) device upon connection BLE peripheral devices can broadcast their UUID values, enabling BLE central devices to identify the specific peripheral they are seeking In practical applications, the UUID value is configured for emission by the BLE device, with a value range from 0x02 to 0x07.

The Local Name refers to the identifier displayed when scanning for devices, such as in the Bluetooth settings of a smartphone During a scan, users can view the names of all detected devices, which are derived from the Local Name in the Advertising Packet The value range for Local Name is from 0x08 to 0x09, where 0x08 presents only a partial Local Name, while 0x09 reveals the complete Local Name.

BLE Stack

Figure 8: The architecture of Bluetooth Low Energy

The BLE Stack, developed by manufacturers like Nordic, refers to the library code essential for Bluetooth Low Energy applications A typical BLE application is structured into three primary components: the controller, the host, and the application itself, each serving a distinct function within the overall system.

The application code initiates the Stack and performs essential tasks, including reading temperature and humidity sensors and transmitting data to a smartphone This layer incorporates various features commonly found in BLE devices.

– The BLE protocol stack layers interact with applications and profiles as de- sired Application interoperability in the Bluetooth system is accomplished by Bluetooth profiles.

– The profile defines the vertical interactions between the layers as well as the peer-to-peer interactions of specific layers between devices.

– A profile composed of one or more services to address particular use case A service consists of characteristics or references to other services.

Profiles and applications that operate on the Generic Attribute Profile (GATT) or Generic Access Profile (GAP) layers of the Bluetooth Low Energy (BLE) protocol stack manage essential functions such as device discovery and connection services for BLE devices.

The Generic Access Profile (GAP) serves as a crucial interface between the application layer and its associated profiles, facilitating device discovery and connection services for Bluetooth Low Energy (BLE) devices Additionally, GAP is responsible for initiating essential security features, ensuring a secure and efficient connection process.

The Generic Attribute Profile (GATT) is a service framework that defines sub-procedures for using the attribute protocol, facilitating data communication between Bluetooth Low Energy (BLE) devices Within GATT, there are two primary roles: Server and Client The Server is responsible for exposing its data and potentially other controllable aspects, while the Client interacts with the Server to read its data and manage its behavior.

The Attribute Protocol (ATT) is a crucial layer in Bluetooth Low Energy (BLE) that enables devices to share specific data attributes Operating as a client/server protocol, each BLE device can function as either a client, a server, or both Clients request data from servers, which respond by sending the requested attribute values or an acknowledgment (ACK) signal When a client needs to read or write attribute values, it broadcasts a read or write request to the server, facilitating seamless data communication between devices.

The Security Manager (SM) facilitates secure device pairing and key distribution, ensuring safe connections and data exchange between Bluetooth Low Energy (BLE) devices It offers essential services to other layers of the protocol stack, enhancing overall security in BLE communications.

The Logical Link Control and Adaptation Protocol (L2CAP) serves as a crucial multiplexing layer in Bluetooth Low Energy (BLE) communications It efficiently aggregates multiple upper-layer protocols and encapsulates them into standardized BLE packets, which are then transmitted to the lower layers of the protocol stack.

The Host Controller Interface (HCI) is a standard protocol established by the Bluetooth specification, facilitating communication between the Host layer and the Controller layer These layers may be implemented on separate chips or integrated within a single chip.

– Host Controller Interface (HCI)is presented above.

The Link Layer (LL) serves as a crucial interface between the physical layer and higher-level protocols, offering an abstraction that facilitates interaction with the radio It manages the radio's state and ensures compliance with the timing requirements outlined in the Bluetooth Low Energy specification.

The Physical Layer (PHY) is the foundational layer responsible for the transmission and reception of signals It encompasses the physical radio components used for communication, as well as the processes of modulating and demodulating data Operating within the ISM band, specifically the 2.4 GHz spectrum, this layer plays a crucial role in wireless communication systems.

BLE Protocol and BLE Profile

For standard BLE communication, there are some predefined rules:[6]

• Protocol: Regulations on packet format, routing, multiplexing, encryption, etc to exchange data.

A profile outlines the application of a protocol in specific scenarios, with configurations provided by the BLE device manufacturer referred to as generic profiles In contrast, user-defined configurations tailored to particular use cases are known as use-case profiles.

– Generic profiles are basic profiles defined in Bluetooth Specifications docu- ments, especially are two profiles with connecting and exchanging data func- tion: GAP and GATT.

– Use-case profileis used by Bluetooth Special Interest Group (SIG) or by ven- dors.

The Generic Access Profile (GAP) is the topmost control layer in Bluetooth Low Energy (BLE) that regulates essential roles such as Broadcaster, Observer, Peripheral, and Central It facilitates communication between BLE devices by managing connection, synchronization, and security, making it a mandatory configuration for all BLE devices.

The BLE Specifications document defines the following concepts considering the in- teraction between devices:

• Role: Each device can act in one or more different role at the same time: Broad- caster, Observer, Peripheral, Central.

• Modes:is a state that a device can enter for a period of time to achieve a particular purpose or special things, to allow a peer to perform a particular procedure.

The Link layer is responsible for managing the exchange of packets, allowing devices to fulfill specific functions Typically, procedures are linked to operational modes, making it common to consider modes and procedures in tandem.

GAP is designed with a strong emphasis on security, utilizing the Security Manager and Security Manager Protocol to establish security modes and procedures for determining device security levels during data exchanges Furthermore, GAP incorporates additional security features that enhance data protection beyond the specific modes and procedures, ensuring that each application meets its required security standards.

In Bluetooth Low Energy (BLE) connections, the methods for exchanging profiles and user data are defined by the Generic Attribute Profile (GATT), which differs significantly from the Generic Access Profile (GAP) GATT focuses solely on the transmission procedure and format of data, utilizing the Attribute Protocol (ATT) for data exchange between devices This data is systematically organized into services, which group related user data pieces known as characteristics In essence, BLE data transmission is structured and hierarchically organized into services and characteristics, ensuring efficient communication between devices.

The GATT Client, which corresponds to the ATT client, is responsible for sending requests to the server and receiving response results Since the GATT Client is initially unaware of the server's supported properties, it must conduct service discovery to identify available services and characteristics.

– GATT Server: corresponding ATT server, receives the request from the client and sends the corresponding content.

The roles of the GATT (Generic Attribute Profile) are distinct from those of the GAP (Generic Access Profile), allowing both GAP Central and GAP Peripheral to function as either a GATT Client or GATT Server, or even simultaneously fulfill both roles.

A UUID (Universally Unique Identifier) is a 128-bit (16-byte) device identifier that is globally unique Due to its large size, which occupies a significant portion of data packets, the Bluetooth Low Energy (BLE) Specification introduces two shorter UUID formats: 16-bit and 32-bit These abbreviated formats are exclusively applicable to UUIDs defined within the Bluetooth Specification.

Attributes are the fundamental data entities defined by GATT and ATT, which exclusively operate with attributes for client-server interactions Each attribute encapsulates user data and includes self-descriptive information, ensuring that all data is systematically organized in this format.

– Handle: the unique 16-bit number on each server to address the attribute. – Type: the UUID type, includes 16 bit, 32 bit, 128 bit.

– Permission: define the ATT operations that can be executed on the particular attribute.

– Value: contains the actual data in the attribute, limited to 512 bytes.

• Services and characteristics: The data exchanged through the BLE connection is structured data, organized hierarchically into services, the services themselves include characteristics.

GAP and GATT serve as the foundational profiles for all Bluetooth Low Energy (BLE) applications Additionally, devices may offer various other profiles derived from GAP and GATT, tailored to specific applications Key services provided by these devices include functionalities such as Heart Rate Monitoring, Battery status, Health Thermometer readings, and Human Interface Device (HID) support.

Universal Asynchronous Receiver/Transmitter (UART)

UART is a widely utilized device-to-device communication method that operates as a physical circuit within a microcontroller or as a standalone Integrated Circuit (IC) Unlike communication protocols such as SPI and I2C, UART's primary function is to transmit and receive serial data, transferring information bit by bit over a single line or wire For two-way communication, it employs two wires to facilitate effective serial data transfer This approach to serial communication often requires fewer components and wiring, leading to reduced implementation costs based on specific application and system needs.

UART is a widely used communication protocol in embedded systems, microcontrollers, and computers, enabling device-to-device hardware communication with just two wires for transmitting and receiving data As an asynchronous protocol, UART operates without a clock signal, allowing the output bits from the transmitting device to be received independently at the other end.

Figure 10: The communication of two UARTs

The two signals of each UART device are named:

The primary function of a transmitter and receiver line in each device is to facilitate serial communication by transmitting and receiving serial data The transmitting UART connects to a controlling data bus that sends data in parallel format, which is then transmitted serially, bit by bit, over a transmission line to the receiving UART The receiving UART converts this serial data back into parallel format for the receiving device It is important to note that each UART device includes dedicated transmit and receive pins for their respective functions.

For effective UART and serial communication, it is essential to match the baud rate on both the transmitting and receiving devices The baud rate defines the speed of information transfer over a communication channel, determining the maximum number of bits transmitted per second through the serial port.

Wires 2 Speed Any speed up to 115200 baud, usually 9600 baud

The UART interface operates asynchronously, meaning it does not require a clock signal for synchronization between the transmitter and receiver Instead, the transmitter generates a bit-stream using its own clock signal, while the receiver samples the incoming data with its internal clock To ensure proper synchronization, both devices must operate at the same baud rate; otherwise, timing discrepancies may occur, leading to errors in data transmission and reception.

In UART communication, data is transmitted in packets, which are essential for connecting the transmitter and receiver Each packet is structured with a start bit, a data frame, a parity bit, and stop bits, enabling effective control over the physical hardware lines involved in the transmission process.

In UART data transmission, the line remains at a high voltage level when idle To initiate data transfer, the transmitting UART momentarily pulls the line low for one clock cycle The receiving UART detects this high-to-low transition and starts reading the data bits at the specified baud rate.

The data frame is essential for transferring actual data, with a length ranging from 5 to 8 bits when a parity bit is included In the absence of a parity bit, the data frame can extend to 9 bits Typically, data is transmitted with the least significant bit being sent first.

• Parity: Parity describes the evenness or oddness of a number The parity bit is a way for the receiving UART to tell if any data has changed during transmission.

Electromagnetic radiation, mismatched baud rates, and long-distance data transfers can alter bits Once the receiving UART processes the data frame, it tallies the bits with a value of 1 to determine whether the total is even or odd.

In a data transmission system, the parity bit plays a crucial role in error detection When the parity bit is set to 0, indicating even parity, the total count of 1 bits in the data frame should also be even Conversely, if the parity bit is set to 1 for odd parity, the count of 1 bits must be odd If the parity bit aligns with the data's total, the UART confirms that the transmission is error-free However, if the parity bit is 0 and the total is odd, or if the parity bit is 1 and the total is even, this indicates that errors have occurred in the data frame.

Stop bits are essential in UART communication as they indicate the conclusion of a data packet by transitioning the transmission line from low to high voltage for a minimum of two bit durations This mechanism ensures proper synchronization and data integrity, making UARTs a reliable choice for serial communication.

• No clock signal is necessary.

• Has a parity bit to allow for error checking.

• The structure of the data packet can be changed as long as both sides are set up for it.

• Well documented and widely used method.

• The size of the data frame is limited to a maximum of 9 bits.

• Does not support multiple slave or multiple master systems.

• The baud rates of each UART must be within 10

System architecture

Figure 12: system architecture in overview

The system consists of four primary components: the PCB, the NRF52833 board, a mobile phone, and a computer Additionally, various sub-components, including electric devices and sensors, connect to the PCB and the Arduino board, which are integral to the project's application For now, we will concentrate on the main components.

The desktop environment compiles code for the NRF52833 board and mobile application, as well as the Arduino board, primarily serving developers during the setup and development phase Casual users typically do not engage with this technical aspect.

After installing the application, mobile phones can seamlessly communicate with the NRF52833 board via Bluetooth Low Energy (BLE) Once connected, users can issue commands to control the system, while the NRF52833 board relays information back to the mobile device through the same BLE connection.

The NRF52833 board plays a crucial role in facilitating communication between the mobile application and the system It receives signals via Bluetooth Low Energy (BLE) from the mobile app, processes this data, and transmits signals to the PCB, ensuring seamless interaction in both directions.

The Printed Circuit Board (PCB) serves as the central hub for the project, collecting data from incoming signals and transmitting it to the NRF52833 board Additionally, the PCB receives signals from the NRF52833 board and relays commands to control various electrical devices.

nRF52833 Development Kit

Kit content

Before we work with this Kit, we must have some required hardware and software.

• Hardware requirement: Our personal computer and Micro-USB 2.0 cable

• Software requirement: SEGGER J-Link Software

The nRF52833 DK Kit with NFC-A is an essential tool for research and development, featuring comprehensive hardware, preprogrammed firmware, detailed documentation, and hardware schematics along with layout files.

Figure 13: nRF52833 DK Kit and NFC antenna

The hardware design files for the nRF52833 DK, which include schematics, PCB layout files, bill of materials, and Gerber files, can be accessed through the nRF52833 product page available at [Nordic Semiconductor](https://www.nordicsemi.com/products/nrf52833).

Interface MCU

The interface MCU on the nRF52833 DK runs SEGGER J-Link interface firmware and is used to program and debug the firmware of the nRF52833 System on Chip (SoC).

Figure 14: nRF52833 DK Interface MCU

The IF Boot/Reset button on the Development Kit is linked to the interface MCU, allowing it to reset the nRF52833 System on Chip (SoC) and enter bootloader mode Under normal operation, this button serves as a reset for the nRF52833 SoC To access bootloader mode, press and hold the reset button while powering up the Development Kit until LED5 begins to blink Powering up can be done by either disconnecting and reconnecting the USB cable or toggling the power switch.

• Virtual COM port: The on board interface MCU features an UART interface through a virtual port It has some following features:

– Flexible baud rate setting up to 1 Mbps.

Dynamic Hardware Flow Control (DHFC) is an essential handshaking mechanism designed to prevent byte overflow in modems It operates by utilizing two dedicated pins on the RS-232 connector: Request to Send (RTS) and Clear to Send (CTS) This method ensures efficient data transmission and helps maintain communication integrity.

– Tri-stated UART lines when no terminal is connected.

The Mass Storage Device (MSD) feature of the interface MCU enables the Development Kit to function as an external drive on your computer, facilitating drag-and-drop programming While this drive allows for easy file transfer, it does not support file storage To program the device, simply copy a HEX file to the drive, and the interface MCU will handle the programming process.

Segger Embedded Studio

Overview

In this thesis proposal, we use Segger Embedded Studio for programming, debugging and compiling our source code Segger Embedded Studio is a free IDE used for almost

Segger Embedded Studio supports the C programming language across all embedded systems and is compatible with major platforms, including Windows, Linux, and MacOS Its consistent interface and fully portable projects facilitate efficient development regardless of the operating system With fast build times powered by J-Link debug technology, developers can easily download example source code from GitHub and utilize Segger to compile their code for the nRF board.

Installation and setting up

Embedded Studio is a robust C/C++ Integrated Development Environment (IDE) tailored for microcontrollers, offering a comprehensive solution for professional embedded C programming and development It ensures stability and supports a seamless workflow across various development environments To download Segger Embedded Studio, please visit the following link to select the appropriate version: https://www.segger.com/downloads/embedded-studio.

To set up the installed package please follow the instructions in this link: https:// www.segger.com/products/development-tools/embedded-studio/technology/ installation

SoftDevices

Overview

A SoftDevice is a precompiled binary software that implements wireless protocols developed by Nordic Semiconductor, allowing application developers to have minimal compile-time dependence on its features It operates within a unique hardware and software framework that ensures run-time isolation and determinism, resembling a hardware peripheral abstraction with a functional interface The SoftDevice Application Program Interface (API) provides a high-level programming language interface, such as a C header file, and can be viewed as a BLE Stack Library for Nordic chips like the nRF52833 DK.

Compatible SoftDevices

BLE SoftDevices come in various versions tailored to specific applications and functions, with each version offering bug fixes, enhanced stability, and additional features However, increased functionality often results in a larger Stack capacity, which can reduce the resources available for your application Therefore, it is essential to select an appropriate SoftDevice that aligns with your application's needs to optimize resource usage In this thesis proposal, we will utilize the nRF52833 DK Kit, which supports several suitable SoftDevices.

1 S113 SoftDevice: (latest version: 7.2.0) is a memory-optimized Peripheral-only Bluetooth Low Energy protocol stack for our kit nRF52833.

2 S140 SoftDevice: (latest version 7.2.0) is a feature-rich Central and Peripheral Bluetooth Low Energy protocol stack for the nRF52833.

3 S122 SoftDevice: (latest version 8.1.0) is a memory-optimized Central only Blue- tooth Low Energy protocol stack for the nRF52833.

In this project, we have selected the SoftDevice S140 for testing our source code and implementing our tasks due to its support for both Central and Peripheral resources Moving forward, we plan to utilize the S140 SoftDevice to enhance and develop our aquaponic application For more information on compatible SoftDevices, please visit [Nordic Semiconductor's website](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52833).

Software Development Kit (SDK)

Overview

In this thesis proposal, we utilize the nRF5 SDK version v17.0.2, which offers a comprehensive development environment for nRF5 Series devices This SDK includes a wide array of drivers, libraries, and examples for peripherals, as well as SoftDevices and proprietary radio protocols The accompanying documentation provides essential descriptions and reference materials to aid users and developers in navigating the SDK's components Additionally, the nRF5 SDK features numerous examples for development and testing purposes, with a specific focus on the S140 SoftDevice in this version.

Get started

The SDK includes example applications that can be executed on our development kit to verify proper setup Following these tests, we can utilize the examples as a foundation for creating our own projects.

To get started quickly, you can run precompiled examples that showcase simple functionalities like blinking LEDs, as well as more complex applications that communicate with smartphones via BLE These examples eliminate the need for a full toolchain setup, allowing for rapid programming and testing that can be completed in just a few minutes.

Note: Running precompiled example will be discussed more specifically in Imple- mentationpart.

Other components

The SDK offers extensive support for various hardware drivers compatible with all nRF5 Kits, with a particular emphasis on the nRF52833 Driver For detailed information about each hardware driver component, please visit the following link: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/nrf52833_drivers.html.

The library contains all the necessary package code designed to assist developers in locating the relevant modules tailored to their specific needs For detailed descriptions of each package, please refer to the following link: [Nordic Semiconductor Libraries](https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/general_libraries.html).

The article provides a comprehensive collection of examples for nRF5 Series devices, including an overview and compatibility details for each device For further information, please refer to the official documentation available at [Nordic Semiconductor](https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/examples.html).

Nordic nRF Toolbox app

The Nordic nRF Toolbox is a versatile application developed by Nordic Semiconductor for both Android and iOS platforms, designed to facilitate communication with NRF boards that contain essential information like UUIDs for establishing Bluetooth connections Among its various profiles, including Running Speed and Cadence, Heart Rate, and Blood Pressure, this project specifically focuses on customizing the UART Transmitter function to better align with our project's requirements using Android Studio.

Figure 17: Toolbox Application for Android and iOS platform

The nRF Toolbox is compatible with three major platforms: Windows Phone v8.1 or later, Android v4.3 or later, and iOS v8 or later This proposal focuses solely on the Android platform, as our connection to the nRF52833 is exclusively through devices running the Android operating system.

We can easily download the nRF Toolbox on mobile phone And when we operate the app, we can see the platform of app similar to figure below.

Figure 18: nRF Toolbox platform on mobile phone

Android Studio

Android Studio serves as the official integrated development environment (IDE) for developing Android applications Built on the IntelliJ IDEA platform, it offers robust code editing features and a suite of developer tools tailored for software development.

Android Studio, the official integrated development environment (IDE) for Android, offers advanced tools for app development, debugging, and packaging This platform is essential for developers looking to create high-quality applications efficiently.

A source code editor provides advanced features such as code completion, refactoring, and analysis, essential for Android app development The Android build system includes tools for building, testing, running, and packaging apps, featuring project wizards, GitHub integration, and multi-screen app development support It also offers a virtual device manager for various Android devices and the ability to create multiple APKs with different features from a single project using Gradle An APK, or Android application package, is the file format used to distribute and install applications on Google's Android OS.

The Android Debug Monitor serves as a debugger to test and debug target programs, which are typically developed in a mobile development environment using the Java programming language Android Studio is the ideal platform for this process, as it seamlessly integrates essential tools for application development However, developers have various alternatives to Google's tools for Android app development, including different IDEs and programming languages.

– For developing websites directly on an Android device, using HTML/ CSS/ JavaScript languages, it is suitable to use the Android web editor AIDE Web (http://www.android-ide.com/)

– For developing real Android apps directly on the Android device, using C/ C++/ Java languages, use AIDE (http://www.android-ide.com/)

– For easy development of mobile and desktop applications with the web based http://www.applicationcraft.com under the HTML5 language, use the drag-and-drop IDE Application Craft

– For quick development of any type of Android apps in modern version of Visual Basic, use Basic4Android (http://www.b4x.com/b4a.html)

– For a complete solution for developing connected apps for Android (or Win- dows, iOS) from a single codebase in ObjectPascal/C++ languages, use RADStudio XE (http://www.embarcadero.com/)

Hterm and Arduino serial monitor

Hterm

HTerm is a terminal emulation program for serial communication running on Win- dows and Linux Hterm has some features:[13]

• Supports all available hardware and virtual USB serial rs232 ports

• Supports all baud rates provided by the port

• Input and output in ASCII, hexadecimal, binary and decimal

• Sending and receiving of files

• Customization via XML configuration file

Arduino serial monitor

The Serial Monitor is an essential feature of the Arduino IDE that facilitates data transmission between motherboards and computers through USB communication Functioning as a distinct pop-up window, it serves as an independent terminal, offering functionalities comparable to other terminal applications like Hterm.

In this section, we will talk about the Aquaponic system, why we chose this system to implement as long as system requirement, design step and idea.

Introduction

As concerns about food safety and hygiene rise, many families are turning to closed Aquaponics systems to cultivate their own clean vegetables and fresh fish at home This innovative growing method, successfully adopted by numerous industrialized nations, offers a sustainable solution for self-supplying nutritious ingredients for daily meals.

The Aquaponics model integrates aquaculture and hydroponics, creating a sustainable ecosystem where plants purify water for fish, while fish waste serves as a nutrient-rich organic fertilizer for healthy plant growth.

The innovative integration of aquaculture and hydroponics offers unparalleled advantages in farming, allowing for soil-free plant cultivation without the need for fertilizers or additional nutrients This sustainable model relies on the beneficial microbiome from fish waste to nurture the plants, enabling growers to simply sow seeds and await a bountiful harvest Unlike traditional fish farming, which requires draining and cleaning water, this system utilizes plants to purify the water, promoting optimal growth conditions for fish.

System feature base on aquaponic model

This model is very suitable to apply bluetooth low energy connection, we add some functions to the system to make the system easier to use for users:

• The system will work automatically to reduce human effort.

• Can be controlled remotely (using Bluetooth connection) to make it easier for users to control the system.

Implementation idea and system feature

In order to fulfill the requirements set above, we decide to have some main parts:

The system requires multiple sensors to monitor water levels in the pot, including a moisture sensor for soil condition and a current sensor to check the water pump's functionality Additionally, relays are needed to manage external power, allowing control over the light and pump An Arduino UNO controller will process data from these sensors and operate the relays effectively.

• Because the system can be controlled remotely, so we usenRF52833 development kit(introduced above) to make communication between smartphone and our sys- tem.

• A PCB boardto integrate Arduino, nRF5, sensors and relay.

• An application on smartphone for user can connect to the system and control re- motely.

About functionality of the system, user can:

• Retrieve data from different sensor to know a status of aquaponic

• Turn on and off specific relay to control water pump

• System also support automation mode, ´ıt uses data from sensor to adjust water level.

In next chapter, we will go deeper about the way we implement the system Which is includingApplication programming, PCB design and layoutand Hardware pro- gramming.

Android Application

User guide

This project primarily focuses on the Aquaponic UI, although it includes a second UI as well Both user interfaces share identical core features, enabling effective connection and communication with the NRF board.

To connect to the board, simply tap the connecting button located in the top row of the home screen, specifically the third button from the left This button features a cloud symbol with the letter 'X'.

The Bluetooth device list displays all nearby available devices, providing essential details such as each device's name, address, and RSSI, which measures the strength of the signal received from an access point.

Figure 23: Basic UI Figure 24: Aquaponic UI

Choosing the right device you want to connect and if the connection is successful, the connect button will change to a cloud with a check symbols

While the pop-up window shows all available Bluetooth devices, users can only successfully connect to Nordic devices Other devices disconnect immediately after the connection attempt due to the mobile device's attempt to connect to the GATT server, which is exclusive to BLE devices Additionally, the application generates the RX.

TX service with specific UUID so only Nordic boards can connect to this application. After connecting successfully, the application now is ready to communicate with NRF board.

Once you successfully connect to the NRF board, all transmit buttons become enabled and ready for use, allowing for effective control of the system.

BLE Communication

When the RX, TX service are created, the first message confirm the successful con- nection will appear in the message log.

To facilitate data transmission to the system, we designed user-friendly buttons with ON and OFF tags, enabling users to effectively control the PCB board ports Each user interface features eight pairs of buttons dedicated to managing the various ports on the PCB, ensuring seamless operation in the Aquaponic system.

In the Aquaponic UI, users can connect two pump devices for plants and two for water tanks, while the remaining four ports can be utilized for additional devices like lights and oxygen generators Users need not be concerned about the order of ports on the PCB aligning with those in the app, as they can easily adjust the order in the Settings section of the UI.

The RX functionality currently supports four open ports on the PCB for data reception from sensors, which is displayed differently depending on the sensor type In the basic UI, all RX data appears in the message log, while the Aquaponic UI features four pumper icons corresponding to each sensor These icons illuminate when a positive current signal is detected on the respective port, remaining unlit for negative signals or if a different sensor is used Users can access the received signals by selecting the corresponding "Plant pot" or "Fish tank" linked to the appropriate ports, or by checking the message log through the message icon.

Printed Circuit Board Design

Hardware Components description

This switch power supply efficiently converts AC to DC while maintaining voltage stability, making it ideal for applications such as power adapters, LED light strips, LED displays, billboards, and industrial equipment Constructed from high-quality metal, it is durable and reliable, ensuring excellent performance for users Additionally, this switching power supply can be easily installed and manually operated for convenient on/off functionality.

• Input voltage: AC 110V to 240V 50/60Hz

• Protections: Overload/ Over voltage/ Short circuit

• LM2596 DC-DC step down power supply module

Figure 26: LM2586 DC-DC step down power supply module

The LM2596 adjustable DC-DC step-down module efficiently converts input voltages ranging from 3V to 30V into lower voltages between 1.5V and 30V It is designed to support a load of up to 3A while providing excellent line and load regulation.

• Multi-turn trimpot for adjustment of the output voltage

• Short circuit protection (current limiting)

• Hall effect current sensor ACS712 5A

Figure 27: ACS712 current sensor 5A module

The ACS712 Module, utilizing the renowned ACS712 IC, measures current through the Hall Effect principle It can accurately gauge both AC and DC currents in three ranges: ±5A, ±20A, and ±30A Selecting the appropriate range is crucial, as higher ranges can compromise accuracy The module outputs an analog voltage of 0-5V proportional to the current, making it simple to interface with various microcontrollers.

The ACS712 module features two green phoenix terminal connectors for wire connections and includes mounting screws for secure installation It has three pins: Vcc, which should be connected to +5V to power the module, and a ground pin that connects to the MCU's ground The analog voltage output from the ACS712 can be read using any analog pin on the microcontroller, enabling effective current sensing in your projects.

A relay is an electrically operated switch that utilizes an electromagnet to control its internal mechanical contacts When the relay coil is energized, it activates the switching mechanism, allowing power to flow in the circuit This enables a low current circuit to effectively manage one or more higher current circuits, offering significant advantages in electrical control systems.

• Thinner cables can be used to connect the control switch to the relay thereby saving weight, space and cost.

• Relays allow power to be routed to a device over the shortest distance, thereby reducing voltage loss.

• Heavy gauge cable only needs to be used to connect a power source (via the relay) to the device.

Basic relays are defined by their electrical ratings for both the coil and the internal switching contacts The coil voltage rating indicates the necessary voltage for proper operation, while the switching circuit has specific voltage and ampere ratings that must not be exceeded Double throw relays typically provide two sets of electrical specifications: one for the normally open terminal and another for the normally closed terminal.

In this thesis, we will utilize 24V 7A 5-pin relays, which feature two pins for coil control and three pins for switching power between two circuits These relays include both normally open and normally closed connection pins, allowing for efficient power management When the coil is activated, the power transitions from the normally closed pin to the normally open pin, facilitating seamless circuit operation.

When relays are switched off, they can generate significant voltage spikes due to the de-energizing of the coil To prevent these spikes from damaging sensitive components in the control circuit, resistors or diodes are often installed across the relay coil This protective measure highlights the importance of using relays to safeguard devices from potential electrical surges.

Figure 29: The 5-pin relay layout

An opto-coupler, also known as an opto-isolator, is a semiconductor device that facilitates the transmission of electrical signals between two isolated circuits It consists of two main components: a light emitter, typically a light-emitting diode (LED), and a light detector, which can be a photodiode, phototransistor, or photodarlington The light emitter converts the incoming electrical signal, whether AC or DC, into a light signal, while the light detector receives this light and transforms it back into an electrical signal Both components are housed within a compact black box equipped with pins for connectivity, ensuring efficient signal isolation and transmission.

A photosensor is an output circuit that detects light, producing either AC or DC output based on its configuration Initially, current flows to the opto-coupler, causing the LED to emit infrared light in proportion to the current When this light reaches the photosensor, it triggers a current, activating the device Conversely, if the current to the LED is interrupted, the infrared beam is halted, leading to the photosensor ceasing its conduction.

An opto-coupler is essential for eliminating electrical noise from signals while providing isolation between low-voltage devices and high-voltage circuits This device protects against disruptions caused by voltage surges, including those from radio frequency transmissions, lightning strikes, and power supply spikes Additionally, it enables the control of larger AC voltages using small digital signals.

A diode is a device which allows current flow through only one direction That is the current should always flow from the Anode to cathode The cathode terminal can

Resistors can be identified by a grey bar, as illustrated in the image above The 1N4007 diode has a maximum current capacity of 1A and can handle peak currents of up to 30A, making it suitable for circuits designed for less than 1A Additionally, its reverse current is a negligible 5µA, while the power dissipation rating is 3W.

This thesis examines the use of the 1N4007 diode as a fly-back diode, which is essential for mitigating fly-back voltage spikes that occur across inductive loads when their supply current is abruptly reduced or interrupted Fly-back diodes are commonly employed in circuits controlling inductive loads through switches, as well as in switching power supplies and inverters, to ensure circuit protection and reliability.

A resistor is a passive electrical component designed to create resistance in the flow of electric current, commonly found in electrical networks and electronic circuits Resistance is measured in ohms, where one ohm represents the resistance encountered when a current of one ampere flows through a resistor with a voltage drop of one volt across its terminals.

Resistors serve various functions, including limiting electric current, voltage division, heat generation, and controlling gain in circuits They are available in a vast range of resistance values, exceeding nine orders of magnitude, and can be utilized in applications from dissipating kinetic energy in trains to tiny components in electronics Numerous standards exist for measuring and quantifying resistor properties, as well as for defining physical sizes and resistance values The most recognized standard is the color code marking on axial leaded resistors, which indicates resistance value and tolerance through colored bands In this context, we focus on three specific resistor values: 220Ω, 1 kΩ, and 10 kΩ.

Hardware Design

In this section, we utilize Altium Designer software to create and illustrate the schematic diagram The initial step involves locating the appropriate library and selecting the suitable components for each hardware element within Altium, ensuring compatibility with all related hardware components.

When designing printed circuit boards (PCBs), selecting the appropriate electronic components is crucial, as using unsuitable ones can lead to significant challenges during implementation To facilitate a better understanding of Altium Designer, we will provide a comprehensive step-by-step guide on how to effectively work with this software.

To effectively design an aquaponic system, it is essential to compile a list of necessary electronic components This includes accessing the Altium library, which provides the required footprints for layout and symbols for component connections Below is our curated list of electronic components to be utilized in Altium Designer.

To begin, we will integrate the component library into Altium software and incorporate it into the schematic layout Next, we will establish connections between each component to form an integrated circuit To enhance clarity, we will simplify the schematic diagram by breaking it down into smaller, more manageable sections, as this approach is common in PCB design Our goal is to provide a clear and detailed explanation throughout the process.

Figure 37: The main schematic diagram of aquaponic system

The schematic diagram features an Arduino Uno connected to eight 24V relay circuits and four 3-pin female headers for sensor integration It operates on a 24V DC supply, facilitated by an LM2596 circuit and a power jack.

Figure 38: Schematic diagram of Power supply

The schematic diagram illustrates the connection of the DC-005 power supply, featuring two wires labeled 24V and -24V The 24V wire supplies DC power for components operating at 24V, while the -24V wire serves as a ground connection to stabilize the circuit The 24V wire is linked to port 4 of the DC-005, designated as the positive pole, whereas the -24V wire connects to port 3, identified as the negative pole Additionally, port 2 of the DC-005 is another negative pole that remains unused.

Figure 39: Schematic diagram of LM2596 module

For this project, we utilized the existing LM2596 module instead of creating a new design with additional components Our design features four ports, including two input ports connected to 24V and -24V wires The LM2596 outputs provide the necessary 5V DC power to operate the Arduino Uno and other electronic components that require a 5V DC supply.

Figure 40: Schematic diagram of sensors

To establish a connection between sensors and the mainboard, we utilize a 3-pin female header, which requires only three ports: VCC, GND, and an analog signal In this setup, port 1 is connected to the GND supply from the LM2596, port 3 is linked to the 5V supply from the LM2596, and port 2 is connected to the analog signal of the Arduino Uno, designated as sensor1.

Figure 41: Schematic diagram of Arduino Uno board

To integrate the Arduino Uno with various sensors and electronic components, we utilize two rows of female headers The Arduino Uno is capable of processing both analog and digital signals, along with providing special functions like 5V DC, 3.3V DC, and GND In this setup, we will specifically use 8 digital ports, ranging from D4 to D11, which will be directly connected to 8 relay circuits operating at 24V DC to monitor their digital values.

4 ports for analog signals from A0 to A3 These ports will be connected to any analog signals of sensors such as water level sensor, temperature and humidity sensor, etc.

Figure 42: Schematic diagram of 24V relay circuit

The schematic diagram illustrates the core of our system, featuring a 24V relay circuit comprised of two main components: the left side houses the opto-coupler circuit, while the right side contains the basic switch relay circuit This relay operates using an electromagnet that shifts a pair of movable contacts from an open to a closed position One significant advantage of the relay circuit is its ability to function with a relatively low power input for the relay coil, enabling it to control high-power devices such as motors, lamps, or AC circuits efficiently.

The NPN relay switch circuit, utilizing the 2SC1815 transistor, operates based on the input voltage level When the Base voltage at port 3 is zero or negative, the transistor enters a cut-off state, functioning as an open switch, which results in no current flowing through the Collector at port 2, thereby de-energizing the relay coil In this scenario, the absence of Base current prevents any current from reaching the relay coil Conversely, when a sufficient positive current is applied to the Base, it saturates the NPN transistor, allowing the current from the Base to Emitter at port 1 to control a larger current flowing from Collector to Emitter, thus energizing the relay coil.

To protect semiconductor transistors from damage, a freewheeling diode is connected across the relay coil This diode effectively clamps the reverse voltage to approximately 0.7V, dissipating stored energy and safeguarding the switching transistor from potential harm.

The PC817C opto-coupler is employed to connect to the basic switch circuit, consisting of an input side with an LED and an output side with a phototransistor When 5V is not applied, no current flows through the LED, resulting in no light on the phototransistor, which leads to virtually zero collector current and no voltage across output wire 3 Conversely, when 5V is applied to wire 1, current flows through the LED, illuminating the phototransistor and enabling it to conduct, thereby generating an output voltage across wire 3.

Opto-coupler’s output current is controlled by its input current, that a control circuit connected to its input can be electrically fully isolated from the output circuit, and that

Isolating opto-couplers are highly valued for their ability to maintain safety by allowing significant voltage differences, sometimes reaching hundreds of volts, between input and output circuits This unique characteristic is primarily due to the purely optical link that controls the output, ensuring effective isolation while preventing electrical interference.

Figure 43: The PCB layout of mainboard

Once we have the schematic diagram of the aquaponic system, we will proceed to create a PCB layout, following a structured design process This involves several key steps to ensure an effective and efficient layout that meets the system's requirements.

Implement the board

Figure 45: The bottom side and top side of printed PCB layout

To create a printed circuit board (PCB), we begin by printing both sides of the PCB layout, ensuring that the top layer is mirrored prior to printing Next, it is essential to compile a comprehensive list of all components, materials, and tools required for the PCB fabrication process.

• 2 30-pin female header for arduino Uno, LM2596, sensors.

• 2-layer copper board (in this project, with A4 size of board, we can divide it into 3 similar parts).

• Soldering Iron, hand drill, Iron.

And now, we will give you the instructions of making 2 layer board:

• Step 1: Put the bottom layer print on the copper board and ironing it.

• Step 2: After we have bottom layer on 1 side of copper board, we use hand drill to drill pad holes on the copper board and on the top layer print.

To ensure proper alignment, place the top layer print face down onto the copper board and secure the pad holes using LED pins Next, carefully iron the reverse side to transfer the design effectively.

• Step 4: Put the copper board which has 2 layer prints into the FeCl3 liquid to remove the redundant copper.

• Step 5: Use hand drill to drill all holes of the board.

• Step 6: Place the components and soldering them Notice that we should use smaller components first,

Programming micro-controller

Ngày đăng: 03/06/2022, 11:29

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w