Welcome folks to yet another exciting AIoT project that I would like to share with you. I have designed a product to address the challenges faced by college students in coordinating package deliveries with busy schedules. In this instructional blog, I will guide you through the step-by-step implementation process of building an automated package collection box using image processing and an ESP32 microcontroller. This project aims to reduce student anxiety and streamline the delivery process for both students and delivery agents.
ProblemStreamlining Package Deliveries in Hostel Settings
College students, especially those pursuing STEM disciplines, lead busy lives filled with academic, sporting, and socio-cultural activities. Most students are rarely present in their hostels, making it challenging to coordinate with delivery agents for package deliveries. This problem is further compounded by the inability to answer calls during lectures or meetings, leading to missed deliveries and additional hassles of finding someone available at the hostel.
SolutionAutomated Package Collection Box
To address these challenges, I propose building an automated package collection box that utilizes image processing and a microcontroller to streamline the delivery process. This solution eliminates the need for students to be physically present during package deliveries while ensuring secure and convenient storage of parcels until they can be collected.
The BuildInside the collection box(this is just a prototype cardboard box for demonstration), the hardware components other than the Husky Lens AI camera are also kept. The setup is powered from a 5V 3000 mAh Li-ion powerbank that feeds power to the FireBeetle board. The IO shield on the board then distributes the power to the SG90 servo motor, the I2C LCD display and the Husky Lens.
The servo motor is attached to the lid of the box that opens when the servo motor shaft angle is 90 degrees. The LCD display is kept on top of the HuskyLens(not visible in the picture). Both the HuskyLens and the display communicate with the Firebeetle over I2C.
Connect the components according to the Fritzing schematic below. Note that the I2C LCD display is not shown in the demonstration image since it was kept behind the Huskylens for better visibility for the delivery person.
The initial implementation plan was as follows -
I am going to build a package collection box that senses when a delivery agent is in front of the box using image processing and opens the lid to receive the parcel. It also has a character LCD display to send any instructions to the delivery agent or pass on the delivery OTP. After the package is received, the lid closes automatically and is held in place using a suitable mechanism.
There is no existing solution which is cheap or practical enough to be installed in a hostel setting. Of course, there do exist automated locker systems but those are high investment options suitable for residential settings only.
The product is useful since it reduces the student`s anxiety regarding package deliveries. It is also useful for delivery agents who do not have to waste time calling busy students incessantly.
The character LCD display driven by the ESP32 would display a message "Please stand with your face in front of camera to deliver package". The first step is the waking up of the ESP32 microcontroller on the Firebeetle at the press of a Start button. The Husky Lens AI camera is used to capture pictures of the delivery agent in front of the box. Two courses are action are possible after this based on the user`s preferences.
In the first one, a database of delivery agents who regularly deliver packages to that hostel would be pre-loaded onto the Husky Lens. This would be done since the delivery agents for a particular service do not change very frequenctly for a particular service area. After the delivery agent`s face is recognised, the ESP32 would actuate the servo motor to receive the parcel.
In the second course, the picture of the delivery agent is captured and sent to the user using IFTTT multimedia message service. After viewing the image, the user can click on a button on the Arduino Cloud Dashboard to allow or disallow the opening of the box with a message as simple as "Open Box" and vice-versa.
If an OTP is required to complete the transaction, the user can enter it on the Arduino cloud dashboard to display it on the LCD display for the delivery agent.
After 30 seconds the lid would be closed and the cycle would have to be repeated for any more parcels. The details of the last delivery along with the status of the box would be displayed on the Arduino Cloud dashbaord that can be monitored form anywhere.What I eventually Built
Before I describe the build process, I would like to outline the step-by-step process that would help you understand how each of the functionalities desired was implemented.
Step 1: Gathering the Required Components To begin the implementation, gather the following components:
- ESP32 microcontroller (such as Firebeetle)
- Husky Lens AI camera
- Servo motor
- Character LCD display
- Start button
- Arduino Cloud Dashboard
Step 2: Designing the User Interface
- Connect the character LCD display to the ESP32 microcontroller.
- Implement the necessary code to display the message "Please stand with your face in front of the camera to deliver the package" on the LCD display.
Step 3: Waking Up the Microcontroller
- Connect the start button to the ESP32 microcontroller.
- Develop the code to wake up the microcontroller upon pressing the start button.
Step 4: Image Processing and Facial Recognition
- Configure the Husky Lens AI camera to capture pictures of the delivery agent standing in front of the box.
- Implement image processing algorithms to recognize the face of the delivery agent.
- If a pre-loaded database of delivery agents exists, compare the captured image with the database to verify the delivery agent's identity.
- If the delivery agent is recognized, proceed to the next step. Otherwise, proceed to the IFTTT multimedia message service option.
Step 5: Pre-loaded Database Option
- If the delivery agent's identity is confirmed, trigger the ESP32 microcontroller to actuate the servo motor and open the package collection box to receive the parcel.
Step 6: IFTTT Multimedia Message Service Option
- If the delivery agent is not recognized, capture the picture of the delivery agent and send it to the user via the IFTTT multimedia message service.
- Enable the user to view the image and click on a button on the Arduino Cloud Dashboard to allow or disallow the opening of the box.
- Based on the user's response, actuate the servo motor to open or keep the box closed.
Step 7: OTP and Parcel Completion
- If an OTP (One-Time Password) is required to complete the transaction, provide a feature on the Arduino Cloud Dashboard for the user to enter the OTP.
- Display the entered OTP on the character LCD display for the delivery agent's reference.
- Once the transaction is completed, close the lid of the package collection box using a suitable mechanism.
Step 8: Monitoring and Feedback
- Display the details of the last delivery and the box's status on the Arduino Cloud Dashboard.
- Monitor the system remotely from anywhere using the dashboard.
Start Button Initialization
- Define the pin number for the start button.
- Set the pin mode to INPUT_PULLUP to enable the internal pull-up resistor.
- Attach an interrupt to the start button pin, which will trigger the
startButtonInterrupt()
function when the button is pressed.
Servo Motor Initialization
- Include the
Servo
library. - Define the pin number for the servo motor.
- Declare a
Servo
object to control the servo motor. - Inside the
setup()
function, attach the servo motor to the specified pin using theattach()
function. - Set the initial position of the servo motor by calling the
write()
function and passing the desired angle (e.g., 0) as an argument.
LCD Display Initialization
- Include the
LiquidCrystal_I2C
library. - Define the I2C address of the LCD display.
- Create an instance of the
LiquidCrystal_I2C
class, providing the LCD address and the number of columns and rows. - Inside the
setup()
function, initialize the LCD display by calling theinit()
function. - Turn on the backlight of the LCD display by calling the
backlight()
function. - Set the cursor position using the
setCursor()
function.
Display Message on LCD(and create a function for further calls)
- Create a function named
displayMessageOnLCD()
that takes aString
argument for the message to be displayed. - Inside the function, clear the LCD display using the
clear()
function. - Print the message on the LCD display using the
print()
function.
Start Button Interrupt
- Create a function named
startButtonInterrupt()
that will be triggered when the start button is pressed. - Inside the function, set a boolean flag (
startButtonPressed
) to true, indicating that the button has been pressed.
Capture Delivery Agent Image
- Create a function named
captureDeliveryAgentImage()
to capture an image of the delivery agent using the Husky Lens AI camera. - Display a message on the LCD to indicate that the image capture is in progress.
- Use a while loop to wait until the camera responds with available data using the
HuskyLens.available()
function. - Read the recognized delivery agent from the camera using the
HuskyLens.read()
function. - Check if the delivery agent is recognized or unknown.
Process Recognized Delivery Agent
- Create a function named
processRecognizedDeliveryAgent()
that takes aHUSKYLensResult
argument for the recognized delivery agent. - If the ID of the recognized delivery agent face is "0", save the captured image on the microSD card and inform the user by SMS and on the Arduino Cloud IoT Dashboard by calling the
sendImageToUser()
function. - If the recognized delivery agent is known, actuate the servo motor to receive the parcel by calling the
actuateServoMotor()
function.
Actuate Servo Motor
- Create a function named
actuateServoMotor()
to actuate the servo motor and open the box. - Display a message on the LCD to indicate that the box is opening.
- Use the
servoMotor.write()
function to set the desired angle for the servo motor (e.g., 90) to open the box. - Delay for a certain period of time to keep the box open.
- After the delay, set the angle back to 0 using the
servoMotor.write()
function to close the box.
Send Image to User
- Create a function named
sendImageToUser()
that takes aString
argument for the image file path. - Use the IFTTT service or other suitable service to send the image to the user via SMS or multimedia message.
- Implement the necessary code or API calls to send the image to the user.
Handle User Response
- Create a function named
handleUserResponse()
that takes aString
argument for the user's response. - Extract the user's response from the received data.
- Check if the user's response is 'Y' (indicating approval) or any other character (indicating disapproval).
- Act accordingly based on the user's response by either displaying a message on the LCD or actuating the servo motor to close the
Integration with IFTTT SMS Service
- Implement the
sendSMSToUser()
function to send SMS messages to the user using the IFTTT SMS service. - Construct the appropriate URL with the event name and key for the IFTTT webhook.
- Use an HTTP POST request to send the SMS message to the IFTTT webhook URL with the message body as a parameter
To get an idea of how to go about implementing the IFTTT SMS service, take a look at this Hackster project.
https://www.hackster.io/Moinak/trukdoc-aiot-solution-for-in-transit-vehicle-monitoring-e9d8d9
Monitoring on the Arduino IoT CloudSign in to the Arduino Cloud website using your username and password and click on the Arduino IoT Cloud tab. https://cloud.arduino.cc/home/
On the Things tab, click on Create and you would be greeted by a screen similar to the one below.
Set the name of your 'thing' at the top.
Head over to the Devices tab and click on Create. The following screen appears. Enter the target device as Firebeetle ESP32.
Name the device suitably. I have named mine 'Delivery Bot'.
Check that your Device has been created or not.
Return to the Things tab with your thing(Mine is Parcel_Collection_Bot). Click on the Network tab to the right panel and then on the configure button. Enter your Wifi credentials as well as your device key which you obtained after creating your device.
Click on the Dashboards tab. Create a new Dashboard. Give it a nice name. Then click on Add to obtain a set of widgets that can be added to the dasboard.
My final dashboard looks as follows. There are three status indicator LEDs that display the status of three boolean variables in code. Green light signifies 'true' and red light denotes 'false'.
Apart from the status indicators, there is a switch attached to the variable 'user_servo_handle' that can be used by the student to remotely operate the servo motor and open the lid to accept a parcel in case the delivery guy is unrecognised.
Another very useful provision is a chat window that allows the student to send important messages to the delivery guy like the OTP for a particular delivery. The string input is attached to a variable 'lcd_prompt' that in turn is connected to a string buffer that is displayed on the LCD display.
This is how the dashboard looks on a mobile device(tested on Samsung Galaxy A31). Isn`t it cool?
Now with the dashboard setup, head over to the Things tab to connect variables in code with the status indicators and the inputs on the dashboard.
Use the Add Variable button to create and configure a new variable as shown.
At this point, head over to the Sketch tab inside the Things tab. You would be amazed to find that the web IDE automatically generates a starting point for your sketch with all callback functions and variable declarations done beforehand.
Before modifying the sketch, add all necessary libraries to the sketch by either uploading .zip files or including libraries from the Library Manager.
Modify the code to include all desired functionality.
Compile the sketch. Download the Arduino Create Agent desktop application to upload the sketch to the ESP32 board.
Once the code is running on the Firebeetle, play around with the switches and status indicators on the dashboard to test all functions. In the image below, I demonstrate how the Chat feature on the dashboard can be used to dispplay messages for the delivery guy on the LCD display fixed atop the box.
And, that`s all folks!!!!!!!
You have successfully completed the software development for the Parcel Collection Robot.
Finishing Thoughts and Future ProspectsBy implementing this automated package collection box, I have addressed the challenges faced by busy college students in coordinating package deliveries. The use of image processing, facial recognition, and a user-friendly interface ensures a streamlined and secure process for both students and delivery agents.
Not only does this solution reduce student anxiety regarding missed deliveries, but it also saves valuable time for delivery agents who no longer have to make incessant calls to coordinate deliveries. The ability to remotely control the box and view delivery agent images through the Arduino Cloud Dashboard adds convenience and flexibility to the system.
Remember, when building your own package collection box, ensure you have all the necessary components and follow the step-by-step implementation process outlined in this instructional blog. Feel free to adapt the design to meet your specific requirements and preferences.
With this automated package collection box, you can revolutionize the way packages are delivered and received in hostel settings, making the process efficient, secure, and hassle-free.
Happy building!
Comments