## 3 Materials and Methods
### PET Identification Confidence Index and PBIA
#### 3.2.2 The PBIA in the AIoT Context  
The PBIA is implemented using Bash scripts, with each functionality managed by a separate script. All tasks related to sensor operations have been implemented in Python and subsequently integrated into the main Bash script. Directly reading from a sensor using only Bash is challenging because Bash lacks direct support for GPIO pin manipulation and precise timing, which is necessary to communicate with the sensor. This hybrid approach takes advantage of the strengths of both languages: Bash for its powerful automation capabilities and Python for its precise control over hardware interactions, particularly those involving sensors. This modular design approach divides the application into distinct modules, each with its own task, as follows:  
* The module for the PIR sensor (named _pir.py_) uses the Asus.GPIO library dedicated to all GPIO interactions;
* The module for the LED (_LED.py_) uses the Asus.GPIO library as well, to manage the LED signaling functionality;
* The module for authentication (_auth.sh_) relies on cURL and OpenSSL libraries for handling secure HyperText Transfer Protocol (HTTP) requests and encryption. We use cURL to send Azure SQL Server requests in Bash, programmatically;
* The module for the scale (_scale.py_) utilizes the HX711 py library for reading the data from the load cell, which measures the weight;
* The module for handling Azure requests (_azure.sh_) uses cURL to send HTTP requests directly to the Azure Custom Vision service;
* The module for the motor (_motor.py_) also employs the Asus.GPIO library for managing motor control operations;
* The module for the Azure SQL Server database interaction (_database.sh_) requires an SQLcmd tool to interact with and manage database queries and data retrieval from the Azure SQL Server;
* The main module integrates the PBIA and engages the previous modules as needed. By organizing the application into modules, maintenance becomes more straightforward. Each module can be individually updated, debugged, or improved without affecting others, simplifying troubleshooting and supporting continuous development. This separation of concerns makes pinpointing issues in specific system areas easier, leading to quicker debugging and updates. The PBIA was integrated using Bash scripting in order to benefit from the following advantages:  
* Direct access to system resources, because Bash scripts can directly interact with the operating system and hardware, enabling low-level control over the sensors and actuators;
* It is well-suited for automating tasks, such as scheduling Azure requests or handling database updates, ensuring the system operates smoothly;
* Efficiency in resource management, because Bash scripts are lightweight and do not consume extensive system resources. This is advantageous in an IoT environment where resources are limited;
* Bash scripts are highly portable and compatible across various Linux-based systems, providing flexibility should the PRS be deployed on different hardware or in other AIoT environments. Figure 5 presents a screenshot of the detection process for a non-PET object, illustrating the steps involved in capturing a frame from the camera and sending it to the Azure Custom Vision service for analysis. This visual representation highlights the system's ability to differentiate between various object categories during the identification process. After recycling PET bottles, users will receive a reward through an application developed in C# that is compatible with any device. The application employs the ACTLR and is responsible for implementing the user management protocol to encourage PET recycling. This application features a user-friendly graphical interface that includes elements such as the client's QR code, the accumulated points, and the number of recycled PET items,with each bottle recycled being attributed to one point. Additionally, the application tracks alerts, which represent penalties incurred from attempts to introduce non-PET items into the PRS.