Weather station or simple outdoor temperature measurement for free - data for energy analysis
- Andrzej Jarosz
- 6 hours ago
- 4 min read
When implementing energy consumption monitoring systems, the following thought often occurred to me:
What if we added a correlation with weather conditions?
Such data opens up enormous possibilities – from the analysis of weather-dependent energy losses , through the assessment of insulation effectiveness , to the control of installations based on current external conditions .
🔍 Looking for a simple way to get weather data
While reviewing various weather stations and industrial sensors, I quickly noticed that most of them do not share data with external systems or require a cloud server. However, for many analyses , a professional, reference measurement from the nearest weather station is sufficient – even if it is not directly next to our facility.
And here the perfect solution appeared: free meteorological data from the IMWM website , covering hundreds of stations in Poland, refreshed hourly. This is completely sufficient for energy consumption analyses.
Even our own weather station measures differently – differently on the roof, differently at the ground, differently on the southern wall. IMWM data can be treated as a reliable point of reference for the entire area.
⚙️ Free automation with InDriver
Thanks to the InDriver platform – a system tool for automation and data processing – downloading data from the IMGW API is simple, fast and free (for non-commercial use).
Just a few lines of JS code in InDriver are enough to:
download data from the IMGW API every 20 minutes,
save them to the PostgreSQL database,
and make it available for further analysis.
Sample script:
onStartup
InDriver.import("RestApi");
InDriver.sqlExecute('azureserver', "select tsapicreatetable('public','imgw')");
InDriver.installHook(1200000) // call onHook every 20 minutes
onHook
let ts= InDriver.hookTs();
RestApi.sendRequest('weather','{"url":"https://danepubliczne.imgw.pl/api/data/synop","timeout":5000, "type":"get","headers":{"ContentTypeHeader":"application/json"}}');
// <= read REST API DANE
if (RestApi.isSucceeded()) {
// We have data!
const restData = RestApi.getData('weather');
const weatherData = JSON.parse(restData);
const stations = weatherData.map(item => {
const dateStr = item.data_pomiaru; // np. "2025-10-20"
const hourStr = item.godzina_pomiaru.padStart(2, '0'); // eg. "07"
// local time Europe/Warsaw
const local = new Date(`${dateStr}T${hourStr}:00:00`);
const offsetMinutes = local.getTimezoneOffset(); // eg. -120 for CEST, -60 dla CET
const ts = new Date(local.getTime() - offsetMinutes * 60000).toISOString();
// helper function empty or null → null
const toNum = v => v === null || v === "" ? null : Number(v)
return {
station: item.stacja,
ts: ts,
data: {
cisnienie: toNum(item.cisnienie),
kierunek_wiatru: toNum(item.kierunek_wiatru),
predkosc_wiatru: toNum(item.predkosc_wiatru),
suma_opadu: toNum(item.suma_opadu),
temperatura: toNum(item.temperatura),
wilgotnosc_wzgledna: toNum(item.wilgotnosc_wzgledna)
}
};
});
InDriver.debug(stations,"Debug",false);
// Log JSONs to SQL Database
for (const s of stations) {
const stationWeather = JSON.stringify(s.data);
const safe = text => text.replace(/'/g, "''");
const query = `select tsapiinsert('public','imgw','${safe(s.station)}','${s.ts}','${safe(stationWeather)}')`;
InDriver.sqlExecute('azureserver', query);
}
}
⏱️ Weather data aggregation and processing
Each data source – including REST APIs – has its own specificity and requires appropriate processing.
In the case of IMWM data, the situation is as follows: we can download data at any time, but the measurements are updated once an hour , usually around 15 minutes past the hour . This is not officially documented, but practice shows that this is when new values appear.
Therefore, the InDriver task queries the API every 20 minutes. As a result, some data is repeated – which is not a problem, because the raw imgw table contains data in the form of timestamp, source, and jsondata.
This data is then automatically aggregated into processed tables: imgw_1hour, imgw_1day
They contain averaged, interpolated hourly and daily values, which are ideal for analysis and visualization in Grafana or Power BI.
🧩 Automatic aggregation in InDriver
Aggregation is performed in a separate task (e.g. OnHook), using the built-in TsApi API. The definition of an aggregator is very simple:
onStartup
InDriver.import("TsApi");
TsApi.defineAggregator("weather", "azureserver", "imgw", "Europe/Warsaw", '[]', '[ "1h", "1d"]', 10000);
TsApi.setAggregatorDebugMode("weather", false);
onHook:
aggregate('weather');
function aggregate(agg) {
const startTime = Date.now();
TsApi.aggregate(agg);
const endTime = Date.now();
const durationMs = endTime - startTime;
InDriver.debug(`TsApi.aggregate(${agg}) duration: ${durationMs} ms`);
}
In this way, InDriver automatically creates and updates tables with data aggregated at 1h and 1d intervals.
Thanks to this, in BI analyses we do not have to operate on raw data – we immediately use ready-made, processed temporal data.
📊 Effect
From Grafana, Power BI or any analytical tool, we can now conveniently use IMGW data after aggregation, e.g.:
imgw_1hour – to correlate instantaneous trends with energy consumption,
imgw_1day – for daily reports and seasonal analyses.
This is another example of how InDriver automates the entire data path – from download to processing and visualization.
📊 Data visualization in Grafana
We can easily combine weather data with energy data in Grafana , creating clear correlation graphs. Below is an example in which the temperature from the Institute of Meteorology and Water Management (IMGW) was plotted against the energy consumption of the facility:

Sample SQL query for temperature trend in Grafana:
select ts as time,(data->>'temperatura')::double precision as "temperatura" from public.imgw_1hour where source = 'Kraków' and ts between now() - interval '1 day' and now() order by ts asc;
☁️ Before you buy a weather station...
Before you spend money on a device, check out the available free weather APIs – in addition to IMWM, you can also use:
Open-Meteo: https://open-meteo.com/
OpenWeatherMap: https://openweathermap.org/api
WeatherAPI: https://www.weatherapi.com/
Combine them with InDriver and Grafana and you will create a complete analysis and visualization system.
– 10× faster, 10× cheaper and 100× more efficient .
This is the Game Changer of automation and data analysis .
Comments