Inspiration

Everyone has experienced climate change, but those in cities have been affected the most. Being from Nashville, Tennessee, I've definitely experienced the way cities can trap heat and worsen already unpleasant conditions. Climate change used to be something in the back of my mind, but experiencing summer after summer of temperatures regularly hitting 3 digits and realizing I couldn't do the things I did outside just 10 years ago without risking heat-related illness (which I was afflicted with several times) made me understand how serious of an issue it is. Unfortunately, climate change isn't the type of thing that can be solved by one person; we all have to do our part.

There are many contributing factors to climate change, but transportation plays a very large role. As of 2022, transportation is responsible for 28% of greenhouse gas emissions in the US, with 80% of that being from personal vehicles. Thankfully, vehicles are one of the few contributing factors of climate change that is controllable by your average citizen. As more people become aware of the effects vehicles have on the environment, more cities are being designed with alternative, eco-friendly methods of transportation in mind.

However, most Americans have no idea how much time they spend on the road, let alone how much CO2 they emit when driving. Good thing we all carry a device fully capable of analyzing our driving habits in our pockets every day -- the cellphone.

What it does

Carbon Tracker does basically what it says on the tin: it tracks your carbon emissions. Specifically, it tracks your carbon emissions from driving. It then reports statistics back to the user regarding how much CO2 they are emitting from driving, giving them the opportunity to make educated decisions when they decide how they will go to work that morning and every other morning.

Because I value privacy myself very highly and I strongly oppose applications violating user privacy, I intentionally made Carbon Tracker do everything on the user's phone. It doesn't store actual location data -- it only handles the coordinates briefly to determine distance before dropping them -- but the few values it does store never leave the user's phone. It will stay open-source forever, so users can know their data isn't being sent somewhere they don't agree with.

How we built it

Carbon Tracker uses the Android Activity Recognition (determines actions such as sitting, walking, driving, etc.) API and location services. It polls the users activity, and if the API returns that the user is driving with adequate confidence, the app will start polling location in a regular interval. It determines the distance the user traveled by summing the distance between every adjacent pair of coordinate points, and logs that as a drive. The date, duration, and distance of a drive, the only things logged persistently, allow for a variety of calculations.

For actually calculating the carbon emissions, I used a dataset of CO2 emissions by vehicle. The user can select which car they own out of a large variety, and the CO2 emissions (in grams) are then calculated simply by multiplying the reported CO2 emissions by the kilometers traveled.

The drives are stored across restarts using Android Room, and the user's selection of car is stored using the SharedPreferences class. The currently implemented statistics are calculated when the user launches the app, but I will most likely choose to cache more computationally intensive statistics should they be implemented.

I chose to stick with the native Android SDK, since the UI is fairly simple and I didn't want to over-complicate things given the time limit. However, I may migrate to Ionic in order to make the application cross-platform in the future.

Challenges I ran into

The first major challenge I ran into was that this is my first time making a mobile app, and I chose to work individually, so I had to basically teach myself mobile app development as fast as possible. This wasn't an easy task, and I lost a considerable amount of time just trying to get up and running, but I got the hang of it eventually.

The second major challenge was testing. Being able to detect the user driving is a central part of Carbon Tracker, but I have neither a vehicle nor a driver's license. I had to adapt by temporarily modifying the code to consider walking to be driving, and I tested it by walking laps around the DCC. However, this still proved challenging when I wasn't walking anywhere near a kilometer and had difficulty determining if anything was being detected. The solution to this was just to walk for a longer time, and later implementing a function to generate random drives for testing calculations.

I faced several minor challenges that were mostly related to me not having a second pair of eyes to look over the code. For example, I spent a good while debugging why distance and CO2 emissions were the same value, just to find I had forgotten to change a variable when I copied the code that displays the distance. The frequency of these small mistakes increased throughout the night, unsurprisingly.

Another minor challenge I faced was the hardware limitations of my laptop. My CPU temperature stagnated at 95c for about 10 minutes while I was first trying to get Android Studio working, and it was slow to the point where I was completely unable to use Firefox at the same time. I also experienced a lot of frustrating computer crashes, and I was completely unable to emulate a phone for testing.

Accomplishments that I'm proud of

I'm proud to have created a functional mobile app independently in 24 hours. I was worried I was going to have to throw in the towel and go back to my dorm, but I got it done, even with a late start. I do have experience programming, but I have always focused on communicating with other computers, not the user. That is to say, I don't have experience with UI development outside of very rudimentary projects. I have wanted to learn UI development, but I didn't really have a compelling reason to until now. I'm glad I decided to leave my comfort zone.

I'm also just proud of myself for doing this competition. I'm very introverted, so being around lots of other people for 24 hours straight is exhausting for more reasons than the lack of sleep. I'm glad I did; it was very rewarding, if tiring.

What I learned

I learned a lot. Android app development is the obvious answer; I walked in DCC yesterday morning without even having Android Studio installed, let alone having used it. Now I can say I made an app that actually does something, and I'll be able to bring to fruition the various other ideas I've had for mobile apps that never got past the planning stage.

I also learned a lot about pacing myself. I tried to rush through it because of the time restraints, but I ended up losing time tracking down the small mistakes I glossed over because I didn't fully read over my code.

On the flip-side, I had to learn to accept imperfect code. Usually, my process is highly developing smaller parts of the project one piece at a time, and perfecting and optimizing them before I even have the whole thing finished. This is useful if you're forgetful, but a very large hindrance if you're just trying to make a demo in 24 hours.

What's next for Carbon Tracker

There are a lot of ideas I had that I wasn't able to implement. For example, something I originally thought of as a core feature that I had to accept wouldn't be done today was a scrolling graph showing the user's carbon emissions over time so they could see trends and get the satisfaction of seeing it decrease. Unfortunately, the Android SDK does not provide anything even really close to this out-of-the-box, and third-party libraries were limited.

I would also like to add a much larger variety of statistics for users to examine, including predictions for future trends. Following that, I would like to greatly expand the user preferences, allowing them to enable or disable different statistics, change the color scheme, or change units, to name a few uses. Another useful feature would be to simulate different scenarios -- "if I only drive 5km to the park-and-ride every day instead of driving all the way to work, how will that effect my carbon emissions?" for example. This would significantly increase Carbon Tracker's utility as a tool aiding in making environmentally friendly submissions.

Share this project:

Updates