Monthly Archives: December 2023

AVGTMP: A Program to Get the Average Temperature for a Location for Computing Degree Days

For many years I have been using the average temperature shown on my utility bill to compute the efficiency of my heating system, represented as fuel consumption per degree day. It’s an easy thing to do using a simple spreadsheet and it helps me judge whether improvements in things like insulation have made a difference. I’ll go into the details later in this post.

However, my utility recently redesigned my utility bill and stopped showing the average temperature value. I need that value, and spent a long time searching online for a source for such data. Finally I found a source, and used it to write a simple program called AVGTMP to download the data and use it to compute the value I need. I’m making the program available here.

Computing Heating System Efficiency

I heat with gas, which is measured in “ccf” (hundred cubic feet), so the efficiency value I use is “cf/DD” (cubic feet per degree day). It should be relatively constant over time. My gas bill is monthly, but the actual period varies by a few days from month to month. To be accurate, I need to consider the actual number of days in each period, and get the average temperature for only the days in the period.

My spreadsheet takes three values for a specific month: 1) number of days in the period, 2) average temperature for the period, and 3) gas consumption in ccf. Using those values I compute degree days for the period and consumption in cf/DD. It’s simple enough that you can easily create your own spreadsheet to do the same.

I use gas for other things like cooking and heating water, so there is a small baseline usage beyond what is used for heating. It’s small enough that I just ignore it.

Obtaining the Average Temperature Data Online

The key to making my AVGTMP program work was to find a source of historical temperature data for a specific location and for specific dates, that can be accessed through an API that would allow me to write a program to access it. I spent months looking for this, and finally found it, with a commercial data source at the website It is a paid service, but they have a free tier of service that allows limited data download, which happens to be more than adequate for what I’m using it for.

To use AVGTMP, you need an account at Visual Crossing, which is free and easy to set up, and you need something called an “API Key”. Go to, sign up, select the free tier, and get your API Key. You’ll enter the key into AVGTMP later.

Installing AVGTMP

AVGTMP is a simple command-line program. That will take a little getting used to if you’re not familiar with such programs, but it’s easy. I didn’t want to spend the extra time to make a fancy GUI for the program.

Download the file from and unzip it. Ignore the “avgtmp.cs” file unless you’re a programmer and wish to see how it works, modify it, or use it for your own purposes.

The simplest way to “install” AVGTMP is to put avgtmp.exe in C:\Windows\system32, since that’s the folder you’re in by default when you open a command prompt. That’s not a clean way to do it, and if you’re an experienced Windows user, feel free to come up with something better. In what follows, it’s assumed that you’re in a folder where AVGTMP is accessible.

You need a command prompt window to run AVGTMP. I like to put a shortcut to the command prompt on my desktop. Or you can hit Win-X and pick “Command prompt” from the list.

Once you have a command prompt, type “AVGTMP” and you’ll see:

*** No API Key set!
    Data is obtained from
    You must go there, create an account, select a plan,
    get an API Key, and enter it into this program, using this command:

    avgtmp -K mykey

AVGTMP - look up average temperature for a date range - 12/28/2023

To execute enter: AVGTMP zip start end

  zip is five-digit zip code of desired location
  start is start date
  end is end date

(Once you set an API Key, the first part of this message will no longer be displayed). Now would be a good time to get yourself an API Key and set it using the command shown in the message.


Once you have the API Key set, run AVGTMP by using the command shown above. Use a 5-diigit zip code and start and end dates in any reasonable format. Enclose the dates in double quotes if they include blank spaces. You can leave out the year if it’s the current year. So for example:

   avgtmp 10927 6/4 6/9

will give you the average temperature for the six-day period from June 4th through June 9th of the current year for the zip code 10927:

   from 6/4/2023 through 6/9/2023 (6 days) average temperature is 60.02

There is error checking built into the program to catch many common errors, but not all. You may get hard-to-decipher messages in some cases.

About Periods

The periods that you specify include the end days. This may or may not correspond to what you need. For example, my utility bill might have a period of Nov 3 to Dec 6 which would call 33 days. They are measuring from the middle of the starting day to the middle of the ending day, roughly corresponding to the time of meter reading. AVGTMP measures from the beginning of the starting day to the end of the ending day, which gives 34 days. My opinion is that it’s close enough.