Inspiration

Charles Dickens once said: "Champagne is one of the elegant extras in life.", and Frank Sinatra also shared his words of wisdom: "Alcohol may be man's worst enemy, but the bible says love your enemy."

Clearly, these alcoholic drinks holds some sort of magical attraction over their non-alcoholic beverage counterparts. Sometimes the only thing you would want to do after a long day of work is to crack open a cold one with the homies.

What it does

Compass actively observes your location and rotates its needle to point you in direction to nearest desired location. In this case, the nearest bar.

How we built it

We have ESP32 controlling a BNO055, Adafruit ultimate GPS, and a motor. The ESP32 reads acceleration and gyroscopic data from the BNO055, which an onboard fusion algorithm simplifies the calculation of direction (e.g. north, southwest, northwest) and heading (degree in direction). It also takes the latitude and longitude from the GPS module by parsing NMEA bytes from satellites. The data from IMU and GPS are collected as current location \((x_1, y_1)\), target location \((x_2, y_2)\), converted to radians. Relative angle is calculated as target angle minus current heading. And we use spherical trigonometry to find theta: $$ \theta = \text{arctan2}(\sin(\Delta y)\cos(x_2), \cos(x_1)) $$ Theta is then converted back to degrees and relative angle normalized between -180 and 180. Then, the normalized degrees are used to drive the motor towards the target location.

Hardware are connected via their GPIO pins and communicate via I2C or UART. We created a ground and voltage breakout to overcome the limited pins of the ESP32. The system is powered with triple A batteries.

Challenges we ran into

  • Limited RAM on ESP32 means no complex web requests over Wi-Fi, unable to complete Google TLS verification
  • Limited GPS module capabilities while indoor
  • Lack of precision from GPS and IMU unit, because bearing calculation error significantly increases as target latitude and longitude increases from current position
  • Using spherical trigonometry to calculate offset angle to target location was very math-heavy and required lots of brainpower
  • Soldering the pieces together and manage the physical wiring inside the compass container, which took hours to make since power tools were off-limits

Accomplishments that we're proud of

We are proud that we are able to get this navigation system working, perpetually pointed towards a desired location and it can consistently tell us how to get there. We had originally intended to use Wi-Fi signaling to estimate latitude and longitude, but due to its limited compute, we had to figure out another way to get those coordinates. We integrated the GPS module into our system, with dedicated software and wiring, and it was tested to work. The team's response and adaptability to problems is definitely something we are proud of.

In addition, none of the members have had much experience tinkering with physical hardware, so being able to transform what could have been a software application into a nuanced physical application backed by tested software in such a short period of time also meant a lot to us.

Finally, we are also proud that this application has great expandability beyond this humorous application. For instance, it can be programmed to point towards the nearest ER in case of serious emergency, or it could be programmed to point towards camp sites for hiking.

And this project has really good documentation.

What we learned

We learned how software translates to working on the hardware. Each programmed pin holds responsibility in completing our application, for instance, controlling the motor movement via signaling and PWM, and seeing what we learned in computer system class takes a more familiar form was enriching.

We also learned how to work with a resource constrained system considering the ESP32 is a compute-limited device, we optimized for latency and efficiency by minimizing the core logic and reducing redundancy as much as possible. The system is also battery-powered, which taught us how to work with undervolted system, or how to supply more power to the system without breaking the circuit.

Software-wise, we learned how to work with Google's geolocation and map API to get the appropriate latitude and longitude of bars, processing them through spherical trigonometry with data from IMU and GPS to calculate the degree needed to turn in order to face the closest bar.

What's next for Compass

The physical wiring could be optimized if we learn how to design our custom PCB. We would also need an alternate solution for janky GPS connection indoors, especially when locating via Wi-Fi signaling is impossible on ESP32. Making the contraption smaller and more pocket-sized is the next important step. The software functions as intended, but refactoring could be useful in increasing its neatness.

Built With

Share this project:

Updates