USB powered relay and thermal sensors

Red Squirrel

[H]F Junkie
Joined
Nov 29, 2009
Messages
9,211
I am looking at coding a web based thermostat for my house using C++ with a php web front end, and I want it to run on Linux. My plan is to make it really smart, where it will learn how long it takes for temp changes at a certain outside temperature, so there will be a sensor indoors and outdoor. Maybe multiple sensors in different spots. But for sure I want at least two sensors. I will also need at least 3 relays, one for just the fan, one for the heat and one for the AC (I don't have AC yet but want to eventually get it). Idealy the more in/out ports the better as I may use it for other stuff.

What kind of solution would offer me this? It needs to be able to work with Linux, idealy, it should just be writing to a text file, that way I can code my app to read the files and react. For output there would need to be some standard way of doing it so that I can code it in.

Anyone know what I could buy to make this possible? I will be doing shift work in the next few months or so, so I'd like to be able to easily add complex scheduling and stuff. I also want to make it smart where it wont short cycle, so like if based on previous calculations it knows it will lose heat and have to start again, it will run longer. There will be lot of "smartness" coded into it. I'm not worried about the coding part, I just need some piece of hardware that is easy to interface with, and I'm really not sure what would give me that functionality. In fact even something that just has a telnet interface would do, I could have my app telnet in for input/output.
 
Broadcast Tools has a device which will give you GPIO channels via RS232 (just throw a usb<->rs232 on it). They do 4ch, and 16ch models. They have inputs and outputs.

FYI - the relays are just reeds. If you're gonna drive a contactor on an HVAC unit, grab an external relay to control your hvac gear. The BT boxes can switch 24VDC easily. Alternatively, you could go for a solid state relay (I prefer mechanical relays since that way I can listen for the clicks when i'm troubleshooting, and I don't have to look at the relay all the time).

As for the actual control - just do a simple PID control loop. Alternatively, just do threshold based control and only have it enabled when you're (coming or already) home.
 
Hmm I just googled GPIO so is that like a standard for this type of stuff? Sounds interesting. So basically this device would be like a switch, and then I just buy the modules I need and plug them in? It also looks like it would show up in /proc and I can communicate with them that way. That's pretty much what I'd like, that way it gives me full freedom to code whatever I want.
 
Get homeseer and some zwave temp sensors and thermostats. . . . Done
 
Get homeseer and some zwave temp sensors and thermostats. . . . Done

This seems much more logical than building something from scratch...

Alternatively, you could get on of the 3M wifi models from Home Depot for $99, they run the RadioThermostat.com software which has a public API available, and responds to JSON commands through curl, I created a quick batch script to make some simple changes. You can command it to spit out temperatures and log temps to a text file which you could parse for whatever info you're looking for, you could then pull external temp from another sensor or even from weather.com

Check out their technical forum for more info: http://forums.radiothermostat.com/viewforum.php?f=11&sid=3119329027fc388540c0d2da78343f65

edit, one more link of available info through the API: http://central.isaroach.com/wiki/index.php/Tstat_APIs#.2Ftstat.2Fhumidity
 
Last edited:
I did not find any such thermostat at home depot, but yeah if anything like this exists it would work too. Will probably end up being more expensive to build something myself anyway.
 
GPIO just describes simple digital logic that works at the individual bit level.

Hell, if you have a nice hardware parallel port, you have 8 bits in and out right there. Throw a solid state relay off the outputs to switch whatever.

It doesn't show up in /proc. To control the outputs, you just send it commands via RS232. Whenever an input is activated, it sends you text via RS232.

It comes with all the logic stuff you need. All you need is an external power source.

The outputs are just relay contacts, so you put +24 volts on the COM connection, NO is normally logic 0, NC is normally logic 1.

Usually boxes like this are pretty variable when it comes to inputs. You might be able to just give it +24 off switch contacts (it should debounce) or it might be able to do contact closures (in which case, you just connect both sides of the switch to this box).

Hmm I just googled GPIO so is that like a standard for this type of stuff? Sounds interesting. So basically this device would be like a switch, and then I just buy the modules I need and plug them in? It also looks like it would show up in /proc and I can communicate with them that way. That's pretty much what I'd like, that way it gives me full freedom to code whatever I want.
 
Last edited:
lol I just build a rough version of what you are talking about using a couple eZ430-RF2500 and a wrt-54gs for a class. If you are looking for a project it could be fun. If you want something that will work without much upkeep get one of the commercial WiFi Thermostats.
 
I want to avoid serial/paralell if possible, just because that's legacy and eventually wont be possible to get at all, so I want something that will work with any PC. The server I want to run it off of also does not have a serial port. I do have a converter, but those can be flaky.

I found this:

http://www.canakit.com/4-port-usb-relay-controller.html

Think that could work? For the temp sensors, I'm guessing I put thermistors? So I would probably get some weird value that I think have to translate to celcius? Also since thermistors are based on resistance, can I still put one remotely using a long wire? Or would that mess up the value?

I would probably put the relay module in the server room next to the server, but I'd want the thermistor in the living room or some other place.
 
Depending on how long your runs for temp sensors are you may want to look at something wireless.

The canakit board is nice, they deal with a lot of the hardware work for you.
 
I'll bet USB is legacy before serial is dead and gone, I wouldn't worry about using serial, there's always going to be a way to interface with it one way or another, and you could run the system from an embedded board like a real thermostat instead of a full blown pc/server.
 
Depending on how long your runs for temp sensors are you may want to look at something wireless.

The canakit board is nice, they deal with a lot of the hardware work for you.

Yeah I'm starting to lean towards that. In fact it just occurred to me now they are in Canada, that will make things easier and cheaper.

As for the temp sensor runs, is it actually an issue as far as functionality if they are far? I don't mind having to run wire. Worse case scenario I could put the whole module where the thermostat is, and just run a USB extension to the server. I'd have to ensure I'm within the spec, but it's not that far to go. Either way I will have to run a wire, whether it's USB, or the temp sensor. I've also been wondering if I can put the sensor in the return vent, but the air temp of that air is probably all over the map.

I'm thinking I could use this sensor:

http://www.canakit.com/ds18b20.html

Not sure how it works, if that's a straight up thermistor, or if it's actually a small module that just sends data over a wire. If it sends the actual data then I'm guessing the length does not matter too much. I will probably be running a cat6 and use one pair. (I already have lots of cat6)
 
Lots of ways to go DIY. I've recently started playing with a project home automation hub: http://www.dbzoo.com/livebox/livebox using "development" boards from http://jeelabs.org/shop/ - they use the ATMEGA programmable ics which are really simple to use/reprogram through the arduino open source ide.
Some ramblings on my blog: http://tickett.wordpress.com/2011/12/05/more-jeenodes-my-home-automation-hub/

Also stumbled across: http://openenergymonitor.org/ which seems really interesting.

Good luck
 
So I just ordered that board and one sensor, I'll see how that goes. Been wanting to do this for a while and talking about it, now I'm actually doing it. I'm glad I found that site, I may order more stuff from there later on.
 
I want to avoid serial/paralell if possible, just because that's legacy and eventually wont be possible to get at all, so I want something that will work with any PC. The server I want to run it off of also does not have a serial port. I do have a converter, but those can be flaky.

I found this:

http://www.canakit.com/4-port-usb-relay-controller.html

Think that could work? For the temp sensors, I'm guessing I put thermistors? So I would probably get some weird value that I think have to translate to celcius? Also since thermistors are based on resistance, can I still put one remotely using a long wire? Or would that mess up the value?

I would probably put the relay module in the server room next to the server, but I'd want the thermistor in the living room or some other place.

Thermistors are best connected using what's called a four-wire configuration. You connect a constant current supply to the thermistor. The current source will push any current required into the sensor. You then connect a voltmeter across the thermistor. The voltmeter has a very high input impedance, high enough that the impedance of the connecting cables is minimal compared to the impedance of he voltmeter. This way, the error is minimal compared to overall error of the thermistor.

Get a Platinum RTD, that's a well defined standard sensor. The resistance is what changes, but knowing the constant I and the voltage V, that's a one liner to figure out.
 
Back
Top