mgrzemow
Posts: 3
Joined: Tue Oct 09, 2018 1:28 pm

Yet Another Raspberry Thermostat

Tue Oct 09, 2018 2:20 pm

YART - at least the acronym looks good. ;-)

I am looking to build a weekly thermostat for my heater at home. I would be mostly grateful for any comments or suggestions. I have looked at many projects out there, but it seems that none of them meet my requirements. I have probably missed some, so maybe I am wrong.

My requirements are as follows:
- reliable - this I think eliminates all the fancy big frameworks. I installed Cayenne - and it was so erratic and unreliable that I gave up on it. Domoticz might be ok, but it doesn't have a visual weekly editor, or does it?
- rather simple - one sensor and one heating device being controlled with on/off logic
- remote access for monitoring and control from the internet
- all the logic locally on the raspberry, so that if the internet goes down it will continue to work

I have a thermometer:
https://botland.com.pl/czujniki-tempera ... zarny.html
And a relay:
https://botland.com.pl/przekazniki/1997 ... ka-5v.html
I have actually put it all together with domoticz:
https://www.youtube.com/watch?v=WuNDU2ow-SM

So, the idea is to drive the whole thing from a google calendar.
1. I would create a plan of heating temperatures as events in a calendar.
2. I would use IFTTT to copy those to the raspberry as text files via dropbox or similar. I would support only recurring weekly events and maybe some special ones (for temporary program override).
3. On the raspberry there would be a script running once a minute, which would:
- check if there are any changes coming from the calendar, and based on that
- add or delete entries to the cron table for changing the set temperature
4. The above cron entries would just run another script, which would change the set temperature in a text file.
5. Another script would act as a simple thermostat, being executed say every 30s.
6. I would have to implement some additionat functionality for turning the whole thing on and off, etc.
7. I would restart the raspberry once a day to ensure OS stability.

For monitoring I would just use a standard tool such as domoticz.

Any ideas? Is this a good or bad idea? Stupid? Dangerous? Already done?

nostradomus
Posts: 1
Joined: Tue Jan 31, 2017 7:10 pm

Re: Yet Another Raspberry Thermostat

Wed Oct 10, 2018 1:37 pm

Hi @mgrzemow,

here’s a short description on how I replaced the old-fashioned home thermostat by an RPI :
  • I connected a DS18b20 temperature probe to the pi. There ’s a good tutorial on adafruit to do so (Lesson 11 : measure temperature with your Raspberry Pi using the DS18B20). Pay attention on where you install the probe in the room (height from floor, not in an air-stream…). It is the same chip as the one you bought, however, I used the water-proof version. It has a metal cap, and as such a more stable read-out.
  • I connected a relay on one of the outputs (with a transistor, resistor and diode) to connect to the two wires of the original thermostat. Your module should do the job as well.
  • I connected a power bank between the pi and the power supply. It serves as a UPS. I noticed that you were having questions on reliability. My system is now already showing a linux uptime of more then 3 years !
  • All code has been built in simple python scripts.
  • The temperature logging and weekly schedules are stored in a mysql-database
  • The web-interface is written in the python and runs in the pi’s built-in apache cgi-bin. However, the python scripts just generate some basic webpages with minimal css and javascript. Btw, they are built to fit on a phone screen.
You see, as the abbreviation says, KISS (keep it simple s...).

Below a couple of screenshots from the interface which I built :

Image

Image

I hope all of this gives you plenty of ideas to roll-your-own ;-)

As the pi is more then powerful enough, I also added a couple of other options, like a portal for other domotics, such as remote control for lights, a web-radio, a weather station,...

Image

Good luck !

morticiaskeeper
Posts: 68
Joined: Mon Aug 27, 2012 6:05 pm

Re: Yet Another Raspberry Thermostat

Thu Oct 11, 2018 6:36 pm

Before replacing my thermostat, I wanted some data to see what the temperatures were like in my house.

Each room has a pi zero W with a DS18B20 sensor, the kitchen pi also has an outside sensor and the living room aquarium already had an ambient sensor. Each pi runs a python script every half hour, sending the temperature to a central LAMP server, also a pi zero.

All data is stored in a SQL table and viewable via php pages using Google charts.

After a year of logging data, I've come to the conclusion that the existing thermostat does a very good job.

https://drive.google.com/file/d/1Tw0J0s ... p=drivesdk

pfletch101
Posts: 215
Joined: Sat Feb 24, 2018 4:09 am

Re: Yet Another Raspberry Thermostat

Fri Oct 12, 2018 3:53 pm

morticiaskeeper wrote:
Thu Oct 11, 2018 6:36 pm
Before replacing my thermostat, I wanted some data to see what the temperatures were like in my house.

Each room has a pi zero W with a DS18B20 sensor, the kitchen pi also has an outside sensor and the living room aquarium already had an ambient sensor. Each pi runs a python script every half hour, sending the temperature to a central LAMP server, also a pi zero.

All data is stored in a SQL table and viewable via php pages using Google charts.

After a year of logging data, I've come to the conclusion that the existing thermostat does a very good job.

https://drive.google.com/file/d/1Tw0J0s ... p=drivesdk
The month you show has the outside temperature varying within a very narrow range - I would expect a very simple thermostat to do well under those circumstances. Living somewhere where the outside temperature is frequently in the 80s (F) and sometimes in the 90s in the summer, falling to single digits (again F) or sometimes negative values in the winter, I find the additional control given by a programmable WiFi-enabled thermostat very worthwhile. If I had been 'into' Pis when I started using high-end programmable thermostats, I might well have followed that route.

morticiaskeeper
Posts: 68
Joined: Mon Aug 27, 2012 6:05 pm

Re: Yet Another Raspberry Thermostat

Fri Oct 12, 2018 5:56 pm

That screenshot was a single day. Week and month graphs show more variance.
https://prnt.sc/l5dwax
https://prnt.sc/l5dwn4

pfletch101
Posts: 215
Joined: Sat Feb 24, 2018 4:09 am

Re: Yet Another Raspberry Thermostat

Fri Oct 12, 2018 7:40 pm

morticiaskeeper wrote:
Fri Oct 12, 2018 5:56 pm
That screenshot was a single day. Week and month graphs show more variance.
https://prnt.sc/l5dwax
https://prnt.sc/l5dwn4
Indeed, they do, but they also show more diurnal and longer-term variance of indoor temperatures than I would want. For comparison, see the attached screenshots of my system's display of the winter and summer temperature variations over a month at my house. My display software only shows two simultaneous traces (and I only track temperatures in two indoor locations). Most of the variance that is visible actually reflects my controlling temperature to maximize comfort and minimize cost, and I am only showing the downstairs temperature here, but the upstairs variance is only a little more.
Attachments
June.JPG
June.JPG (123.67 KiB) Viewed 728 times
January.JPG
January.JPG (81.14 KiB) Viewed 728 times

maurice1
Posts: 34
Joined: Tue Mar 05, 2013 8:55 am
Location: Dublin

Re: Yet Another Raspberry Thermostat

Wed Oct 17, 2018 4:29 pm

For Logging only,
I used Anita2r (Member here) instructions.
They were easy to follow and my 18 x DS18B20 have been running fine for about 4 years

Everything is done on the pi
About 10th post down
viewtopic.php?t=26466

mgrzemow
Posts: 3
Joined: Tue Oct 09, 2018 1:28 pm

Re: Yet Another Raspberry Thermostat

Tue Oct 23, 2018 11:28 pm

Firstly, THANKS YOU ALL for your comments. They were very inspirational.

This is what I have done so far.

I have the following scripts:
1. mymail.py for sending emails via gmail - it will retry if anything goes wrong and log all the issues in detail
2. init.py where I keep all the data and settings.
3. termostat.py The actual thermostat, which is run every minute
4. t.py A script containing only the temperature being set (single line eg "T=21")
5. settemp.py A script which is run in cron and which overwrites the temperature in 4.

You can have a look at the scripts here:
https://sourceforge.net/p/yarth/code/ci/master/tree/

I tried to log everything in detail and to handle as many exceptions as I could find.

Everything seems to be working fine. I will now try to integrate the cron table with google calendar.

BTW: Project changed its name to yarth. yart was already taken.

mgrzemow
Posts: 3
Joined: Tue Oct 09, 2018 1:28 pm

Re: Yet Another Raspberry Thermostat

Wed Oct 24, 2018 9:16 pm

Here is a temperature chart for one day. You can see that it is not cold enough for the room to cool down below the set temperature in the night. Overshoots are depending if the logging software captures the peak or not.
Attachments
temperatura.jpg
temperatura.jpg (225.94 KiB) Viewed 523 times

Return to “Automation, sensing and robotics”