Awareness and mindfulness is necessary to make real change, Carbon-less aims to be a part of that by providing real-time emissions tracking in order to more accurately calculate fuel-efficiency and therefore arrive at a more precise calculations of emissions.

The youtube link for this demo will be on the Github repository attached to this post! (https://github.com/MuseGIM/carbon-less)

Using react-native, we worked on getting live updates from the phone's GPS services to calculate real-time carbon emissions and other statistics in order to have accurate calculations. The significant challenges we overcame involved working with constant streams of geolocations (and the calculations that came along with that) as well as robust app development with asynchronous data. The chief concern in our mind and confirmed by https://fueleconomy.gov/feg/driveHabits.jsp, was that fuel efficiency changes at different speeds, as seen below:

fuelgraph

Goal:

A good first approximation might be to look at a whole route, its total distance required, then use an average fuel efficiency (mpg) to arrive at gallons used by the car and thus its carbon emitted. But we wanted to have the infrastructure set up so that we could use real-time data from the phone's GPS to use positional/velocity data continuously over time to calculate emissions over intervals and therefore raise the ceiling for accuracy compared to precomputing it based on a route.

Process:

In terms of technologies and design process, we used React Native to make sure our app was cross-platform, while reducing our development time, and increasing our ease by making it done all in TypeScript. Within React-Native, we used the Expo Go infrastructure to rapidly iterate and deploy our app and within that we especially made extensive use of the the built-in modules of Location to handle our geolocation needs, Task Manager to work with background processes and location polling even when the app was unfocused, and AsyncStorage to compile location results for later calculation. blackboard

Details on realtime calculations

The basic idea is that fuel efficiency (and therefore fuel consumption) is a function of current speed. So the process to calculate carbon emissions over a trip is to take running averages of location, speed, altitude, etc. after every few seconds and compare them to the averages of the past few seconds, then calculate the total distance traveled for that interval and plug that and speed into our formula to get final carbon emissions. We use running averages in order to smooth out any odd data and we had to do put in a lot of research/effort in trying to distance based off changes not just in lat/longitude but also in altitude. We also used data to construct a function that models fuel consumption (gallons per miles) based off a car's current speed that we used in our code to calculate emissions over a certain time interval. Below is some code showing parts of our calculations used:

code more code

Design process:

We started with chalkboard writing of all possible features and how they rank on ease and necessity, then we moved on to drawing out flows of what the different core features might look like and the algorithms behind them. Some examples of that can be seen below: [insert blackboard images] While some of further moved to flesh out our algorithms, in parallel began to map out our app-screens on Figma (note figma prototype and final end result in app): figma

After this, while some of us worked on using React Native to build out and style our designs from Figma, others started to hook into the GeoLocation APIs and start to work out the core functionality of our project. We started with simply getting the location, then getting multiple locations and saving them, then calculating from intervals, then putting together all the calculations into one sum, etc.

Share this project:

Updates