08 A bit of code. Programming for energy data management

Programming for energy data management

I am going to talk about programming. I am not an expert but I believe that programming is essential for an energy manager. The reason is the amount of data he has to manage. Once you have designed your dashboards you have to update them, monthly or weekly. If the energy monitoring system is automatized and allows updating, perfect, but this is not normally the case. Usually the data is worked on a spreadsheet. Why? Because apart from the real data, the baselines must be established and updated. To increase this analysis and reaction, you have to calculate the differences against the baselines. And you have to add information about potentials. For example, consumption in non-working hours, the consumption in weekend hours, etc.

Programing to automatize analysis.

Therefore, the purpose of this post is to explain that it is convenient to automate these tasks. This can be done through programming. As I said before I am not an expert but I try to learn everything that I find interesting. In the end it is more about overcoming fears and facing new challenges. In my case in most of the time I use Excel spreadsheets so I program in VBA. I think that Excel has some features that facilitate the work. Especially to an amateur like me. The panel of tools for programming, the ability to record macros and its debugger are great.

In Excel, VBA.

Surely I do more spaghetti than an Italian restaurant. But in the end the program runs and does what I want. We will have the time to refine the code, shorten its extension and make it more efficient with less processing time.

Spaghetti: big amount of programing code which is not optimized
Spaghetti: big amount of programing code which is not optimized

 

There is a whole community of programmers and a lot of support. There are lot of websites and videos to program in any language. In particular, for VBA, I always find many resources. above all, code examples, which I can use directly or adapt them with simple modifications.

VBA Excel Programing interface
VBA Excel Programing interface

 

Lot of free resources to learn.

It is always necessary to make a balance when programming. I do not think that it is convenient to program excessively all the tasks. The decision of when to program depends on the length of the task. The number of repetitions throughout the month or year. I mention this because you can end up devoting too much time to programming. And you cannot neglect other tasks, typical of the energy manager.

Once you decide that the task is frequent it is good to make an investment of time to program it. It is true that this contribution of time at the beginning is huge, so we must reserve the space within our time to do it.

Programing as a means not as a target.

The knowledge to program can be found in many web pages created for that purpose. I can recommend the following:

http://www.excel-easy.com/vba.html

https://www.tutorialspoint.com/vba/index.htm

https://www.excelcampus.com/vba/vba-immediate-window-excel/

Normally what I do is simply to look for the type of code I need, and consult several references until I choose the one that suits me best.

It is difficult that you can use some of the code that I have written since it is very specific. But as an example I am going to leave you here a code. It takes data from a temperature-humidity-CO2 detector. I use it to measure the conditions of the rooms or buildings that consume energy.

Temperature, humidity and CO2 sensor. TIM12 Desktop CO2 & RH / T Monitor / Data Logger
Temperature, humidity and CO2 sensor. TIM12 Desktop CO2 & RH / T Monitor / Data Logger

The code imports the data from a .txt file into Excel. Later, builds pivot tables with the measured parameters represented over time. Finally it makes a graph of temperature versus humidity. It allows to locate the conditions and compare them with the appropriate comfort zones.

VBAcodeDataImportTemperatureMeter

Leave a Reply