Introduction: SafeDrop: a Smart Package Delivery Safe

In this instructable I’m going to show you how my team made SafeDrop, a modern IoT-connected device prototype that protects your delivery packages from theft! We came up with this idea at the AT&T Developer Summit Hackathon, and coded and constructed it in little more than 24 hours. Our design netted us a second place win in the Intel Edison Sponsor Challenge! I hope you enjoy.

In the holiday season, thieves are on the lookout for Amazon gifts left on your doorstep. Safedrop is a secure safe which sits in front of your house, and can only be opened if the correct package’s barcode is scanned through.

Users operate the safe through a companion mobile app. They enter a package’s confirmation code into this app, which will register this package’s barcode into the database of functional keys. When the deliveryman comes, they scan the package with the box, which only opens if the box is recognized.

Our build consisted of four major parts:

1. The Box, controlled by the Intel Edison board

2. The Scanner, running on an Android phone, with code written in Cordova through the Intel Edison XDK

3. The Companion App, running on a second Android phone, with code written in native Android

4. The Cloud, which coordinates all the parts together

To build this contraption, we used:

1 Cardboard Box

2 Android Phones

1 Intel Edison Board

1 Grove Board

1 LED

1 Buzzer

1 Servo

1 Photoreceptor

1 USB Webcam

Intel Edison XDK IoT Edition (Board and Scanner app)

Android Studio (Companion app)

Box Cutter

Lots of tape (or whatever else you want to use to keep everything together)

Step 1: Preparing the Board

The board has a couple different modules, that are coded to activate in different situations.

A servo acts as the lock. If it is parallel to the edge of the box, it is unlocked. It turns 90 degrees into the locked position if it is notified to do so.

The LED turns on and buzzer buzzes on when the box is unlocked.

The webcam uses the photoreceptor data to turn on and off.

The Intel Edison XDK runs in modified Javascript, so it can be unfamiliar for people who are used to programming for Arduino. You can look through the code we wrote, to get the gist of how the programming language works.

One major challenge for this part was making the USB webcam work. We wanted it to record for the 10-second interval that the box was open, then post that video in the cloud to be accessed. We found that live-streaming the video is simple enough, but actually saving the video clip for replaying was frustratingly difficult. We ended up putting in some code to convert it from one filetype to another, where it is able to be saved correctly.

Included in the code is the cloud functionality. There is a local server set up in node.js that the webcam uses to post the most recent video recording. The mobile app accesses this endpoint to see the video.

The code we used is here.

Step 2: The Scanner App

We wrote the scanner's app using the Intel Edison XDK, which features example applications pre-written in Cordova. Cordova is a platform which translates languages typically used in web development (HTML, CSS, Javascript) into native mobile apps. One of the example applications included in the development kit is a Barcode Scanning app, so we used that as our base app and put edits on it to make sure everything worked in our system.

Our code's edits feature a nice big "Scan" button, and we use the front camera instead of the back camera to do the actual picture-taking. This process was actually quite time-consuming, and required us to delete the pre-compiled .jar file that came with the project, and recompile it in with the camera change, in order for the app to recognize it.

After the app scans the barcode, it sends out an HTTP POST request to a verification endpoint. The verification endpoint keeps track of a database of expected keys. If that barcode key belongs to a package that you're expecting, it sends back a success JSON. Otherwise, it sends back an error.

If we parse the verification as a success, then we send out another HTTP POST request to a different endpoint in the local network -- the box listens to this endpoint, and it will open if it receives a positive. After 10 seconds, the scanner app sends out a close request to the same endpoint, which commands the box to close.

If an error occurs in any of this pipeline, then the scanner app displays that there is an Error and does not open the box.

The code we used is here.

Step 3: The Companion App

The companion app is written in native Android code, and we used Android Studio as the IDE. The UI is pretty simple:

In our mockup app, the user begins in a login screen. As of now, we haven't implemented an actual login algorithm, so just click Login to get through.

The list of expected packages is shown on the main dashboard. Our app displays a green check next to deliveries that have arrived. Selecting these deliveries lets the user see the details of the said delivery, as well as watch a video of the delivery person putting the package in the box. the video is accessed through a local webpage that the Intel Edison Board posts to.

The code can be found here.

Step 4: Assembling the Box

Once everything is coded and wired, the assembly is not too difficult. We used a spare packaging box that was lying around as the body of the safe. It opens at the top.

To form the locking mechanism, we took off the handle that was originally on the very top of the box and attached it on the lip. This forms a little pocket. We then attached the servo to the opposite lip of the machine, so that when the servo is in the "locked" position, it inserts itself into the pocked. When it's in "unlocked" position, it takes itself out.

We put the webcam and the light detector together at the back of the box. This gives the largest vantage point, so the webcam can see the most of the process of putting the package in.

The LED and the buzzer are by the front edge of the box, to notify the user that the box is open.

We used a box cutter to cut the necessary holes on the front of the box, one big hole for the phone screen and a small portal for the scanning camera to see.

We used tape to adhere everything together, because it was a hackathon and we were pressed for time. If you guys have more time, feel free to use something more clean or permanent :).

Step 5: Final Instructions

Now, all you need to do is plug in your Intel Edison Board and load up the scanner app and companion app. You can copy down the tracking codes you see on barcodes you have lying around (the app recognizes all major types, including QR code!) into the companion app to register it into the system. When you scan it through the scanner, it should work!

That's it! Have fun with your prototype SafeDrop!