Gabriel J-C

My name is Gabriel J-C. I attended 9th grade this past school year (2016 to 2017) at The High School for Math, Science, and Engineering at CCNY. I chose to build a Bluetooth beacon for my main project because I wanted to learn more about low-level networking and how it works from the standpoint of electrical engineering (e.g. the way Bluetooth transmitters pack data onto radio waves). I decided on the TV-B-Gone for my starter project because it is a relatively simple tool with significant utility.

I came to BlueStamp because I like engineering and was looking for a project-based program. I’ve had a great experience here. In the end, BlueStamp has taught me that tasks in a project that may seem simple at the outset often end up causing the most trouble. I experienced this when struggling to get the physical PiBeacon device and its corresponding app to “talk” to each other.

Engineer

Gabriel J-C

Area of Interest

Software Engineering

School

The High School for Math, Science, and Engineering at CCNY

Grade

Incoming Sophomore

Final Project

The physical beacon device is a Raspberry Pi Zero W, which has integrated Wi-Fi and Bluetooth radios. I wrote a Python script to automatically set the packet data to be transmitted over Bluetooth LE. That same script also binds a custom HTTP server to port 80 on all of the Pi’s network interfaces. It sets up four HTTP routes: “/enable”, “/disable”, “/status”, and “/update”.

The “/enable” and “/disable” routes enable and disable, respectively, the Pi’s Bluetooth radio when supplied an HTTP GET or HTTP POST request. The “/status” route accepts an HTTP GET request and returns the text “Enabled” or “Disabled” depending on status of the Pi’s Bluetooth radio. The “/update” route accepts an HTTP GET request with the Major and Minor values in the query string. Those values are included in Bluetooth payload and are used to differentiate between different beacons transmitting in the same place, at the same time.

I added a way to visualize the signal strength of the beacon in augmented reality to the iOS app. This functionality is implemented using Apple’s ARKit framework for iOS. Once the user taps the beacon in the camera view, the operating system’s machine vision tracks it and other anchors in said camera view as the iOS device is moved. The app constantly gathers the varying signal strengths of the beacon at different points in space, compiling them into the circular visualization.

I devised an algorithm for translating the signal strength data into real-world space. When a significant change in the RSSI, a measure of signal strength, occurs, the circle extends to the physical location of the phone when said RSSI change was detected. This way, as new data points are collected, the visualization continuously improves in accuracy.

The main GitHub repository for the PiBeacon project can be found at https://github.com/Gerzer/PiBeacon. The GitHub repository for the iOS client app can be found at https://github.com/Gerzer/PiBeacon-Client—mobile-edition. The Bill of Materials (BOM) can be found at https://github.com/Gerzer/PiBeacon#components. The BOM as an Excel file can be found at bluestamp-bill-of-materials-bom.

Second Milestone

I wrote an HTTP server in Python on the Raspberry Pi that would turn on or off the Bluetooth radio when it received different HTTP requests. I built an iOS app in Swift to provide a graphical user interface for sending such requests to the beacon. Each beacon displayed in the iOS app has a cell in a Cocoa collection view, with its user-defined name, a switch for enabling or disabling its Bluetooth radio, and an “info” button for more actions. Those additional actions include removing it from the app, changing its user-defined name, configuring arbitrary HTTP requests to be made upon entering or exiting its signal range, and measuring its signal strength in augmented reality. A button at the bottom of the screen lets the user add a new beacon to the app by entering its local LAN hostname or private IP address and a custom name for the user’s convenience. The hardest part was programming the app to retain information about the user’s beacons even when they quit the app and relaunch it later. I ended up using Apple’s “user defaults” local key-value storage service.

First Milestone

It was hard to get the serial console on the Raspberry Pi to work. After finally logging in to the serial console from my laptop, I wrote a Python script to automatically configure the Bluetooth radio to continuously transmit iBeacon-formatted packets at each boot. The packets all contain the same, unique identifier so that nearby devices can detect that they are within range of the particular beacon.

Starter Project

The TV-B-Gone is somewhat of a universal, wireless off switch for most popular television models. It flashes four infrared (IR) light emitting diodes (LEDs) to “tell” a nearby TV to turn off, similar to what the off button on a standard TV remote does. (IR LEDs emit light with wavelengths outside the spectrum visible to the human eye.) Unfortunately, different TV brands use different IR flash sequences to signal to their respective TV models to turn off, meaning a standard remote can work with only one brand of TV at a time. The TV-B-Gone, however, is programmed with a long list of different flash sequences for different TV brands through which it cycles to maximize the chance that it will successfully turn off any given TV.

Leave a Comment

Start typing and press Enter to search