Smart Thermostat

34 posts   Page 1 of 2   1, 2
by Gio » Fri May 25, 2012 2:32 pm

Do you think it would be possible to add the sensors and controls to the Raspi for it work as a smart thermostat.
Like the Nest or ecobee
I obviously would require a thermostat and control switch to turn the central heating on and off, and possibly a motion detector to monitor when people leave/enter their home.
Are these sort of items available to connect to the GPIO ?

Then the really hard bit for me, I would need to create the software to control it all (but that's why I ordered a Raspi, to challenge myself).
Although some might think it's easy, I haven't done any real programming in 20 odd years.

User avatar
Posts: 7
Joined: Fri May 25, 2012 2:28 pm
by rurwin » Fri May 25, 2012 4:55 pm
Yes it's possible. It might even be something I'd be interested in doing. But don't think it is a RaspPi plus a few pence-worth of components. The sensors have to be interfaced to the RaspPi, which is either fiddly if you build it or moderately expensive if you buy it. Then you multiply that by the number of rooms you are monitoring. Switching the boiler on and off is just a relay, it needs some electronics too, but not much. The expensive bit will be interfacing thermistors (which are variable resistors) to the RaspPi (which doesn't have any analogue inputs) with a long wire (some rooms may need over ten metres of cable,) or a wireless link.
User avatar
Posts: 2887
Joined: Mon Jan 09, 2012 3:16 pm
by domesday » Sat May 26, 2012 3:37 pm
You could always get ready made ones from
Posts: 256
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK
by Hairlocks » Sat May 26, 2012 9:12 pm
I hope to do a similar thing for my house. but I am going to use a ardiuno for the acutally grunt work as it is more than powerfull enough an more suit the need. 1-wire sensor are what you need for the temperture side of things, can't remember the model number from memory though. the arduino has a library ready to use.

I may use the RPi as a central controll / watchdog of it all.
Posts: 38
Joined: Sat Feb 11, 2012 9:35 pm
by davidmam » Thu May 31, 2012 1:32 pm
The 1-wire sensors work very well with arduino and with the RPi. They are cheap - effectively you are looking at the cost of 2 or 4 core cabling to the relevant places.

I'm interested in the schematics for controlling relays to replace a normal controller clock.
Posts: 98
Joined: Tue Dec 06, 2011 4:13 pm
by bredman » Thu May 31, 2012 1:40 pm
Here is an example USB-connected board which supports relays and connections to temperature sensors.

This particular model has 110v relays, but this is only an example of what is available.
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by Gio » Thu May 31, 2012 2:23 pm
Thanks for the replies.
I have seen a 1 wire thermostat on ebay for £1.95, but will need to research the cost of the other parts, I don't wont to spend too much money on this, so if they are expensive I will shelf the idea.
I think I will buy a couple of the thermostats and have a play with them first then move onto controlling the central heating.
User avatar
Posts: 7
Joined: Fri May 25, 2012 2:28 pm
by abishur » Thu May 31, 2012 3:11 pm
It would be nice to see a wiring diagram pop up sooner or later on how to make your own relay board with all the appropriate circuit protection and GPIO voltage boosting to trip said relay so projects like these could DIY instead of shell out 50 for a pre-assembled :-)
Dear forum: Play nice ;-)
User avatar
Posts: 4221
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by Hairlocks » Fri Jun 01, 2012 9:08 pm
I have just order myself some more 1-wire thermostats DS18B20 at £7.52 for 10 inc free postage. From a website in hong kong with mixed reviews so will wait for them to turn up and I can compare them to the ones I bough from farnell a while ago.

I have also bought some DHT11 which humidity as well as temperture at about £10 for 10. These are almost as good as 1-wire (e.g. talk in binary) but cannot be addressed seperately so only 1 on each IO pin.

Just before I orderd I spotted a 4 relay board, with 4 x 250V 10A relays for £4 so I bought 2 of those to try I will do some googling when I have it to see if it is correctly isolating the 250v from the 5v. It had arduino listed in is description.
Posts: 38
Joined: Sat Feb 11, 2012 9:35 pm
by fruitloaf » Sat Jun 02, 2012 10:00 pm
Let us know how you get on with those 1-wire thermistors as I'm interested in doing something similar.

Do you know if the cable to them has to be twisted pair or can I mount them in place of an existing thermostat and mount the Pi at the boiler programmer using the existing cables in the wall.
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by Hairlocks » Sat Jun 02, 2012 10:06 pm
It does not need to be twisted pair. I believe it is best to use 3 wire is possible, ground, 5v and data. although the can be powered from the data line in puts more limitations on the network.

The ones I have bought are without VAT, which I need to pay before they will be delivered. DHL website currently broken,
Posts: 38
Joined: Sat Feb 11, 2012 9:35 pm
by Lorian » Sat Jun 02, 2012 11:02 pm
If they are coming dhl expect a handling fee too. you need to make sure your low cost .hk purchases arrive by post.

I have some spare temperature sensors not far away. if it rains tomorrow I might experiment.
Posts: 112
Joined: Sun Mar 11, 2012 10:09 am
by chrisrhoden » Sun Jul 15, 2012 10:23 pm
Please, can anyone point me at some drivers for the 1-wire sensors? Lots of people keep mentioning that they're available, but I have only found them for arduino. I would love to get some sense of how they might be used.
Posts: 3
Joined: Wed Jun 20, 2012 2:56 am
by teicors » Fri Jul 27, 2012 10:09 am
I'm looking too for a schematics for the 1wire bus.
I own few DS18S20 but I'm not able to find anything about pins of RPi used for data, modules to loa, etc. :(

Posts: 4
Joined: Thu Jul 26, 2012 11:13 pm
by bateau62 » Fri Jul 27, 2012 4:15 pm
There is a large amount of documentation on the maxim website. Look at the application notes, they are relatively good, but you can find many other sources around. Search for onewire or 1wire. By the way I'm about to assemble my self developed raspi stacking 1wire driver + GPIO board based on a I2C driver (if time permits). Will post more info about that.
Posts: 3
Joined: Sun May 20, 2012 1:50 pm
by teicors » Fri Jul 27, 2012 5:33 pm
Hi bateau62,
it's no easy as it seems :)
I wondering to use the 1wire on the latest kernel from the git.
At last resort (to undesrtand if i'm wrong or not) I followed the directions found at viewtopic.php?f=44&t=6649 and my 1wire works !!

root@raspberrypi:~# cat /sys/bus/w1/drivers/w1_master_driver/w1_bus_master1/28-0000039745f6/w1_slave
c4 01 4b 46 7f ff 0c 10 3b : crc=3b YES
c4 01 4b 46 7f ff 0c 10 3b t=28250

so at the moment I found a solution, not very elegant, but working. :) and I still waitng for a patch to apply at the official kernel.

Posts: 4
Joined: Thu Jul 26, 2012 11:13 pm
by eshatohhin » Mon Jul 30, 2012 7:30 pm
Hairlocks, have you had any success with DHT11 sensor?
I've tried the kernel patch for Dallas 1-wire interface (viewtopic.php?p=86172) but the device isn't getting detected... some say that they are not 1-wire really, but have some own sort of protocol..
User avatar
Posts: 11
Joined: Tue May 15, 2012 12:27 pm
Location: Estonia
by teicors » Thu Aug 02, 2012 9:27 am
eshatohhin wrote:Hairlocks, have you had any success with DHT11 sensor?
I've tried the kernel patch for Dallas 1-wire interface (viewtopic.php?p=86172) but the device isn't getting detected... some say that they are not 1-wire really, but have some own sort of protocol..

I simply got the latest sw image (if i'm not wrong 15.07) and I put the kernel with modules on the sd and it worked like a charm.I'm putting the data in cacti (as test) to display my room temperature.
As info I found that in my test environment is impossible to use the ds18b20 in parasite way and I'm using three wire to connect the chip.

graph_image.php.png (5.85 KiB) Viewed 12395 times
Posts: 4
Joined: Thu Jul 26, 2012 11:13 pm
by Acuario » Fri Aug 17, 2012 5:45 pm
I have been trying to get the DHT11 running on my Pi but without success. I think you will need to resort to either a pic type interface where the pic reads the device and passes the result back or (and I have no experience/idea about this) write a kernel mode driver to access the device. I've had devices successfully running on a pic 16F877A clocked at 20MHz.

At user mode the timing required to read the serial data stream from the device can't be controlled finely enough as it needs microsecond timing as the data bit value is represented by the length (in time) of the data bit.

Maybe I'll have a look at a driver one day or (if I'm lucky) someone else will come up with one.
Posts: 3
Joined: Sat Jul 07, 2012 8:39 pm
Location: Tortosa, Costa Dorada, Spain
by ripzay » Wed Aug 22, 2012 12:18 pm
This is exactly what my project aims to do - amongst a long list of other things..


My slave can take an IO module - with 7 bits of definition - a temperature sensor could feed data into the inputs using an ADC, and the 7 outputs could drive a digital thermostat, as well as allowing for human input of the 'target' temperature.

All this is done over RF rather than hard wired. but the RF module could very easily be replaced with a cheaper USB FTDI or direct RS232 Connection to the RasPi
User avatar
Posts: 28
Joined: Thu Jul 19, 2012 9:32 am
by Acuario » Sun Aug 26, 2012 8:31 am
I bit the bullet, burnt some midnight oil, read and searched a lot and eventually came up with a kernel mode driver that (mostly) works.

You can connect the DHT11 directly to the GPIO port and the driver will read it and return the results.
I've found there is a discrepency in the results from the same sensor when run on 3V3 and 5V. Certainly my device seems more accurate on a 5V supply than the Pi 3v3 one.

The driver + source + usage instructions etc. are here:

There are various output formats that can be chosen when loading the driver.
root@raspberrypi:/home/pi/kernelmode# cat /dev/dht11
Temperature: 19C
Humidity: 28%

Posts: 3
Joined: Sat Jul 07, 2012 8:39 pm
Location: Tortosa, Costa Dorada, Spain
by Marcovaldo » Fri Dec 28, 2012 6:58 pm
Hi All,

I plan to launch a similar project.

As I have always been close to hardware, I consider to build a kind of
thermostate shield/case

Who else would be interresting in such a thing?

The preliminary specs is:

* RPi pluggable as daughter board
* Some kind of LCD display (maybee a small graphical one)
* Plastic case (maybee wall mounting and/or DIN rail mounting)
* Supports a few temperature sensors(application could be some thing like
smart thermostate, differential thermostate for solar boilers, controller for home brewing of beer,
some climate control for your pet/snake/homegrew ... and whatever
* a few outputs (relays and/or SCR)
* a few front panel keys (something like MENU,+,-, ENTER)
* a few status LEDS
* maybee a serial port driver and connector
* maybee a powerline and/or WLAN comms option

What else?

Best regards,

Posts: 4
Joined: Fri Dec 28, 2012 6:45 pm
by ryebrye » Sat Dec 29, 2012 2:04 am
One other feature would be IR out. For instance, I have a system where my AC isn't controlled by my existing thermostat (in my case it's a built-in ductless ac unit - but for others it might be that they have a window-mounted AC unit).

Having an IR blaster that could turn the AC on and off would be extremely nice.

The other thing would be motion sensors - so you could build in a feature similar to the Nest where it will crank down heat in areas of a house that nobody is present in.
Posts: 1
Joined: Sat Dec 29, 2012 2:00 am
by Marcovaldo » Sat Dec 29, 2012 4:13 pm
ryebrye wrote:One other feature would be IR out.

Seems an easy task. I wasn't aware of such a need as I am happy to live in an area where ACs are
seldom. But when travelling and staying in hotels I remember some of them have ACs with some
kind of IR-Remote. I think the cost is to have a IR-LED and possibly some software driver

Anyway other uses are thinkable: sending IR commands to some kind of motorized heater valves
located in the same room. (Or to turn off TVs etc if the system decides the room is empty...)

ryebrye wrote:The other thing would be motion sensors...

I think this costs two digital inputs(one or two of them to be IRQ capable)
I think this can be part of the user interface concept:
either something like 4 buttons or two buttons and encoder.
There are several cheap sensors around (I think by ALPS of japan) that offer for example
- 4 way joystick plus pushbutton
- jog wheel plus pushbutton

Also a kind of IR receiver(or RF intrusion contact) might be an option. I think in the scandinavian
area they use contacts at the windows that throttle the heating(to remind the inhabitant to close
the window again after getting some fresh air in.

For non-eternet comms ther might be an option of a Zig-Bee or BT module (guess they are relatively
cheap to get from the arduino focused channels). Some kind of powerline (or X10) would be nice
but the ready made converters are not cheap and large and building from scratch is not trivial
(and there are a few regulations to meet also...)


Posts: 4
Joined: Fri Dec 28, 2012 6:45 pm
by SuperDave156 » Sat Jan 05, 2013 1:23 pm
Hi all,

I have a number of student houses that I rent out. The monthly rent includes all bills so I often go into a house in the middle of the day and find no one home but it is sweltering hot with the thermostat turned up to full!
I need a solution to replace the conventional thermostat where the Raspberry Pi monitors the temperature and periodically logs itself onto my website, checks what temperature the house should be from a house/time/temperature database and switches the heating on or off as appropriate.
That way I could configure each house remotely from my desk.

Does this seem feasible?
I am pretty good at programming but have no experience with thermistors or relays etc.

Posts: 11
Joined: Sat Jan 05, 2013 12:56 pm