Register opened window when airing thermostat

Hi all.

I've been working on DIY thermostat for my home. Everything works fine. Connected via blynk. But since I heat my house with pellets and big hot water boiler I only run pump with thermostat. Pellet burner check water temp and turn on and off.

Now there is a problem when I open widnows for airing my living room. We smoke inside or cook so we let some fresh air inside often. And there is a problem every time I open widnow my pump starts as temp fall beyond set temp minus histeresys. After I close the windows temp rise to the temp before windows were open with or without pump working. There is always heat stored in walls and air.

So I would like to make some kind of function to. Register temp drop and stops the pump if cold air is coming inside.

Rights now I made a function that check temp every 2 minutes and if the change is greater than 0.2C stop the pump. Works only if change is below 0.2

But this have a bug. If window is opened for longer than the temperature settles on some lower temp and calculation of old and new temp is 0 again which makes pump work. But when I close windows room temp usually gets back up where it was in minutes just from warm walls and air.

Any ideas?

Thanks

One way would be to use some of those magnetic sensors that burglar alarms use to detect open windows.

If you want to do it in software alone, check for the drop of 0.2C in 2mins. Set a flag that says the window is open. When the temperature goes up again (window closed) clear the flag.

While the flag is set, use a lower temperature threshold to trigger heating. I would want to be sure a forgotten window doesn't cause burst pipes, but I wouldn't want to be heating the atmosphere outside the house unnecessarily either.

That was one of idea to place a sensor directly on windows but that eoukd involve 3 more arduinos so everything stays wireless.

This is a good idea with flag. Something like it is working now for short period of window opening.

So I would need to set the flag and remember temp at that point in time and than reverse flag when previous temp is back again +/- 0.1C

I'll try that tomorrow.

Any more ideas are welcome.

Thanks wildbill

It occurs to me that you may want to distinguish between temperature went up and went up while heat was on. If the window is open and the temperature falls to the point where water pipe saving heat is required, you would not want to recognize any rise due to heating as a sign that the window is closed.

You may need to consider other factors too. I get a couple of extra degrees of heat in the house when the sun's shining through the windows. You may want to log what the system is doing and adjust what counts as windows opened/closed.

This is not the answer to your question, but I can see an obvious improvement to your heating controller.

Don't use hysteresis for water fed space heating. Use PWM with a cycle time of around 10 or 15 minutes.

If you use hysteresis something like this happens: Thermostat requests heat, pipes heat up, radiators heat up, room heats up. Temperature passes off point. Pipes and radiators are hot so the keep heating the room. Eventually they cool down, by which time the room is hotter then the off point. Room starts to cool. Passes the on point, which is below the off point. Radiators are cold so take a while to heat up. By the time the do the room is well below the on point. Same thing repeats.

Instead you use the set temperature to control PWM with a period of 10 to 15 minutes, the closer the room temperature is to the set temperature the more time the heat is off and less on, until just above the set temperature it is off completely.

My controller has a cycle time of 720 seconds and is fully on when the room temperature is below 1 degree below the set temperature, and fully off a small fraction of a degree* above the set temperature. This maintains the room within 0.1 degree, or sometimes within 0.2 degrees of the set temperature.

*I used a crude version of the I from PID to calculate the off point.

Alarm switch on the window triggering a relay . Relay contact in series with thermostat . Heating will then not come on whilst the window is open .

Give up smoking , you’ll save a lot more money and live longer .

I have it all ploted thanks to blynk. Here ia an example. The two marked dips in temperature (yellow green full of color). Green line is temp difference in 2min, red is boiler temperature and white is pump ON OFF marker. One dip is window opened for longer time and second dip is short period.

I see good ideas here.

Yep. I should quit smoking but....

Thanks all

Use a BME280 sensor to sense humidity as well as temperature. The outside air will have a distinct humidity change that will be easily detectable.

Look at the BME280 datasheet and they will give examples of detecting a door being opened.

I would just look at the temperature change slope you get from normal closed window operation. Then if you see a faster slope from an open window, your software ignores it.

looking at this like an industrical process control, you have a base variable, the actual space and you have a trasient upset, the open window.

Second, you have a mass that is heated, the walls, furniture, floor, ceiling, etc that will not change rapidly.

you have one condition, keeping the main mass at a temperature
and a second condition, heating the low mass air that enters.

the upset occurs with the window open, then ends when you close it.
if you look at the BTUs needed to keep the space at the desired temperature, you have one condition
if you look at the BTUs needed to address the temporary condition, you have a second condition.

also, the heating system is also a mass that has a lag time so it will start to dump heat to address the upset, and if you try to continue after the process has been restored, you will overshoot.

I like Perry's solution. address the mass as if that were one condition. ie: keep doing what you have been doing and don't try to alter the main system.

Then using the open/closed switch (my dollar store has a switch with piezo alarm.) you can jump to a second condition.
once the window is closed, you would go back to the first.

if you break it down to a BTU value, you have one steady state and one transient. your goal is to supply an equal BTU to offset the variable of the second state.

Also, since temperature has a huge time lag, there is almost no way to address the first chill or the overshooting past the closing. but ending the output when the window closes would limit the overshoot and give you a point that would allow you to focus on controlling things a bit more.

it's probably not an option, but if you controlled where the fresh air enters, you could have a chamber that tempers the air.
think of a box like a window air conditioner. put in a coil so the air that comes in is pre-heated. or a vent at the heater so the air around the heater is pushed into the space and the heater gets the colder air.

also, if you have an automatic window. you press the button, the heater responds, then the window opens, then stays open for a bit, then closes, all automatically and your total system control has a better chance at adjusting to the changes.

Thanks all.

So far the best solution would be to calculate slope. But how to do that. Is there any math function for that. I was reading about derivations for curves but that sound complicated and I think i am missing some data. I only have time and temp change.
What would be the best math to calculate slope.

In the end some positive number representing temp change up and negative number represent change down. In this period heating is off. While the slope is 0 or close to zero it should work.

There is some formula m=(y2-y1)/(x2-x1)

Electret microphones have a very good low frequency response. One application of this is a door alarm for a shop which is nowhere near the door but detects a pressure change as the actual door is opened or closed. A barometric sensor could also be used to good effect.

In a closed room, there should be few pressure changes - except when a door is opened or closed which is brief and limited. With the windows open, there will likely be a different pattern of varying pressure changes corresponding to any breeze - and if there is no breeze at all then you would not lose significant heat anyway.

Yes you can calculate a derivative from the difference between two samples. But if you watch the raw data you will probably see the temperature go up and down by 0.1 degrees several times per second, just from the analog noise in the sensor. That will make the derivative very noisy: 0.1 degrees per second is 6.0 degrees per minute, which is probably bigger than the effect you are looking for.

One solution is to make the samples further apart. Sample once per minute and then a few 0.1 errors don't make much difference to the desired signal of (maybe) 2.0 degrees per minute. An obvious improvement to this scheme is to average a few readings: take 10 readings per minute, calculate the average of those 10 and then look at the difference between two minutes.

Mathematically, it makes no difference if you do the average before or after the derivative. So you could take a reading every 6 seconds (10 per minute), calculate the difference to the previous reading and then average 20 of those together.

Morgan,
Thanks, that's a good explanation. I always found calculus difficult at best. ++Karma;

MorganS:
One solution is to make the samples further apart. Sample once per minute and then a few 0.1 errors don't make much difference to the desired signal of (maybe) 2.0 degrees per minute. An obvious improvement to this scheme is to average a few readings: take 10 readings per minute, calculate the average of those 10 and then look at the difference between two minutes.

Thanks MorganS, haven't thought about avarage it. I do calculate difference in 2min periods. Also Dht22 is quite slow so there is no really a lot of oscilation.

I have mode it now into calculating percentage difference. That is not so volatile as just subtracting new and old temp every 2min.

It works better but I still have that lower point of chart slope changing direction. When window is open I have some negative numbers than 0 than some positive numbers and than 0 again. Heating pump works only in between (- 0.4 till +0.4). I can live with 2min of work time when it changing from negative to positive over 0.

I believe the only true way is by connecting a reed switch on all windows and door in living room. Or to place thermal camera sensor and sense cold air intake

I still think there is more detail available through the BME280 humidity sensor.

I've ordered three off them from ebay. False advertising. They were all BMP models not BME and they all didn't work. That happens when you don't check the real price and order something for a dollar or two.