Python logging+graphing to optimize central heat efficiency
Moderator: leecollings
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Python logging+graphing to optimize central heat efficiency
A fellow forum member (nickyb2) has made a nice application to log temperatures of your central heater. By optimizing your heating you can save gas. There is a nice (Dutch) topic on how to get your central heater as efficient as possible: http://gathering.tweakers.net/forum/lis ... es/1619229
nickyb2 has made a nice logging application, which pulls its data from temperature sensors you use in Domoticz. I have put two DS18B20 on the ingoing and outgoing pipes of the heater. Also a DS18B20 is hidden somewhere in my livingroom to measure room temperature. The external temperature is grabbed from Weather Underground.
With nickyb2' application, you can create graphs like this:
Find his excellent write-up (in Dutch) here: http://tweaken.blogspot.nl/2015/01/cv-k ... t-een.html
He also has made a nice script to upload the gasmeter-reading to Mindergas.nl daily: http://tweaken.blogspot.nl/2015/01/domo ... gasnl.html (you need a smartmeter connected to Domoticz).
Very useful when optimizing your heating and thus, lowering your gas bill
nickyb2 has made a nice logging application, which pulls its data from temperature sensors you use in Domoticz. I have put two DS18B20 on the ingoing and outgoing pipes of the heater. Also a DS18B20 is hidden somewhere in my livingroom to measure room temperature. The external temperature is grabbed from Weather Underground.
With nickyb2' application, you can create graphs like this:
Find his excellent write-up (in Dutch) here: http://tweaken.blogspot.nl/2015/01/cv-k ... t-een.html
He also has made a nice script to upload the gasmeter-reading to Mindergas.nl daily: http://tweaken.blogspot.nl/2015/01/domo ... gasnl.html (you need a smartmeter connected to Domoticz).
Very useful when optimizing your heating and thus, lowering your gas bill
I am not active on this forum anymore.
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Python logging+graphing to optimize central heat efficie
Now wireless!
Since i migrated from a Raspberry Pi to my NAS (Synology DS114) i couldn't read the 1-wire sensors anymore. I thought about buying a 1-wire USB-cable, but why not make the sensors wireless?
I was experimenting a bit with a ESP8266, and it just seemed perfect for this task.
So i started working, and it resulted in this:
(LM2596 DC-DC convertor on the left, ESP8266 ESP-01 in the center, 2x DS18B20 on a PCB screw terminal on the right).
The DS18B20 in the picture are just for testing. In my setup i use waterproof DS18B20 in a nice steel tube that i mounted on my central heater' pipes with tie-rips.
The code is written by a forum member from Tweakers.net, 'mightym'. I have included it in the attachment.
It is far from stable (reboots after a few measurements) but works fine, because the ESP8266 starts measuring & publishing to Domoticz automatically again after a reboot.
Edit the 'init.lua' so it contains your WiFi networkname (SSID) and correct password. Edit the 'multids18b20.lua' so it points to the right IP & port of your Domoticz installation.
In your Domoticz install, create two virtual temperature sensors and remember their IDX. Put these in the URL's in the 'multids18b20.lua' code.
Since i migrated from a Raspberry Pi to my NAS (Synology DS114) i couldn't read the 1-wire sensors anymore. I thought about buying a 1-wire USB-cable, but why not make the sensors wireless?
I was experimenting a bit with a ESP8266, and it just seemed perfect for this task.
So i started working, and it resulted in this:
(LM2596 DC-DC convertor on the left, ESP8266 ESP-01 in the center, 2x DS18B20 on a PCB screw terminal on the right).
The DS18B20 in the picture are just for testing. In my setup i use waterproof DS18B20 in a nice steel tube that i mounted on my central heater' pipes with tie-rips.
The code is written by a forum member from Tweakers.net, 'mightym'. I have included it in the attachment.
It is far from stable (reboots after a few measurements) but works fine, because the ESP8266 starts measuring & publishing to Domoticz automatically again after a reboot.
Edit the 'init.lua' so it contains your WiFi networkname (SSID) and correct password. Edit the 'multids18b20.lua' so it points to the right IP & port of your Domoticz installation.
In your Domoticz install, create two virtual temperature sensors and remember their IDX. Put these in the URL's in the 'multids18b20.lua' code.
- Attachments
-
- ESP multi ds18b20.zip
- (2.62 KiB) Downloaded 1176 times
I am not active on this forum anymore.
-
- Posts: 3
- Joined: Monday 27 July 2015 16:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python logging+graphing to optimize central heat efficie
hi, first thanks for sharing your projects.
I've build the wifi dimmer with succes.
Now I am experimenting with this dual ds18b20 wifi sensor but I did something wrong I guess.
The lua script is running, but the temperature reading from both sensors stay empty when connected with a serial terminal and also in domoticz.
I've tested the sensors with another single temperature script and they work fine.
I hope you can help me with this.
Thanks!
I've build the wifi dimmer with succes.
Now I am experimenting with this dual ds18b20 wifi sensor but I did something wrong I guess.
The lua script is running, but the temperature reading from both sensors stay empty when connected with a serial terminal and also in domoticz.
I've tested the sensors with another single temperature script and they work fine.
I hope you can help me with this.
Thanks!
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Python logging+graphing to optimize central heat efficie
Have you created the virtual temperature sensors and changed the IDX'es in the Lua code to those of your newly created sensors?
I am not active on this forum anymore.
-
- Posts: 3
- Joined: Monday 27 July 2015 16:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python logging+graphing to optimize central heat efficie
Hi, yes I did.
It only showed the C character without any temperature reading.
I couldn't find exactly what was wrong but I did a format on the esp and reloaded the lua files and now both sensors are working!
The only strange thing is that the first sensor has 0.5C degrees steps and the second 1C degrees steps, also in the domoticz log file.
Thanks for your reply Thinkpad.
It only showed the C character without any temperature reading.
I couldn't find exactly what was wrong but I did a format on the esp and reloaded the lua files and now both sensors are working!
The only strange thing is that the first sensor has 0.5C degrees steps and the second 1C degrees steps, also in the domoticz log file.
Thanks for your reply Thinkpad.
-
- Posts: 14
- Joined: Monday 14 March 2016 21:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Groningen
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
Hi Thinkpad,
I started with Domoticz a few weeks ago and now i want to try to connect two DS18B20 sensors to a ESP8266 as you did above.
Are you sure the file multids18b20.lua is correct. No matter what i try i'm not able to get it working... I got this error when i try to excecute teh file multids18b20.lu with the dofile("multids18b20.lua") command:
> PANIC: unprotected error in call to Lua API (multids18b20.lua:10: invalid option '%f' to 'format')
c_??RS?fJS?fJS?f??
With another lua-program i was able to send the temperature (with only one sensor) to my Domoticz-system so i know how to setup the ip, port and idx in the lua-file.
I have two DS18B20-sensors connected to gpio0 and 1 (3 and 4).
Hope you can help me,
Joop
I started with Domoticz a few weeks ago and now i want to try to connect two DS18B20 sensors to a ESP8266 as you did above.
Are you sure the file multids18b20.lua is correct. No matter what i try i'm not able to get it working... I got this error when i try to excecute teh file multids18b20.lu with the dofile("multids18b20.lua") command:
> PANIC: unprotected error in call to Lua API (multids18b20.lua:10: invalid option '%f' to 'format')
c_??RS?fJS?fJS?f??
With another lua-program i was able to send the temperature (with only one sensor) to my Domoticz-system so i know how to setup the ip, port and idx in the lua-file.
I have two DS18B20-sensors connected to gpio0 and 1 (3 and 4).
Hope you can help me,
Joop
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
Hi,juppetup wrote:Hi Thinkpad,
[...]
Hope you can help me,
[...]
It has been too long ago for me to remember how it worked. I now use a OTGW (Opentherm Gateway) to monitor my 'CV-ketel'. No need to tape sensors to the pipework, just use the data coming from the heater itself.
See http://gathering.tweakers.net/forum/lis ... es/1653967 for more information.
I am not active on this forum anymore.
-
- Posts: 14
- Joined: Monday 14 March 2016 21:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Groningen
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
Hi,
thanks for the tip about Opentherm. But i think it must be something small. I copied the lua files and still i get a lua-error: invalid option '%f' to 'format'
Can it be i have a different nodemcu-firmware then you have?
I have: 0.9.5 build 20150318 powered by Lua 5.1.4
regards,
Joop
thanks for the tip about Opentherm. But i think it must be something small. I copied the lua files and still i get a lua-error: invalid option '%f' to 'format'
Can it be i have a different nodemcu-firmware then you have?
I have: 0.9.5 build 20150318 powered by Lua 5.1.4
regards,
Joop
Last edited by juppetup on Tuesday 15 March 2016 16:52, edited 1 time in total.
-
- Posts: 15
- Joined: Friday 05 June 2015 11:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Rotterdam, NL
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
Hi Joop,
As an alternative to lua you might take a look at ESPeasy: www.esp8266.nu to connect the sensors to domoticz.
Bob.
As an alternative to lua you might take a look at ESPeasy: www.esp8266.nu to connect the sensors to domoticz.
Bob.
-
- Posts: 139
- Joined: Thursday 19 February 2015 21:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
I have done the same a while ago, to optimize the heating of my new house, since it was heating slow and I was wasting a lot of energy.
Instead I have used ESP01 units with 2 one wire temperature sensors attached, runing a mysensor sketch that is gate with inputs (from the development branch)
I have one sensor on the incoming water line and one to the return line
To heat a house in the most efficient way, the heaters should all have about the same flow/temperature drop. if one rediator has a much lower flow resistance, most of the water will be passing through that radiator and the pump is wasting engery pumping the wafer round and the other radiators get not enough water to radiate a lot of heat, and heating will be slow.
To adjust the heaters I reduced the out flow valve and kept the inflow open, that increases the temperature drop over the radiator. hot water can always go in when the pump starts but flows out slowly, so residence time is long and makes it om efficient. since changing the flow on one radiator will have an impact on the others, I changed the flows one at the time and then looked in the logging of domoticz what the maximum temperature drop was. at the end I also adjusted the inlet valves of some radiators that were close to the heater to limit the flow and get more flow at the end of the system. (here a dutch reference side about it http://www.cv-inregelen.nl/waterzijdig-inregelen)
When you have adjusted the flows you can bring down the boiler water temperature of the heater to safe some more energy and cost.
next to that you can adjust the boiler water temperature based on the outside temperature, when it is outside <0C i want my house to be heated quickly so the boiler wafer will go to ~80C and when it is hot outside I don't need so much heating power, so I reduce the boiler water temperature.
I do that through the open therm gateway (http://otgw.tclcode.com/index.html)
last but not least I recently installed a magnetic valve in one of the waterlines, since I only spend a lot of time in my workroom in the weekend and I forgot to turn of the heater by hand.. so it had been heating all week while nobody was there, waste of energy that had to be solved .
now I manually open the valve (just a press of a switch on the domoticz app) when I need to and it automatically closes when the central heater goes off at night
turning off the heater I have also automated, based on the outside temperature I turn off the heater at a different time, since the hous will stay warm for a while it is a waste of energy to keep heating it until you go to bed.
when it is outside >10C the heater switches off at 20:00 , between 0C and 10C it switches off at 21:00 and under 0C is switches off at 21:30
Since my heater is modulating, the temperature data over the heater is changing all the time.
issue with domoticz is that it is only logging every 5 minutes, so the resolution is low...
so I pulled out the data in csv and processed with a macro it in excel to see which radiator I had to adjust (twice a week to get some statistics for every heater)
now my 3 heaters in the living room get in about the same temperature and all have a drop of 10C
the heater in the bathroom I have added a thermostat in the end, since it was always heating faster than the livingroom and was a waste of energy
and my workroom, I manually switch on in the morning when I know I will be there, but need to integrate some logic in there because the temperature is not yet controlled....
this is the mysensor sketch i used
p.s. I also tried to do the same with Z-wave binary input units since they claim also to work with onewire sensors, but those node kept dropping off and acting strange, so i changed to the cheaper ESP units with a vlotage regulator and some old phone chargers to power the units
Instead I have used ESP01 units with 2 one wire temperature sensors attached, runing a mysensor sketch that is gate with inputs (from the development branch)
I have one sensor on the incoming water line and one to the return line
To heat a house in the most efficient way, the heaters should all have about the same flow/temperature drop. if one rediator has a much lower flow resistance, most of the water will be passing through that radiator and the pump is wasting engery pumping the wafer round and the other radiators get not enough water to radiate a lot of heat, and heating will be slow.
To adjust the heaters I reduced the out flow valve and kept the inflow open, that increases the temperature drop over the radiator. hot water can always go in when the pump starts but flows out slowly, so residence time is long and makes it om efficient. since changing the flow on one radiator will have an impact on the others, I changed the flows one at the time and then looked in the logging of domoticz what the maximum temperature drop was. at the end I also adjusted the inlet valves of some radiators that were close to the heater to limit the flow and get more flow at the end of the system. (here a dutch reference side about it http://www.cv-inregelen.nl/waterzijdig-inregelen)
When you have adjusted the flows you can bring down the boiler water temperature of the heater to safe some more energy and cost.
next to that you can adjust the boiler water temperature based on the outside temperature, when it is outside <0C i want my house to be heated quickly so the boiler wafer will go to ~80C and when it is hot outside I don't need so much heating power, so I reduce the boiler water temperature.
I do that through the open therm gateway (http://otgw.tclcode.com/index.html)
last but not least I recently installed a magnetic valve in one of the waterlines, since I only spend a lot of time in my workroom in the weekend and I forgot to turn of the heater by hand.. so it had been heating all week while nobody was there, waste of energy that had to be solved .
now I manually open the valve (just a press of a switch on the domoticz app) when I need to and it automatically closes when the central heater goes off at night
turning off the heater I have also automated, based on the outside temperature I turn off the heater at a different time, since the hous will stay warm for a while it is a waste of energy to keep heating it until you go to bed.
when it is outside >10C the heater switches off at 20:00 , between 0C and 10C it switches off at 21:00 and under 0C is switches off at 21:30
Since my heater is modulating, the temperature data over the heater is changing all the time.
issue with domoticz is that it is only logging every 5 minutes, so the resolution is low...
so I pulled out the data in csv and processed with a macro it in excel to see which radiator I had to adjust (twice a week to get some statistics for every heater)
now my 3 heaters in the living room get in about the same temperature and all have a drop of 10C
the heater in the bathroom I have added a thermostat in the end, since it was always heating faster than the livingroom and was a waste of energy
and my workroom, I manually switch on in the morning when I know I will be there, but need to integrate some logic in there because the temperature is not yet controlled....
this is the mysensor sketch i used
Code: Select all
#include <EEPROM.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>
// Enable debug prints to serial monitor
#define MY_DEBUG
// Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
#define MY_BAUD_RATE 9600
// Gateway mode always enabled for ESP8266. But we add this anyway ;)
#define MY_GATEWAY_ESP8266
#define MY_ESP8266_SSID "xxx"
#define MY_ESP8266_PASSWORD "xxx"
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 192,168,2,113
#define MY_IP_GATEWAY_ADDRESS 192,168,2,254
#define MY_IP_SUBNET_ADDRESS 255,255,255,0
// The port to keep open on node server mode
#define MY_PORT 5003
// How many clients should be able to connect to this gateway (default 1)
#define MY_GATEWAY_MAX_CLIENTS 2
#include <ESP8266WiFi.h>
#include <MySensor.h>
// Dallas stuff
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
#define ONE_WIRE_BUS 2 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 16
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
boolean receivedConfig = false;
boolean metric = true;
// Initialize temperature message
MyMessage msg(0,V_TEMP);
void setup()
{
Serial.println("debug setup");
// Startup up the OneWire library
sensors.begin();
// requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
}
void presentation() {
Serial.println("Presentation:");
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Temperature Sensor", "1.1");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
Serial.print("sensors: ");
Serial.println(numSensors);
// Present all sensors to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
}
void loop()
{
Serial.println("Loop:");
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
sleep(conversionTime);
// Read temperatures and send them to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
Serial.print("Reading sensor: ");
Serial.print(i);
Serial.print(" with value: ");
Serial.println(temperature);
// Only send data if temperature has changed and no error
#if COMPARE_TEMP == 1
if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
#else
if (temperature != -127.00 && temperature != 85.00) {
#endif
// Send in the new temperature
send(msg.setSensor(i).set(temperature,1));
// Save new temperatures for next compare
lastTemperature[i]=temperature;
}
}
delay(60000);
}
-
- Posts: 139
- Joined: Thursday 19 February 2015 21:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
here is a picture of the nodes I had installed at every heater, runing with the sketch posted
-
- Posts: 14
- Joined: Monday 14 March 2016 21:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Groningen
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
Hi Bob,
ESP Easy looks great indeed! However.... I tried to install the firmware (v78) in the Windows commandline. Used the Flash-command. Entered com33 (my com-port), 512 (size for my ESP-board), and firmware 78. There is communication (i see the rx and tx leds flashing) but firmware-upload goes wrong.
I wonder: i see that the flash-software tries 115200 as baudrate but when i connect with a terminal-program with my esp the baudrate must be 9600 baud. So i think thats the problem: my esp is in 9600 bd mode and the flash-tool uses 115200 bd?
In my ESP8266 is: NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
Joop
ESP Easy looks great indeed! However.... I tried to install the firmware (v78) in the Windows commandline. Used the Flash-command. Entered com33 (my com-port), 512 (size for my ESP-board), and firmware 78. There is communication (i see the rx and tx leds flashing) but firmware-upload goes wrong.
I wonder: i see that the flash-software tries 115200 as baudrate but when i connect with a terminal-program with my esp the baudrate must be 9600 baud. So i think thats the problem: my esp is in 9600 bd mode and the flash-tool uses 115200 bd?
In my ESP8266 is: NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
Joop
-
- Posts: 14
- Joined: Monday 14 March 2016 21:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Groningen
- Contact:
Re: Python logging+graphing to optimize central heat efficiency
I forgot to put the ESP8266-module in program-mode (GPIO0 connected to ground). After that i was able to flash the unit.
Works great. No more lua-scripts here! My two-sensor thermometer was ready in an evening!
Works great. No more lua-scripts here! My two-sensor thermometer was ready in an evening!
Who is online
Users browsing this forum: No registered users and 0 guests