thogue
Posts: 131
Joined: Wed Sep 19, 2012 2:16 am

Thermostat314 - rPi/python powered Thermostat

Mon Nov 12, 2012 3:44 pm

Introduction : I started this project because of my interest in PID algorithms and Temperature control in general. This is really the first "program" I have written, so I was hoping to get some feedback before I finish and someone turns around with some advice that results it it being re-written.


Summary : Thermostat controlled via GPIO pins to replace a 24vac thermostat that controls, Heat/Cool/Fan in my house. Once I finish basic functionality I plan to expand on it, including things like, 7 day schedule, Automatic learning, Automatic return to schedule after X minutes at override, multizone sensing, etc.


Mostly Completed Parts/classes:
get_temp (python, includes sanity check and avg value from X readings, currently 10, using DHT22)
control (python, turns heat/cool/fan on off, includes safety/tracking logic that stores data in sqlite)
dbinstall (python, builds sqlite db, and populates with starting data.) currently, holding 3 tables, settings[ hot,cold,off,fanauto, override, target, safetime ], live [ temp, humid ], states [ heat, cold, fan ] which I think covers the basics of what I need to get functionality going

Un-complete parts:
server/service (python, main python service controlling the thermostat, data/settings via sqlite)
webui (python, via Flask/Bootstrap, get/update data/settings via sqlite)

Thermostat itself: (note temp sensor not attached here)
5pins to rPi, 5v, Ground, GPIO 9,10,11 ( I realize these are using some SPI pins )
9=fan -> relay
10=cool -> relay
11=hot -> relay
Relays simply switch 24vac(R) to G/Y/W (Fan/Cold/Hot)
The cool relay is wired into the fan relay, so cool cannot turn on without the fan being on. I actually have not wired the hot relay yet, as we rarely use it and wanted to start simple.
Image
Image
I am pretty sure I am going to opensource everything once I can get the prototype/program in simple working order, maybe someone else will find it cool. I really want to print up a nice board for it as well but trying to tackle one thing at a time, should be pretty simple as circuits are not very complex.


Just looking for thoughts/feedback of any kind. Thanks for looking.
-T

BlueBill
Posts: 18
Joined: Tue Jul 24, 2012 4:56 am

Re: Thermostat314 - rPi/python powered Thermostat

Wed Nov 14, 2012 5:06 am

Was considering doing the same.

Until... I bought a Radio Thermostat 3M-50 WiFi thermostat. Seems it's possible to control via a Python script, sounds like an ideal task for the Raspberry Pi.

The API is available from Radio Thermostat.

PS don't forget those relay contacts need snubbers else they'll pit over time. Transorbs are one way, another is 1K+0.1uF.
Bill

thogue
Posts: 131
Joined: Wed Sep 19, 2012 2:16 am

Re: Thermostat314 - rPi/python powered Thermostat

Wed Nov 14, 2012 10:19 pm

Yeah, I considered the radio thermostat options, seems REALLY straight forward.

I am really interested in other temperature control applications, Like kilns. I figured this would be a fun start to get the brain flowing.

BlueBill
Posts: 18
Joined: Tue Jul 24, 2012 4:56 am

Re: Thermostat314 - rPi/python powered Thermostat

Wed Nov 14, 2012 11:39 pm

Want a PID challenge? Try a Sous-vide controller.

The 3M-50 works like a charm, but could use some features that could be added with software. Anticipation would be one e.g. You've got it set for temperature at time, a top of the line stat would have it at that temperature at that time.
Bill

thogue
Posts: 131
Joined: Wed Sep 19, 2012 2:16 am

Re: Thermostat314 - rPi/python powered Thermostat

Thu Nov 15, 2012 12:16 am

Bluebill: Could you possibly dump some knowledge on me?

I surely am in need of a snubber, I just pulled a "104" cap, pretty sure its 0.1uF rated at 50v, and a 100ohm 1/4watt resister.

Am I correct that all that needs to be done is connect the resistor side goes to hot, in my case R and cap side goes to - in my case Y,W,G. and I need 1 snubber per relay ?

Currently, I am just in test mode and R + is connect to 3.3v on the Rpi, and I have 2 leds wired into G and Y (with resistors) to give me a visual representation to whats going on.

Just saw your reply, originally I was going to build some type of "smoker control" but really wanted my first project to be from the ground up, I saw the HeaterMeter has that very well covered. Learning a lot as I go with this one.

BlueBill
Posts: 18
Joined: Tue Jul 24, 2012 4:56 am

Re: Thermostat314 - rPi/python powered Thermostat

Thu Nov 15, 2012 12:49 am

The fun part is getting the temperature reliably and accurately.

Opps yes 100ohms & 0.1uF
It doesn't matter which order, it's bidirectional. Your 1/4w & 50V should be fine for your 24VAC application.
And 1 snubber per relay.
Image
Typical relay driver
Image
Bill

thogue
Posts: 131
Joined: Wed Sep 19, 2012 2:16 am

Re: Thermostat314 - rPi/python powered Thermostat

Thu Nov 15, 2012 2:39 am

Thanks BlueBill, I know there was something I was missing on that circuit, I was unsure of switching 24vac, only thing that really made me know it was safe was looking at what other thermostats were using.

ammellema
Posts: 4
Joined: Fri Aug 09, 2013 4:09 am

Re: Thermostat314 - rPi/python powered Thermostat

Fri Aug 09, 2013 5:00 am

Did you ever finish this project? I am looking to do something very similar for a research project. Phase one is pretty much what you described but with a relay for water/humidifer. Its for a controller for greenhouses. Phases one is just using a am2315... which idk how to wire up safely yet because im nervous. Would like to have 4 relays if i could figure it out.

Return to “Automation, sensing and robotics”