Welcome, Guest
Username: Password: Remember me

TOPIC: Home central heating monitor/controller

Home central heating monitor/controller 7 months 1 day ago #3650

  • bmwmilos
  • bmwmilos's Avatar
  • Offline
  • New Member
  • Posts: 12
  • Karma: 0
Hello!
I've built a home central heating controller using arduino. It controls wood boiler pump, central heating pump and water temperature regulation through motorised 3-way valve. Now I wanted to add a ESP8266 and put it in living room together with a display and I wanted to use this server to upload sensor data and to turn on/off heating and modify the water temperature setting.
This is the board in the boiler room ( well it is a clone used for testing purposes ):


This is the ESP (Wemos D1 mini):




I have made my own module using MT_RGB_LED_DIMMER as template but I wanted to add other sensors to sensorstatus. I did manage t use the module for control once,but after the server update things are not working ok. On the mobile app I get the sensor data ( status ) but it is not updated as ESP does publish. And on the mobile app there is no slider or switch. On the web cloud I used to get all sensors status and slider and switch,but now I am only getting three sliders and a switch and no sensor status. Am I doing something wrong ?
Here is the code for my module:
function getModuleData(module){
var data = {
    icon: "",
    status: "",
    timestamp: "",
    rawvalue: "",  //TempPolazZad
    unit: "",
    rawvalue1: "",  //SprGore
	rawvalue2: "", //SprDole
	rawvalue3: "", //Kotao
	rawvalue4: "", //Dim
	rawvalue5: "", //TempPolaz
	rawvalue6: "", //Grijanje
};
data.icon = "user/" + Eiot.Data.ProfileId + "/images/fire.png";
var ic = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.Icon1");
if (ic != null && ic != "" && ic != "undefined")
  	data.icon = "user/" + Eiot.Data.ProfileId + "/images/" + ic.Value;
var level1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.TempPolazZad");
if (level1 != null) {
   data.unit = level1.Unit;
   if (data.timestamp < level1.Timestamp)
	   data.timestamp = level1.Timestamp;
   data.rawvalue = level1.Value;
   var value = Math.round(level.Value.replace(",", ".") * 10) / 10;
   if (isNaN(value)) value = level1.Value;
	data.status =((level1.Description == "") ? "" : level1.Description + ": ")  + value + ((level1.Unit == "") ? "" : "&nbsp;" + level1.Unit);
}
var level2 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.SprGore");
if (level2 != null) {
   data.unit = level2.Unit;
   if (data.timestamp < level2.Timestamp)
	   data.timestamp = level2.Timestamp;
   data.rawvalue1 = level2.Value;
   var value = Math.round(level2.Value.replace(",", ".") * 10) / 10;
   if (isNaN(value)) value = level2.Value;
	data.status += " " + ((level2.Description == "") ? "" : level2.Description + ": ")  + value + ((level2.Unit == "") ? "" : "&nbsp;" + level2.Unit);
}
var level3 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.SprDole");
if (level3 != null) {
   data.unit = level3.Unit;
   if (data.timestamp < level3.Timestamp)
	   data.timestamp = level3.Timestamp;
   data.rawvalue2 = level3.Value;
   var value = Math.round(level3.Value.replace(",", ".") * 10) / 10;
   if (isNaN(value)) value = level3.Value;
	data.status += " " + ((level3.Description == "") ? "" : level3.Description + ": ")  + value + ((level3.Unit == "") ? "" : "&nbsp;" + level3.Unit);
}
var level4 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Kotao");
if (level4 != null) {
   data.unit = level4.Unit;
   if (data.timestamp < level4.Timestamp)
	   data.timestamp = level4.Timestamp;
   data.rawvalue3 = level4.Value;
   var value = Math.round(level4.Value.replace(",", ".") * 10) / 10;
   if (isNaN(value)) value = level4.Value;
	data.status += " " + ((level4.Description == "") ? "" : level4.Description + ": ")  + value + ((level4.Unit == "") ? "" : "&nbsp;" + level4.Unit);
}
var level5 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Dim");
if (level5 != null) {
   data.unit = level5.Unit;
   if (data.timestamp < level5.Timestamp)
	   data.timestamp = level5.Timestamp;
   data.rawvalue4 = level5.Value;
   var value = Math.round(level5.Value.replace(",", ".") * 10) / 10;
   if (isNaN(value)) value = level5.Value;
	data.status += " " + ((level5.Description == "") ? "" : level5.Description + ": ")  + value + ((level5.Unit == "") ? "" : "&nbsp;" + level5.Unit);
}
var level6 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.TempPolaz");
if (level6 != null) {
   data.unit = level6.Unit;
   if (data.timestamp < level6.Timestamp)
	   data.timestamp = level6.Timestamp;
   data.rawvalue5 = level6.Value;
   var value = Math.round(level6.Value.replace(",", "."));
   if (isNaN(value)) value = level6.Value;
	data.status += " " + ((level6.Description == "") ? "" : level6.Description + ": ")  + value + ((level6.Unit == "") ? "" : "&nbsp;" + level6.Unit);
}
var level7 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Grijanje");
if (level7 != null) {
	data.rawvalue6 = level7.Value;
	var offText = "OFF";
	var onText = "ON";
	var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText2");
	if (o1 != null)
		offText = o1.Value;
	var o2 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText1");
	if (o2 != null)
		onText = o2.Value;
	var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Grijanje"); 
	data.status += " " + ((level7.Description == "") ? "" : level7.Description + ": ")  + ((level7.Value == 0 ) ? offText : onText) + ((level7.Unit == "") ? "" : "&nbsp;" + level7.Unit);
}

return data;
}
function initControl(control)
{
	var sliderVal;
	var o4 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.TempPolazZad");
	if (o4 != null) {
		sliderVal = Math.round(o4.Value.replace(",", ".") * 100) / 100;
		if (isNaN(sliderVal)) sliderVal = o4.Value;
	}
			var sliderMinValue =  35;
			var sliderMaxValue =  70;
			var sliderValueStep =  1;
			var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.SliderMinValue");
			if (o1 != null) {
				sliderMinValue = Math.round(o1.Value.replace(",", ".") * 100) / 100;
				if (isNaN(sliderMinValue)) sliderMinValue = o1.Value;
			}
			var o2 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.SliderMaxValue");
			if (o2 != null) {
				sliderMaxValue = Math.round(o2.Value.replace(",", ".") * 100) / 100;
				if (isNaN(sliderMaxValue)) sliderMaxValue = o2.Value;
			}
			var o3 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.SliderStep");
			if (o3 != null) {
				sliderValueStep = Math.round(o3.Value.replace(",", ".") * 100) / 100;
				if (isNaN(sliderValueStep)) sliderValueStep = o3.Value;
			}
			control.find("[data-ui-field=control_slider]").prop("min", sliderMinValue);
			control.find("[data-ui-field=control_slider]").prop("max", sliderMaxValue);
			control.find("[data-ui-field=control_slider]").prop("step", sliderValueStep);
			control.find("[data-ui-field=control_slider]").slider();
			control.find("[data-ui-field=control_slider]").val(sliderVal).slider("refresh");
control.find("[data-ui-field=control_slider]").on("slidestop", function(event, ui) {	for (var j = 0; j < Eiot.Data.Modules.length; j++) {
		if (Eiot.Data.Modules[j].Id == event.target.id)
		{
			var param = Eiot.WebApp.Utility.GetModulePropertyByName(Eiot.Data.Modules[j], "Sensor.TempPolazZad");
			if (param != null){
				Eiot.Data.ServiceCall("Control/Parameter/SetValue/"+param.Id+"/"+control.find("[data-ui-field=control_slider]").val(), null, "POST", null);
			}
		}
	}
});
var state = "0";
var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Grijanje");
if (level != null && level.Value == "1") 
	state = "1";
var onText = "ON";
var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText1");
if (o1 != null)
	onText = o1.Value;
var offText = "OFF";
var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText2");
if (o1 != null)
	offText = o1.Value;
control.find(".ui-slider-label-a").text(onText);control.find(".ui-slider-label-b").text(offText);control.find("[data-ui-field=flipsw]").val(state).slider("refresh");control.find("[data-ui-field=flipsw]").on("change", function(event, ui) {	for (var j = 0; j < Eiot.Data.Modules.length; j++) {
		if (Eiot.Data.Modules[j].Id == event.target.id)
		{
			var param = Eiot.WebApp.Utility.GetModulePropertyByName(Eiot.Data.Modules[j], "Sensor.Grijanje");
			if (param != null){
				Eiot.Data.ServiceCall("Control/Parameter/SetValue/"+param.Id+"/"+control.find("[data-ui-field=flipsw]").val(), null, "POST", null);
			}
		}
	}
});}
function updateControl(control, data)
{
	control.find("[data-ui-field=control_slider]").val(data.rawvalue);
	control.find("[data-ui-field=control_slider]").slider("refresh");
	control.find("[data-ui-field=flipsw]").val(data.rawvalue6);
	control.find("[data-ui-field=flipsw]").slider("refresh");
}
Can someone help and point out if I'm doing something wrong ?
Last Edit: 7 months 1 day ago by bmwmilos.
The administrator has disabled public write access.

Home central heating monitor/controller 7 months 1 day ago #3651

  • bmwmilos
  • bmwmilos's Avatar
  • Offline
  • New Member
  • Posts: 12
  • Karma: 0
This is what I get on android app


This is what I get on web cloud
The administrator has disabled public write access.

Home central heating monitor/controller 6 months 3 weeks ago #3670

  • EasyIoT
  • EasyIoT's Avatar
  • Offline
  • Administrator
  • Posts: 833
  • Thank you received: 258
  • Karma: 24
Your project is very interesting. Could you post your project on this site (schematic and code)?

To answer your question - if you create custom module type it will be visible only on WEB interface. On Android interface you will see only generic module type which displays only parameter values. Module types are in Android application hard coded.

Which module controls do you need for your project?
The administrator has disabled public write access.

Home central heating monitor/controller 6 months 3 weeks ago #3672

  • bmwmilos
  • bmwmilos's Avatar
  • Offline
  • New Member
  • Posts: 12
  • Karma: 0
Thank you for replying. I will post the codes tomorrow. I need only the slider and switch,but i would also like to add 5 more sensors to display in status line like in the temperature and humidity example.
I did manage to get the controls working by selecting the MT_DIMMER module type and I thought that I could solve the problem of sensors by creating another module MT_Generic type. The second module gets created with different Id,and sensors get created and named correctly but even though i publish the values nothing gets to the cloud. Can I publish to two modules from the same client? Do i need to set up something different?
The administrator has disabled public write access.

Home central heating monitor/controller 6 months 3 weeks ago #3673

  • EasyIoT
  • EasyIoT's Avatar
  • Offline
  • Administrator
  • Posts: 833
  • Thank you received: 258
  • Karma: 24
bmwmilos wrote:
Thank you for replying. I will post the codes tomorrow. I need only the slider and switch,but i would also like to add 5 more sensors to display in status line like in the temperature and humidity example.
I did manage to get the controls working by selecting the MT_DIMMER module type and I thought that I could solve the problem of sensors by creating another module MT_Generic type. The second module gets created with different Id,and sensors get created and named correctly but even though i publish the values nothing gets to the cloud. Can I publish to two modules from the same client? Do i need to set up something different?

Hi, your approach is correct. You can use two modules with different ids. Just publish values to correct topic if you are using MQTT.

P.S.: I'm planning to bulid similar thermostat. I will use ESP32, which is more powerful than ESP866. For display I will use touch screen ILI9341 .
The administrator has disabled public write access.

Home central heating monitor/controller 6 months 3 weeks ago #3674

  • bmwmilos
  • bmwmilos's Avatar
  • Offline
  • New Member
  • Posts: 12
  • Karma: 0
I will also put ili9341 screen, I am just waiting to arrive. The arduino part is already in place and functioning. I will only add esp8266 part with additional display.
Will post the code this evening when I come home.
As for the publishing, I cannot seem to get it to work. I am using the code
String valueStr(TempPolaz) and add different topic with different module ID and sensor name but there are no values in cloud! I have even tried to eliminate that part of the code and publish a fixed value over longer period ( once every 60 seconds ) but no luck! I cannot understand where is the problem. The module ID is correct. Before this I had a problem with control module but the values were getting sent. Now when I separated into two modules,the one with generic type only shows sensor names and ":" and absolutely no values. This evening I wil try to eliminate "subscribe" to first module and see if I can upload data then!
I think you can make a module of type generic + dimmer, just the first two parameters would be for dimmer ( control ) and then the generic part would be :
with added & module.Parameters > 2 and modified for (var p = 2;
if (module.Parameters != null & module.Parameters > 2) {
	for (var p = 2; p < module.Parameters.length; p++) {
		if (module.Parameters[p].Name.substring(0, 7) == "Sensor.") {
			data.status = data.status + ((module.Parameters[p].Description == "") ? module.Parameters[p].Name : module.Parameters[p].Description) + ": " + module.Parameters[p].Value + ((module.Parameters[p].Unit == "") ? "" : "&nbsp;" + module.Parameters[p].Unit) + "<br>";
			if (data.timestamp < module.Parameters[p].Timestamp)
				data.timestamp = module.Parameters[p].Timestamp;
		}
	  }
}
This way one could add as many other monitoring sensors as necessary.
I am still new to html and java but I'm trying.
Last Edit: 6 months 3 weeks ago by bmwmilos.
The administrator has disabled public write access.
Time to create page: 0.203 seconds
Powered by Kunena Forum