Future Development Plans
Pinbox - A Locker-like device for secure package delivery
An ambitious goal is to create a locker-like device that users can use to deliver and receive packages securely. This device would be called Pinbox
.
Current progress
As of 25.July.2024. I have created a prototype device that is able to connect to the internet, scan a QR code, and send a POST
request to a server using the scanned QR code as a payload. The device is built using a Raspberry Pi Pico W
and a QR Code Scanner
that I found on Aliexpress. Based on the response from the server, the device will move a servo motor to simulate the opening of a locker.
I coded the Raspberry Pi Pico W in Python
using the MicroPython (opens in a new tab) firmware/library, and the server in Golang (opens in a new tab).
A code snippet that runs on the Raspberry Pi Pico W (this is a simplified version of the actual code):
import time
from machine import UART, Pin, PWM
from servo import set_angle
import env
import wifi
import ujson
import urequests
import storage
WIFI_SSID = env.WIFI_SSID
WIFI_PASSWORD = env.WIFI_PASSWORD
API_URL = env.API_URL
time.sleep(5)
wlan = wifi.Wifi(WIFI_SSID, WIFI_PASSWORD)
store = storage.Storage()
led = Pin("LED", Pin.OUT)
uart = UART(0, tx=Pin(12), rx=Pin(13), baudrate=9600, bits=8, parity=None, stop=1)
sg90 = PWM(Pin(15), freq=50)
# Check if the device is already paired, (it should have a token in the storage)
token = store.get("token")
if token is None:
print("Device is not paired")
else:
print("Device is already paired")
while True:
if uart.any():
raw_data = uart.read()
data = raw_data.decode("utf-8").strip()
print(f"Received:<{data}>")
if data == "ON":
led.on()
elif data == "OFF":
led.off()
elif data.startswith("PAIR"):
token = data.split(" ")[1]
store.set("token", token)
print("Paired successfully")
elif data.startswith("ANGLE"):
angle = int(data.split(" ")[1])
set_angle(sg90, angle)
elif data.startswith("API"):
snd_data = data.split(" ")[1]
payload = {"key": snd_data}
json_payload = ujson.dumps(payload)
try:
response = urequests.post(API_URL, data=json_payload, headers={'Content-Type': 'application/json'})
# Check the response status
if response.status_code == 200:
print('Data posted successfully:', response.text)
else:
print('Failed to post data, status code:', response.status_code)
except Exception as e:
print("Failed to post data:", e)
finally:
response.close()
else:
print("Invalid command")
Future plans
The main idea of the Pinbox is for it to be a device that users that receive or send lots of packages can purchase and install outside their homes or businessed, similar to a mailbox. The device would have a QR Code Scanner
and will be paired with a user's account.
When a courier arrives at the user's location, it will show a QR code present in the application to the Pinbox, which will scan the QR code and open the corresponding locker. The courier will then place the package inside the locker and close it. The user will then receive a notification that a package has been delivered and will be able to open the locker using the application.
Improved Order Recommendation System
The order recommendation system is a crucial part of the application, as it recommends orders that the couriers can accept and deliver.
At the moment, the order recommendation system works in the following way:
- The system fetches all the orders that are available for delivery.
- The system calculates the distance between the courier's location and the order's
pickup location
and filters out the orders that are too far away (more than 10 km). - The system responds with the orders that are within the courier's range.
- The client side displays the orders to the courier in a random order.
Possible improvements to the order recommendation system:
- Fetch from the database only orders within the courier's area this could be a geographical quadrant, a country, or a subdivision of a country.
- Implement a way for the courier to tell the system their preferred delivery area/route and only show orders within that area or around that route.
- Implement a way for the courier to tell the system their preferred delivery time and only show orders that can be delivered within that time frame.
Currency Conversion
The application currently only supports one currency, the American Dollar (USD)
. In the future, I plan to add support for multiple currencies, allowing users to pay for orders in their local currency.
Initially, I want to simply do the conversion on the client side using a currency conversion API. Later on, I plan to implement a more robust solution that involves storing in the database the actual currency of the order and do transactions directly in that currency.
Notification System
At the moment, a shortcoming of the application is the lack of a notification system. The application does not notify the user when an order is accepted, when an order is delivered, or when an order is canceled.
Also, using the chat feature is not very intuitive, as the user has to manually check the chat to see if there are any new messages.