Loss Prevention Device

A PocketBeagle device that alerts your phone through text when you go too far from it

Categories: Intermediate


For the past couple of years, my father has constantly come up with wild ideas for things that would make people’s lives easier. He has always suggested me to engineer one of them as a proof of concept. One that stuck out to me has been a device that would notify the user (through a text message) if they get separated from it for a certain distance. This has many different possible applications, the most prominent one being that the device can be attached to your child, and it would let you know if the child wanders off and you don’t notice. Another application could be attaching it to your wallet or anything you don’t want to lose.

The Parts

The device is centered around a BeagleBoard PocketBeagle computer. There are three main attachments. The first one is a WiFi module (I used an EdiMax N150). This allows the PocketBeagle to connect to the internet independently, which is necessary for the text message functionality of the device. The second is a GPS (I used a GT-U7), which locates the device when prompted, allowing the text to give the coordinates of where the phone and the device were separated. The third is a Bluetooth module (I used an HM-10), which can connect to the device, and once disconnected triggers the text function. The two modules both communicate using UART ports. Wiring for the entire device is very simple — each device connects to a specific PocketBeagle port.

The Hardware

The Code

The code that runs this project utilizes a simple loop. While the device is on, it will communicate with the Bluetooth module constantly. When the Bluetooth module is connected to your phone, it will return a blank string and the device will get ready for a disconnect. When the phone is disconnected, the Bluetooth module will start responding with a string and the text message functionality is triggered. Before the text is sent, the device is located using the GPS module. The location function uses the pynmea2 library to convert the data to the latitude and longitude that is sent in the text. There is potential for more data to be sent using this library, but I just stuck with those two things for now. The text functionality utilizes the Twilio Messaging API to send the data.

Below is a video of the working device:

How To Set Up/Use This Device

As mentioned before, the device is relatively simple to wire up. As shown in the Fritzing diagram below, the Bluetooth and GPS modules use standard UART wiring, and the USB connects to the USB ports on the PocketBeagle. The README file in the GitHub repository goes more in-depth on how to set the device up, but I’ll give a quick rundown here.

  • Make a Twilio account and put your account information and phone number in the
    code. The Twilio website has very good instructions for that.
  • Set up the WiFi module using connmanctl
  • Use configure_pins.sh to set up the UART pins
  • Install Adafruit BBIO UART, pynmea2, and Twilio to the PocketBeagle
  • Download the DSD Tech app on your phone to manage the connection to the HM-10
  • Run
    or have it run automatically on boot

The device should now text you your coordinates whenever you connect then disconnect from it.


Below are some notable things problems/solutions I ran into when working on this project

  • The GPS needs to be outside or near a window to connect to the satellites. The first time it is booted up, it needs to be able to find the satellites (this can take a while) and then it will find them faster in later uses. It doesn’t work unless it is close to my dorm room wall, and I was unable to get it to work at Rice for the first time (It only worked when my professor used it at his house and then gave it back to me)
  • The Bluetooth module only takes commands when your phone is not connected to it. That is why the code searches for a blank string for when it is connected. There is probably a way to improve upon this.
  • UART0 on the PocketBeagle can be challenging to work with. That is why I use UART2 and UART 4.
  • I do not know why but the WiFi adapter only works if I unplug it and plug it back in after the device is powered up

Future Work

This project can be improved in many ways. To start, the device would ideally be operable on its own. That means a battery to power it, and an internet connection that does not need WiFi. This could be done with some sort of cellular connection. Additionally, the text message could be customized further, with information like the time of the disconnect. More indicators of separation could also be added like a buzzer or lights. An automatic Bluetooth connection and indoor GPS connection would improve the project immensely. Lastly, a high fidelity prototype of this device would ideally be quite small.

Comments are not currently available for this post.