antonyg
Posts: 3
Joined: Tue Dec 11, 2012 7:39 pm

Re: Web enabled thermostat project

Sun Jan 06, 2013 6:15 pm

This all sounds great.

Which relay are you using? I can't make it out from the photo.

I'm no electrician, so get confused easily, but I need a relay for the same reason, which lets the PI's 5v switch 240vAC on my boiler. But previously when I asked, people said I needed transistors/resistors etc to protect the pi, but it looks like you've done it with one relay module.

Thanks

Antony

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Sun Jan 06, 2013 8:05 pm

You can find a relay module at sainsmart.com. They're really reasonably priced and worked easily with the Pi's 5v power. They also have data sheets on sainsmart.com that tell you the current draw for each channel individually and when all are on. If you are only using 1 to 4 relays I think the Pi would be able to handle them.

thelongfellow
Posts: 1
Joined: Fri Dec 28, 2012 8:40 pm

Re: Web enabled thermostat project

Sun Jan 13, 2013 2:18 am

do you have any plans for it to control the a/c as well?

i want to do this same project but have 0 programming knowledge but I would like to learn. There are a ton of things I would like to do with the Pi. So far all I have done is read from 2 ds18b20's.
I also have a sainsmart board with 4 relays but i have not messed with it yet.

Any help I can get would be beyond appreciated!! :)

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Sun Jan 13, 2013 3:56 am

thelongfellow wrote:do you have any plans for it to control the a/c as well?

i want to do this same project but have 0 programming knowledge but I would like to learn. There are a ton of things I would like to do with the Pi. So far all I have done is read from 2 ds18b20's.
I also have a sainsmart board with 4 relays but i have not messed with it yet.

Any help I can get would be beyond appreciated!! :)
I would love to incorporate all functions of an hvac system. My primary goal initially was to have a simple thermostat for the winter. You can see a post I made on the first page of this topic that has my sample code on pastebin. I need to study up a bit more on my knowledge of hvac's before I can get things going. Feel free to use the code and modify it to play around with the temperature sensor and relay.
There is more code that I haven't had opportunity to post yet, but but I do plan on it. The best thing you can do is really find yourself some sample python code from around the Web and see how things work. It's often trial and error that makes you learn the really good stuff. I have also had my fair share of people on this forum that have guided me in ways to improve how I do things with the code I was producing. It made my results just that much better.

If there are more specific questions I can answer I will be more than happy to help!

ialbizu
Posts: 36
Joined: Mon Jan 14, 2013 9:23 am
Location: Spain, Zaragoza

Re: Web enabled thermostat project

Mon Jan 14, 2013 9:52 pm

Hi OnePoint.

I have a question. First you used "Using a DS18B20 temperature sensor with a 4.7K ohm resistor tied between pin 2 and 3 on the sensor." and later you used "(http://www.ebay.ca/itm/DS18B20-temperat ... 1247wt_952)" from ebay.

Do you need to use 4.7k ohm resistor yet with the ebay board?

Thanks

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Mon Jan 14, 2013 10:01 pm

ialbizu wrote:Hi OnePoint.

I have a question. First you used "Using a DS18B20 temperature sensor with a 4.7K ohm resistor tied between pin 2 and 3 on the sensor." and later you used "(http://www.ebay.ca/itm/DS18B20-temperat ... 1247wt_952)" from ebay.

Do you need to use 4.7k ohm resistor yet with the ebay board?

Thanks
No you don't need one. It has resistors/LED in place already. So you can simply plug it in to the proper GPIO ports. They are much more convenient.

ialbizu
Posts: 36
Joined: Mon Jan 14, 2013 9:23 am
Location: Spain, Zaragoza

Re: Web enabled thermostat project

Tue Jan 15, 2013 7:23 am

Thanks OnePoint.

I try to use your project for creating a 3 zone programming thermostat for my house. I only develop the php section because yesterday I bought all the components (raspberry-p, sensor, relay board, wires). I never work with Linux and Python, but I can learn quickly.

I need to assemble 4 temperature sensors (3 for different zones hoses’ and one for the outside), Is that possible?

I show you a screenshot of the php page (sorry, in spanish)
Attachments
screenshot.2.png
screenshot.2.png (29.97 KiB) Viewed 8896 times

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Tue Jan 15, 2013 11:49 am

ialbizu wrote:Thanks OnePoint.

I try to use your project for creating a 3 zone programming thermostat for my house. I only develop the php section because yesterday I bought all the components (raspberry-p, sensor, relay board, wires). I never work with Linux and Python, but I can learn quickly.

I need to assemble 4 temperature sensors (3 for different zones hoses’ and one for the outside), Is that possible?

I show you a screenshot of the php page (sorry, in spanish)
That is impressive! I love it!
Yes it is possible. I will try to get together some code for you.

Kovi44
Posts: 4
Joined: Wed Jan 09, 2013 9:32 pm

Re: Web enabled thermostat project

Wed Jan 16, 2013 12:23 pm

I really like your UI (user interface)
Is it possible to share it(provide source code)?

I'm running similar project, where I got 12 sensors(temperature) + meteo station to get outside temperature, humidity, wind, ... Using GPIO i'm contorling the boiler and due to fact that I got also fireplace with water heating functionality, the raspberry control also water pump. If I'm using fireplace, then the boiler is used just in case of low temperature of water in heating system. The system is built for summer house usage.

The whole system use:
perl, php, mysql, rrd, apache
HW: raspi, relay board, ciseso xrf, ciseco xrf realy board, 1-wire temperature sensors, ciseco wireless temperature sensors

Attached: User Interface pictures
sample_1.JPG
sample_1.JPG (58.73 KiB) Viewed 8850 times
sample_2.JPG
sample_2.JPG (36.44 KiB) Viewed 8850 times
sample_3.JPG
sample_3.JPG (51.67 KiB) Viewed 8850 times
I'm able to share my source code, but i'm not sure if it's usable (all comments in slovak language) and also my scripts are not so professional(i got really limited programing skills)

ialbizu
Posts: 36
Joined: Mon Jan 14, 2013 9:23 am
Location: Spain, Zaragoza

Re: Web enabled thermostat project

Wed Jan 16, 2013 1:52 pm

Yes of course. But, a week ago, I never heared anything about raspberry-pi, Linux, Python. I bought a rasp-pi this monday, and only I've writed a php page for saving the programation in a file. Here you have the code.

Code: Select all

<?php
$pipe = '|';

if(isset($_POST["tm_c_1"])) {
	$tm_c_1 = $_POST["tm_c_1"];
	$tm_m_1 = $_POST["tm_m_1"];
	$ti_ini_1_1 = $_POST["ti_ini_1_1"];
	$ti_end_1_1 = $_POST["ti_end_1_1"];
	$ti_ini_1_2 = $_POST["ti_ini_1_2"];
	$ti_end_1_2 = $_POST["ti_end_1_2"];
	
	$tm_c_2 = $_POST["tm_c_2"];
	$tm_m_2 = $_POST["tm_m_2"];
	$ti_ini_2_1 = $_POST["ti_ini_2_1"];
	$ti_end_2_1 = $_POST["ti_end_2_1"];
	$ti_ini_2_2 = $_POST["ti_ini_2_2"];
	$ti_end_2_2 = $_POST["ti_end_2_2"];
	
	$tm_c_3 = $_POST["tm_c_3"];
	$tm_m_3 = $_POST["tm_m_3"];
	$ti_ini_3_1 = $_POST["ti_ini_3_1"];
	$ti_end_3_1 = $_POST["ti_end_3_1"];
	$ti_ini_3_2 = $_POST["ti_ini_3_2"];
	$ti_end_3_2 = $_POST["ti_end_3_2"];
	
	$fp = fopen("D:/root/micasa/data/php_doc.txt", "w+");
	$savestring =
		$tm_c_1.$pipe.
		$tm_m_1.$pipe.
		$ti_ini_1_1.$pipe.
		$ti_end_1_1.$pipe.
		$ti_ini_1_2.$pipe.
		$ti_end_1_2.$pipe.
		
		$tm_c_2.$pipe.
		$tm_m_2.$pipe.
		$ti_ini_2_1.$pipe.
		$ti_end_2_1.$pipe.
		$ti_ini_2_2.$pipe.
		$ti_end_2_2.$pipe.
		
		$tm_c_3.$pipe.
		$tm_m_3.$pipe.
		$ti_ini_3_1.$pipe.
		$ti_end_3_1.$pipe.
		$ti_ini_3_2.$pipe.
		$ti_end_3_2;
	fwrite($fp, $savestring);
	fclose($fp);
}
else {
	$txt = file_get_contents('D:root/micasa/data/php_doc.txt');
	$sep = explode($pipe,$txt);
	$tm_c_1 = $sep[0];
	$tm_m_1 = $sep[1];
	$ti_ini_1_1 = $sep[2];
	$ti_end_1_1 = $sep[3];
	$ti_ini_1_2 = $sep[4];
	$ti_end_1_2 = $sep[5];
	
	$tm_c_2 = $sep[6];
	$tm_m_2 = $sep[7];
	$ti_ini_2_1 = $sep[8];
	$ti_end_2_1 = $sep[9];
	$ti_ini_2_2 = $sep[10];
	$ti_end_2_2 = $sep[11];
	
	$tm_c_3 = $sep[12];
	$tm_m_3 = $sep[13];
	$ti_ini_3_1 = $sep[14];
	$ti_end_3_1 = $sep[15];
	$ti_ini_3_2 = $sep[16];
	$ti_end_3_2 = $sep[17];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mi Casa Calefacci&oacute;n</title>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"
		media="screen">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet"
		type="text/css" media="screen">
</head>
<body> 
<div class="container" style="max-width: 700px;"> <br> 
	<div class="navbar"> 
		<div class="navbar-inner"> 
			<ul class="nav"> 
				<?php $active = basename(__FILE__, ".php"); include ('nav.php'); ?>
			</ul> 
		</div> 
	</div> 
	<div class="row-fluid"> 
		<div class="span12"> 
			<div class="hero-unit" style='background: url("img/fondo_ini.jpg") no-repeat scroll 0 0 #EEEEEE; padding:10px;'> 
				<div class="row-fluid"> 
					<div class="span6"> 
						<h1 style="color:#FFFFFF;vertical-align: bottom;">MiCasa</h1> 
					</div>
					<div class="offset10"> 
						<img src="img/rasp.png"> 
					</div>
				</div> 
			</div> 
		</div>  
	<div class="row-fluid"> 
		<div class="span12 navbar-inner"> 
			<h3 align="center">Calefacci&oacute;n</h3>
		</div> 
	</div> 
	<br>
	<form name="termostat" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
	<div class="row-fluid"> 
		<!--ini 3 columnas--> 
		<div class="span4 thumbnail"> 
			<p class="lead">Zona 1 Planta Baja </p> 
			Temperatura actual <span class="lead">19.0&ordm;C
			</span> <span class="label label-important">Calentando</span>
			<hr> 
			<select name="tm_c_1" class="input-small" id="tm_c_1"> 
				<?php $selected = $tm_c_1; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; confort
			<select name="tm_m_1" class="input-small" id="tm_m_1"> 
				<?php $selected = $tm_m_1; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; Mantenimiento
			<hr>
			Lunes a Viernes<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_1_1" class="input-small" id="ti_ini_1_1"> 
				<?php $selected = $ti_ini_1_1; include ('sel_time.php'); ?> 
			</select> </div>
			<div class="input-prepend"><span class="add-on">Off</span>
			<select name="ti_end_1_1" class="input-small" id="ti_end_1_1"> 
				<?php $selected = $ti_end_1_1; include ('sel_time.php'); ?> 
			</select> </div>
			Fines de semana<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_1_2" class="input-small" id="ti_ini_1_2"> 
				<?php $selected = $ti_ini_1_2; include ('sel_time.php'); ?> 
			</select> </div>
			<div class="input-prepend"><span class="add-on">Off</span>
			<select name="ti_end_1_2" class="input-small" id="ti_end_1_2">  
				<?php $selected = $ti_end_1_2; include ('sel_time.php'); ?> 
			</select> </div>
			<hr> 
			<input class="btn btn-small btn-primary pull-right" type="submit" value="Guardar"> 
			<p><img src="https://chart.googleapis.com/chart?cht=ls&chxt=y&chxt=x,y&chxl=0:|manana|tarde|noche|1:||17|||20|&chs=200x125&chds=16,21&chd=t:17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,20,20,20|20,20,20,20,20,20,20,20,20,17,17,17,17,17,17,17,17,17,17,20,20,20,20,20&chco=3072F3,ff0000&chls=3,2,5|2,2,2&chdl=Programa|Real&chdlp=t"> </p> 
		</div> 
		<div class="span4 thumbnail"> 
			<p class="lead">Zona 2 Habitaciones </p> 
			Temperatura actual <span class="lead">19.0&ordm;C</span> 
			</span> <span class="label label-info">Apagado</span>
			<hr> 
			<select name="tm_c_2" class="input-small" id="tm_c_2">  
				<?php $selected = $tm_c_2; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; confort
			<select name="tm_m_2" class="input-small" id="tm_m_2"> 
				<?php $selected = $tm_m_2; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; Mantenimiento
			<hr> 
			Lunes a Viernes<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_2_1" class="input-small" id="ti_ini_2_1"> 
				<?php $selected = $ti_ini_2_1; include ('sel_time.php'); ?> 
			</select></div>
			<div class="input-prepend"><span class="add-on">Off</span> 
			<select name="ti_end_2_1" class="input-small" id="ti_end_2_1"> 
				<?php $selected = $ti_end_2_1; include ('sel_time.php'); ?> 
			</select> </div>
			Fines de semana<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_2_2" class="input-small" id="ti_ini_2_2"> 
				<?php $selected = $ti_ini_2_2; include ('sel_time.php'); ?> 
			</select></div>
			<div class="input-prepend"><span class="add-on">Off</span>
			<select name="ti_end_2_2" class="input-small" id="ti_end_2_2"> 
				<?php $selected = $ti_end_2_2; include ('sel_time.php'); ?> 
			</select> </div>
			<hr> 
			<p> 
				<input class="btn btn-small btn-primary pull-right" type="submit" value="Guardar"> 
			</p> 
			<p><img src="https://chart.googleapis.com/chart?cht=ls&chxt=y&chxt=x,y&chxl=0:|manana|tarde|noche|1:||17|||20|&chs=200x125&chds=16,21&chd=t:17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,20,20,20|20,20,20,20,20,20,20,20,20,17,17,17,17,17,17,17,17,17,17,20,20,20,20,20&chco=3072F3,ff0000&chls=3,2,5|2,2,2&chdl=Programa|Real&chdlp=t"> </p> 
		</div> 
		<div class="span4 thumbnail"> 
			<p class="lead">Zona 3 Despacho </p> 
			Temperatura actual <span class="lead">19.0&ordm;C</span>
			</span> <span class="label label-important">Calentando</span>
			<hr> 
			<select name="tm_c_3" class="input-small" id="tm_c_3"> 
				<?php $selected = $tm_c_3; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; confort
			<select name="tm_m_3" class="input-small" id="tm_m_3"> 
				<?php $selected = $tm_m_3; include ('sel_tem.php'); ?> 
			</select> 
			T&ordf; Mantenimiento
			<hr> 
			Lunes a Viernes<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_3_1" class="input-small" id="ti_ini_3_1"> 
				<?php $selected = $ti_ini_3_1; include ('sel_time.php'); ?> 
			</select> </div>
			<div class="input-prepend"><span class="add-on">Off</span>
			<select name="ti_end_3_1" class="input-small" id="ti_end_3_1"> 
				<?php $selected = $ti_end_3_1; include ('sel_time.php'); ?> 
			</select> </div>
			Fines de semana<br>
			<div class="input-prepend"><span class="add-on">On</span>
			<select name="ti_ini_3_2" class="input-small" id="ti_ini_3_2"> 
				<?php $selected = $ti_ini_3_2; include ('sel_time.php'); ?> 
			</select> </div>
			<div class="input-prepend"><span class="add-on">Off</span>
			<select name="ti_end_3_2" class="input-small" id="ti_end_3_2"> 
				<?php $selected = $ti_end_3_2; include ('sel_time.php'); ?> 
			</select> </div>
			
			<hr> 
			<p> 
				<input class="btn btn-small btn-primary pull-right" type="submit" value="Guardar"> 
			</p> 
			<p><img src="https://chart.googleapis.com/chart?cht=ls&chxt=y&chxt=x,y&chxl=0:|manana|tarde|noche|1:||17|||20|&chs=200x125&chds=16,21&chd=t:17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,20,20,20|20,20,20,20,20,20,20,20,20,17,17,17,17,17,17,17,17,17,17,20,20,20,20,20&chco=3072F3,ff0000&chls=3,2,5|2,2,2&chdl=Programa|Real&chdlp=t"></p> 
		</div> 
	</div> 
	<!--fin 3 columnas--> 
	</form> 
	<div class="row-fluid"> 
		<div class="span12  navbar-inner"> 
			<h3 align="center">Exteriror</h3> 
		</div> 
	</div> 
	<br>
	<div class="row-fluid"> 
		<div class="span6"> 
			<p>Temperatura exterior <span class="lead">11&ordm;C</span>
</p>
			<p>&nbsp;	    	</p>
			<p><img src="https://chart.googleapis.com/chart?cht=ls&chxt=y&chxt=x,y&chxl=0:|manana|tarde|noche|1:||17|||20|&chs=300x150&chds=16,21&chd=t:17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,20,20,20|20,20,20,20,20,20,20,20,20,17,17,17,17,17,17,17,17,17,17,20,20,20,20,20&chco=3072F3,ff0000&chls=3,2,5|2,2,2&chdl=Programa|Real&chdlp=t"> </p>
		</div> 
		<div class="span6"> 
			<div id="c_cf4a808c08fd77c7d7ddcd94a67ced57" class="completo"></div> 
			<script type="text/javascript" src="http://www.eltiempo.es/widget/widget_loader/cf4a808c08fd77c7d7ddcd94a67ced57"></script> 
		</div>
		<div class="span6"> 
			<img width="256" height="225" src="http://www.sat24.com/image.ashx?country=sp&type=loop&sat=ir" id="Image5_img" alt="Satélite Meteosat" style="visibility: visible;">
		</div> 
	</div> 
	<br> 
	<br> 
	<div class="row-fluid"> 
		<div class="span12"> <footer><small> <span class="pull-right">Copyright © 2013
						Bases & Datos</span></small> </footer> </div> 
	</div> 
</div> 
</body>
</html>

ialbizu
Posts: 36
Joined: Mon Jan 14, 2013 9:23 am
Location: Spain, Zaragoza

Re: Web enabled thermostat project

Wed Jan 16, 2013 2:02 pm

Kovi44 wrote: I'm running similar project, where I got 12 sensors(temperature) + meteo station to get outside temperature, humidity, wind, ... Using GPIO i'm contorling the boiler and due to fact that I got also fireplace with water heating functionality, the raspberry control also water pump. If I'm using fireplace, then the boiler is used just in case of low temperature of water in heating system. The system is built for summer house usage.
How many inputs and output can we use with one ras-pi? I want to manage my sprinkler (5 ways), some ligths, 5 zone thermostate, ¿one anemometer?, are there some pins for out and somes for IN?, or not.

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Wed Jan 16, 2013 5:57 pm

ialbizu wrote:
Kovi44 wrote: I'm running similar project, where I got 12 sensors(temperature) + meteo station to get outside temperature, humidity, wind, ... Using GPIO i'm contorling the boiler and due to fact that I got also fireplace with water heating functionality, the raspberry control also water pump. If I'm using fireplace, then the boiler is used just in case of low temperature of water in heating system. The system is built for summer house usage.
How many inputs and output can we use with one ras-pi? I want to manage my sprinkler (5 ways), some ligths, 5 zone thermostate, ¿one anemometer?, are there some pins for out and somes for IN?, or not.
If you have a look at the following GPIO layout, each pin in green can be used as inputs/outputs. You can define through your programming if each GPIO is an input or output. Your limitation may be related to the current draw for each pin.

Image

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Tue Feb 05, 2013 11:30 pm

Hi Guys,

I do apologize for not getting back to many of your requests sooner. I'm pretty busy with work and family, so not much extra time to spend revising the thermostat. I have had an enormous number of requests for all the web code etc. So here it is!

https://www.dropbox.com/s/krq6z6hw5nz9f ... mostat.zip

You will need a web server with php enabled on your pi. You will likely also need to change many of the permissions to suit your setup. I hope this helps. If you have questions I will do my best to answer them. I know some of you have requested new features and I will do my best to get some time to implement them.
The above file includes the unedited version of my thermostat python script as well as the web content.

Thanks

David

johal
Posts: 3
Joined: Wed Feb 13, 2013 2:28 pm

Re: Web enabled thermostat project

Wed Feb 13, 2013 2:32 pm

Hi,

I have no idea about electronics. But i am very interested in sensing my sump pump failure. So is there a way to get digram of electrical circuit? Or something that shows how to wire everything.

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Wed Feb 13, 2013 2:50 pm

johal wrote:Hi,

I have no idea about electronics. But i am very interested in sensing my sump pump failure. So is there a way to get digram of electrical circuit? Or something that shows how to wire everything.
This was actually my next project for the Pi. I should be able to get some code together for you. Maybe over the next couple of days.

MorePiPlease
Posts: 21
Joined: Mon Nov 05, 2012 1:59 pm

Re: Web enabled thermostat project

Sat Mar 02, 2013 1:31 am

This is great! I am using LAMP to teach my students database this semester and am going to do an open source thermostat program as our final project. I started searching around and I found this HotPi project started by David. Will keep you updated on our progress.

realtek
Posts: 34
Joined: Wed Jan 09, 2013 3:16 pm

Re: Web enabled thermostat project

Tue Mar 05, 2013 6:02 pm

Hi,

What relays did you use for this?

Thanks,

Nick

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Tue Mar 05, 2013 6:20 pm

realtek wrote:Hi,

What relays did you use for this?

Thanks,

Nick
I found mine on ebay. I used a 5volt relay board for an arduino.

Or you can also find them at sainsmart.com.
http://www.sainsmart.com/4-channel-5v-r ... logic.html

tycen
Posts: 9
Joined: Wed Oct 24, 2012 6:12 pm
Location: Seattle, WA

Re: Web enabled thermostat project

Tue Mar 05, 2013 6:36 pm

For my project I used SainSmart relays also (got them for a little more money but with Prime shipping on Amazon). I'm sure most people on this forum already know this about relays, but I didn't at the time and have since learned so I figure I'll post it for others. The mechanical SainSmart relays are ACTIVE LOW. What this means (in non-technical terms) is that you need a high signal from the pi GPIO pin to turn the relay "off" (open the circuit). So, what this translated to me was that anytime I rebooted my pi, there was a brief moment when the signal on that GPIO pin dropped to LOW which triggered the relay to close the circuit. I am using my relays to just do a momentary push on a button - so for me this changed the state of my stove (pellet stove).

I'm currently schooling myself on how transistors and opto-isolators work to use those instead of the relay (much cheaper!) - but in the meantime the best way for me to get around the reboot limitation was to buy the SainSmart Solid State relay: http://www.amzn.com/dp/B0079WI2ZC. This relay is ACTIVE HIGH - so it needs a high signal to close the circuit. Which means that a reboot of the pi (and the pins dropping to LOW) doesn't trigger the relay (because the pins are already sitting at low).

I'm sure there are applications for the way the mechanical relay works - I just know for my project it was a problem.

ultirik
Posts: 1
Joined: Sat Mar 23, 2013 1:02 am

Re: Web enabled thermostat project

Sat Mar 23, 2013 1:12 am

I don't know if it helps but I've been working on a similar project. I had a wireless thermostat control already on a gas combi boiler. I've now set it up so a Pi to control the RF unit taken from the thermostat. This allows me to control the central heating system through a web interface and through buttons/screen attached to the pi.
An overview of the system and the python source code can be found here:
https://docs.google.com/folder/d/0B-hZe ... sp=sharing

Pictures are at the end of the "PiStat Overview" file.

The web interface just uses a similar form page to what has been discussed before.

I'd definitely recommend giving it a go. I didn't have much experience at all with electronics before and had great fun learning as I went along.

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

Re: Web enabled thermostat project

Mon Mar 25, 2013 12:36 am

I just wanted to say thanks to the OP for posting his hotPi code as a starter for other projects -

This is my hardware setup:
4 Way Mains Rated Relay Controller
Temp Sensors as per this thread (only added one so far, will add others shortly)
Couple of manual override switches (haven't put these into the mix so far) and LED indicators

The 4 way relay controls:
HW Call For Heat Relay
CH Call For Heat Relay
Pump Relay
Boiler Relay

I've made a few changes to the code:
- I can control the request for Hot Water as well as Central Heating from the web page now.
- Classed out the relay requests so make it a little more modular, easier to port to other controllers
- Thrown in a lot more debugging support (cos I ssh into my rPi so need a improved remote debugging solution! :p)

If anyones interested I'll bang the code up to github for people to look at.

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

Re: Web enabled thermostat project

Mon Mar 25, 2013 11:33 pm

Just a quick update - Using SiriProxy and some more custom coding - Siri is now responding to the heating commands:

Whats the temperature inside?
Turn the hot water on/off?
Set the thermostat to xx degrees
Whats the status of the heating/boiler?

Works really nicely with the hotPi code as well!

onepoint21
Posts: 42
Joined: Thu Nov 22, 2012 12:13 am

Re: Web enabled thermostat project

Mon Mar 25, 2013 11:56 pm

You guys are blowing my mind. I wish I had more time to dedicate to programming this. But you've all done some spectacular work. My hat is off to you.

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

Re: Web enabled thermostat project

Tue Mar 26, 2013 1:36 am

I'll get some videos/pics up of the setup as it stands at the moment in the next couple of days - although my setup is all breadboarded.

I'd also like to split the methods out more, basically so I can cron the scripts to ultimately allow for a 7 day timer system instead of relying on loops/sleeps for the main tasks, leave the loops for polling the switches and also push button override but we'll see - times running away with me again!

raphex
Posts: 13
Joined: Fri Aug 30, 2013 7:27 pm

Re: Web enabled thermostat project

Sun Nov 03, 2013 7:03 pm

Bonsoir,

I have adapted your code for my regulation (relay is replaced by a servo motor that drive the air trap of my DDG heater)
one problem is remaining, the temp setup performed by the web interface doesbn't work ... i have'nt modifiied your code except the path ....

j'ai adapté vos source pour ma regulation (à la place du relay j'ai un servo moteur qui ouvre et ferme la trappe à air de mon insert chauffage central DDG)
il me reste un soucis, le parametrage de la temperature de consigne via l'inteface web ne fonctionne pas ...
j'ai rien modifié par rapport à votre code pour ecrire dans le fichier si ce n'est que le chemin ...

Merci

Return to “Automation, sensing and robotics”