There were a series of challenges we encountered during this project. Here we highlight a few of the most difficult aspects of our project:
One of the most difficult tasks was finding a way to adequately control the 31 LEDs that our miniature map system needed. This was because while technically there are enough GPIO pins on the ESP to control 31 LEDs, most of them are used by the board during runtime for various tasks. For instance, pin 6 was used as a clock for the microcontroller, so if we attempted to toggle it the whole board would go awry. During the testing process, we found that we could only really use 21 pins, this meant that we could only connect 16 pins directly to the LED, but the remaining 5 pins went to constructing a Charlieplexing circuit that could technically control 20 LEDs but we only needed it to control the remaining 15 LEDs.
One of the challenges with Charlieplexing is that it requires an enormous amount of wiring as well as documentation of the pin positions/mapping to the Lamp IDs, so that one can easily code it once the wiring is complete. Luckily there were a reasonable amount of resources available online that helped us go through the process step-by-step.
Once the wiring was completed, however, another challenge presented itself because due to the nature of the charlieplexed circuit - only one LED in the matrix was able to turn on at the same time. To go around this we used the concept of duty cycle from 6.08 in order to cycle through all of the LEDs that needed to be turned on. Because the speed of the cycling was so fast we were able to make it seem as though the LEDs were continuously on. We also made sure that the code had little opportunity to block the cycling of the LEDs, by cycling them through any loops that were present and by using state machines to minimize non-blocking code.
One difficult challenge was getting the Google Distance Matrix API to work when requesting multiple locations in one request. The Google Distance Matrix API was designed to find routes to and from every point imputed, so it was not possible to only get paths between specific start and end locations if there were multiple locations in the request.
For example, if I wanted to find the travel time from A → B and from C → D I would make a request with
origins = [A,C] and
destinations = [B,D]. However, rather than return the two paths I wanted, the API would return durations A → B, A → D, C → D, and A → D. As you can imagine, with a larger number of origins and destinations, there are a many unnecessary duration values returned. Furthermore, parsing through this data to try to find select routes can be quite difficult depending on how many origins and destinations in a request, and how you order these locations. Thus, instead we performed many individual requests, which simplified parsing the data and ensured that the API didn’t do extra work of getting travel durations between points that we would never need.
Due to the sheer number of requests, initializing the adjacency matrix takes about 8 seconds on average. However, in the grand scheme of things, it would take more than 8 seconds for responders to get in their vehicles, thus even though this code may be slow by our standards, the route would still be perfectly lit by the time the responders departed their station.
One challenge with LIFX API is that it cannot connect to public Wifi Networks in order to ensure a secure and reliable network connection. When we first encountered this problem we first assumed that the Bulb was broken for a couple days because it couldn’t connect to the internet in order to be used by the API. This problem was solved, however, by testing our bulb to different networks and eventually connecting the Bulb to one of our group members personal hotspots seemed to work. In the future we would want to ensure that each bulb has the capability to have either its own secure wireless connection, to prevent tampering by outside parties, or have some type of internet cable that can run up the lamp post to transfer information from the internet.