What is my carbon footprint?


Global warming is an environmental issue ongoing in the past years. It is about the planet Earth heating up. One major cause of the warming is the greenhouse effect. Certain gases, such as CO2, keep the heat within the Earth atmosphere. These gases get into the air by burning fossil fuels such as coal, oil or natural gas. Fossil fuels contain a lot of carbon, which is when burnt, combines with oxygen to form carbon dioxide.

One of the main solutions to avoid global warming is to replace fossil fuel energy sources with renewables, such as wind, solar, hydropower etc. Another carbon free energy source is nuclear energy, which has a different set of challenges to solve.

To learn more about this visit this article by the National Geographic.

Global warming has a set of negative consequences:

  • climate/weather change with more severe weather phenomenon such as storms floods and wildfires

  • geographical changes, landscapes changes, ocean level changes

  • worse air quality due to the increased smog

  • economical burdon to address many of the problem above: such as preventing cities become flooded by oceans

Recently many companies announced plans to become carbon neutral or carbon free. Carbon neutral means not to produce more CO2 than the entity may consume. In this case produced emissions is offset by capturing CO2 from the atmosphere or by planting trees. Carbon free means to completely rely on renewable energy sources.

Why this is important to me

When it comes to global warming and climate change, I try to make choices that has little effect on me but matters for the environment. There are choices I can easily make, like walking to the local grocery store instead of driving. On the other hand there are still a lot of more difficult situations: how do you travel to a distant city in a few hours if not by planes? Unfortunately, jets have no viable alternatives as of writing this post; or is there: could you bring your activities in the distant city to the virtual space?

Burning gasoline will make cars go but it also produces carbon dioxide as a side product. In the last year my major choices of transportation were:

  • walking

  • electric roller

  • trams (run by electricity)

  • trains (run by electricity)

  • electric cars (car sharing)

  • airplanes (sometimes unavoidable)

Besides this used Teams / Skype / Zoom and other similar messaging platforms to communicate with other people at distance.

There are companies such as the Austrian Railway company ÖBB even sharing how much CO2 I have saved by taking a train instead of a car with combustion engine; more details here.

obb saving

This is very nice calculation, but it does not say how much of carbon dioxide has been emitted due to my travel.


As the initial motivation, I would like to know how much CO2 emission does it require to charge my electric roller. As a second step I would like to know how much CO2 is saved by not using a traditional car for traveling within a city or on short distance routes. Thirdly, I would like to generalize the solution to be able to measure not only power consumption of certain devices but a wider range of electrical appliances. Finally, I would like to measure the carbon dioxide footprint of the services and devices I am using to measure all this data.

One could argue that possibly a single flight out-shadows all of the other yearlong activities. This might be true, however the purpose is to measure everything else as well. Carbon emission of planes can be easily estimated by the route the planes take using Flightradar24, weather conditions during the flight and aircraft type. Takeoff weight might be estimated from takeoff characteristics of the flight. This might become an interesting improvement to implement in the future releases of the system.

To become more self-aware one would need to measure how much CO2 is emitted in a consequence of the person's actions. 'What is my CO2 footprint?' is a simple question with no simple answer. In this post, I will describe the IoT infrastructure I built, so that I can start measuring my CO2 footprint. This infrastructure consist of a couple of IoT devices, an Alexa skill, a set of Azure Durable Functions and two AspNet Core services hosted in Azure App Services.

When building the infrastructure itself the key aspects were keeping the system

  • simple

  • cheap to run and maintain

  • secure

  • scalable

  • have a small CO2 footprint


In this section I will model the system. For each component, I will respectively detail out its purpose, relative place in the system, its behavior and interactions to other components. By the end of this section it should give a comprehensive overview on how the system works. At the time of writing, this is the 3rd iteration of the services. As it is being constantly improved and rewritten. The reader may expect that by the time of reading this post, the system has further components, behavior and features implemented.


A device can be any electrical appliance that is in focus of measuring its power usage and thus carbon dioxide emission. Devices are choices of the user. A good candidate for a device is an appliance with high power drain: electric cars, electric rollers, washing machine, vacuum cleaners etc. The primary device I am interested in, is an electric roller. I choose this device as a primary because it has good alternatives for comparison (cars, walking, public transportation), as well as it has a larger, 284 Wh battery. I also have a few smaller capacity devices used as well for system testing purposes. A device may have a few properties once created by the user:

  • if it is actively charging

  • connected power meter, which is monitoring the current charging

  • current charging power

  • start time of current charging

  • end time of the last charging

  • carbon dioxide emission due to the current charge

  • total carbon dioxide emission

A device is implemented by a Durable Entity Function. It has actions to update its charging state. Once charging is started it periodically updates the current and total carbon dioxide emission by reading a carbon intensities and power meter data. When charging is initiated by the user, it can also instruct the power meter to switch the relay to charging state.

Power Meters

A power meter is a special type of hardware measuring power usage typically for a given wall socket. Note, that I am using "hardware" phrase here to avoid any confusion with "device" used above. Two types of hardware are supported: TP-LINK HS110 and Shelly 1PMs. A power meter is modeled by an entity. The entity contains all the hardware specific properties and the ability to communicate (create and parse messages) for the given type of power meter. A power meter is connected through the Gateway. Each power meter is assigned to a gateway, has a name, assigned IP address and country properties. The country is required, so the localized carbon intensity may be used for calculating the carbon emissions. The power meter entity has an Azure Function, Durable Entity implementation. The physical power meter typically has a built in relay. The power meter entity may open or close the hardware's relay.

Both type of physical hardware meters have an API, which can be invoked through HTTP or TCP protocols. The low level communication details are implemented by the gateway.


I use an Azure IoT DevKit as my gateway. It is a small Arduino board with a secure connection to Azure. The gateway does a few things:

  • it measures, temperature, humidity, etc. (not important for the current discussion)

  • it communicates with power meters and the Azure Function Entities

The gateway is an active hardware. It understands power meter types, and communicates to the power meters using their corresponding protocol. It periodically retrieves the configured power meter's power usage and sends data to the cloud functions for further processing. When the gateway is off, the whole system is at idle. This means that no messages are sent to the cloud, and no power meter API is invoked. In this state the whole system consumes no additional power, meaning that no additional carbon dioxide emission is generated. Also notice, that this type of hardware is very low power, it can run from batteries for days. It also reads power meters and cloud messages periodically every few minutes. In the meantime, it can power off itself using a timer til the next communication. Azure Functions communicate with the gateway through a queue.


An authenticated user of the system may have power meters, gateways and devices assigned to his/her profile. User authentication happens with OpenId Connect for both the Data Visualization Portal and the Alexa skill. A set of AzureAD app registrations is used for the system. The frontend and the backend uses on-behalf-of OIDC flow to pass the user's identity.

A user may request different aggregations of the carbon dioxide emitted based on his/her devices or power meters. On the screenshot below, a user has a total 26.935 grams of carbon dioxide emitted. The total is divided between 3 power meters (on the left pie chart) and 2 devices (on the right pie chart).

User Aggregated Data

Power Plants and Data Sources

When power meter readings are available, another function collects CO2 emissions. There are two approaches to calculate carbon intensity. The one currently used is a free service CO2 Signal, which calculates carbon intensity across the world. The second approach is by calculating the carbon intensity manually. I am investigating this solution for a future implementation of the system. The way to calculate carbon intensity is by gathering electricity production data from power plants and combining it with the CO2 emission per MW estimated by IPCC. During this process, the type of the power plant must be considered. Countries also sell and buy power from neighboring countries, which means the final result must be adjusted according to the electricity bought.

How to gather power plant electricity production?

Fortunately, this data is collected and published by Enstsoe and live data generation can be found on the Transparency Platform. Data is refreshed about every 15 minutes. This means that the data retrieved by the function may be cached for a few minutes of period.

Both data sources provide a REST API to fetch data.

Event Driven Approach with IoTHub and Azure Functions

The backed system is built on Azure Functions and Durable Functions. Azure Functions provides an event based architecture. An event can be an HTTP request or a message to on IoT Hub from the gateway. With no messages from the gateway and no HTTP requests from users, the system is idle. Using the Azure consumption plan this state costs nothing, and causes no carbon dioxide emissions.

Durable Functions direct developers to the use of CQRS design pattern. CQRS is a shorthand for Command Query Responsibility Segregation. In this case commands are received from the gateway: a new message to be processed is a command. Commands may also arrive from the user, when new devices or power meters are configured. When a new power data measurement is received the system adds the latest data point to the corresponding power meter and device. After this, a calculation is triggered to retrieve the latest carbon intensity based on the power meter's region. The calculated carbon emission is aggregated at device and power meter level. Durable Functions use Azure Storage tables and queues to trigger async work, which fits well for this type of data. Data processing happens in an asynchronous fashion, so it does not burn CPU power waiting on blocking IO.

This way queries are really fast and typically only need to read an already calculated value. Queries are used by the Alexa skill and the Data Visualization Portal. Is it reading a real time value? Because of eventual consistency and the asynchronous nature of the system it is quasi-real-time. Note, that both power meters and power plants publish data every few minutes only, hence a true real-time value could not be derived by nature of the dependencies. Taking this a step further, larger polluters (gas turbines, coal, oil etc.) cannot be powered up and down by a matter of seconds either. Power generation for these producers are typically planned upfront based historical datasets.

CQRS queries are used by the Alexa skill and the Data Visualization Portal in the system and implemented through HTTP GET requests.

Alexa skill and Data Visualization Portal

The last part of the system is an Alexa skill and Data Visualization. Both serve the same purpose: to visualize sliced and diced carbon emissions data for an authenticated user. Alexa skills are handled by HTTP triggers, along with Alexa skill dotnet library and the Bot Framework to create a conversational experience. Data Visualization Portal is a Blazor application which uses Blazorise to display the results to the user with charts. Grafana has been considered for data visualization, but at this point in time, I did not find a cost effective (and CO2 effective) solution host a serverless Grafana instance. The purpose of both the Alexa skill and the Data Visualization Portal is to make the user more self-aware on the carbon dioxide emissions.

A power meter displaying current power usage:

Power Meter on Portal

Device information during charging:

Device on Portal

Self monitoring

What is the CO2 emission of running the whole system?

At the time of writing this post I cannot measure the CO2 footprint of the services. However there are initiatives to build and measure sustainable software [4]. Using serverless and event driven approach I can make sure to only use power on CPU and memory when it is required. In an idle system, no process runs, which keeps the system's CO2 footprint minimal.

With Azure and Power BI one can use the Sustainability Calculator that gives insight into carbon emissions. Unfortunately today it is only available for Azure enterprise customers.


I am planning to use this app to become more self-aware when consuming electricity, using lamps, charging electric devices.

There are a lot of people, who are aware of the global warming, however their actions do not reflect true concerns about it. Instead of expecting that everyone changes his/her behavior, a more adequate solution must be found. To effectively reduce carbon dioxide emission due to human activities, new technologies should be developed that are carbon-free and that offer added benefits to the current ones, thus motivating consumers to upgrade.


  1. Intergovernmental Panel on Climate Change - IPCC

  2. Global Warming - National Geographic

  3. Global Warming - Wikipedia

  4. How to measure the power consumption of your backend service

  5. Adopting Azure serverless architectures to help reduce CO2 emissions

  6. CO2 Signal

  7. Entsoe Power Stats