User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Wi-Fi Thermostat

Wed Nov 20, 2013 10:57 pm

Hi!

I've just finished the heating system in my new house. I don't live in the house yet, but I occasionally visit the house. I would like to control the heating system remotely through Wi-Fi, so that when I arrive there the house is already nice and warm. When I'm not there the thermostat is set to maintain 8 degrees Celsius, but I'd like to be able to increase/decrease that from away. This can be done with commercially available Wi-Fi enabled thermostats, but those are unbelievably expensive. The cheapest I could find was around 200 euros. The Raspberry Pi, on the other hand, is available for about 40 Euros in my country, including transport. So the idea is to use the Pi to connect to the Internet and make it somehow control a cheap standard radio thermostat.

I currently have a normal, battery powered, movable, radio thermostat module, which has, among other things, two buttons to increase/decrease the set temperature. If I take it apart, I see that under the push buttons there are two wires (actually two tracks on the PCB) that are connected when the button touches them. So all I need to do is to take some wires from those two PCB tracks to the PI and somehow tell the Pi to connect the two PCB tracks for, say, half a second and then release (unconnected them). This would be sufficient for me, I could just watch the thermostat's LCD through a web cam and command the Pi to push the "increase temperature" or "decrease temperature" button through command line or maybe I could even put together some nice web interface.

The only question is how I can accomplish the hardware part. How can I make the Pi "push" those buttons. Although I have worked with the PI in different electronics projects before and I know how to control the GPIO pins, I'm not very good at hardware and I don't know how I can make the Pi connect those two ends of a completely different circuit, which probably runs on a different voltage (I think the thermostat runs on one 1.5V battery, but it may also run or two or three such batteries, I'll have to check). I'm guessing that I need to keep the two circuits separated from each other and use some component which closes the thermostat button circuit when it receives a signal from the Pi. My first guess is that a transistor would be the suitable component to do this, but, like I said, I know very little about hardware, so I might be utterly wrong. What do you think? If possible please also suggest appropriate ratings for this component that can be the "interface" between the PI's GPIO and the thermostat's button circuit.

Thank you!
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Thu Nov 21, 2013 12:31 pm

I've talked to a friend who is more skilled then me in electronics, who says that in order to keep the Pi's GPIO circuit and the thermostat's button circuit isolated from each other, I'll need to use an optocoupler.

He also had the great idea of figuring out what radio signals the thermostat is sending to the unit which is attached to the heating unit and to replicate those signals with the Pi. Sounds like a lot more elegant solution, I just have no idea how to reverse engineer the protocol of the thermostat transmitter or how to send radio signals with the Pi...
Andras
http://iqjar.com

JumpZero
Posts: 1022
Joined: Thu Mar 28, 2013 7:35 pm
Location: 127.0.0.1

Re: Wi-Fi Thermostat

Thu Nov 21, 2013 4:28 pm

Hi,

I will propose that you take the problem by another end:
A thermostat is giving a contact (open/close). So your heating unit receives a contact from the radio receiver to start/stop. You can just replace this contact by a relay contact, and drive this relay from a Pi GPIO output. You hook a temperature sensor to the Pi and with appropriate software it becomes a thermostat.
Normally you send a close contact to start the heating, so if you like you can keep your radio thermostat and put the Pi gpio driven relay contact in parallel with this contact. To have your heating off, both must be open, anyone close will give a heating order. Although I won’t recommend having 2 thermostat in parallel, it’s confusing.
I drive my home heating this way. I did it since 4 years (before it wasn't a Pi but an old PC). I have recently moved to a new house and my system moved with me and is working in my new house. I use the 1wire bus and 1wire temperature sensor, simple, cheap, all software existing. I do more than a thermostat only, I have several temperature sensors, record them, trace trends etc.. My system is accessible through internet so I can start stop my heating from anywhere, I can program it as well. If you like you can have a look to my website, you can download software and have a look to some drawings and photos for new and old houses.
Check here
http://gcolin.hd.free.fr/
and
http://gcolin.hd.free.fr/SystemDescript ... ption.html

But there plenty of other ways to do it...
--
Jmp0

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Thu Nov 21, 2013 11:14 pm

Thank you for your reply JumpZero!

Actually, I have considered the approach that you are suggesting, to have the Pi drive the heating unit directly and I have not completely given up on it completely yet, but there are a few things that encourage me to take the other solution, which is to have the Pi "push" the radio thermostat's "increase temperature" and "Decrease temperature" buttons. Allow me to explain:

1. My fist problem is that I don't really know how my heating unit can be instructed to start/stop the heating. If I want it to heat, do I need to close its contacts and keep them closed as long as I want it to heat, or just close and release quickly to start and close and release quickly again to stop? I guess I could figure this out by experimenting, but a 1000 euro heating unit is not necessarily something I want to play with...
2. As you said, having two thermostats can be confusing. any of them closing will start the heating. But, depending on the answer to my above questions, probably if only one thermostat opens, the heating will not stop. So I wouldn't want two thermostats. But if I get rid of the existing one, then the only way to command the heating unit will be through the Pi. That's not a desirable thing because if the internet connection fails, then I won't be able to control it. Also, I won't have a nice LCD, like on my current thermostat, I will only be able to check the status on my phone or on my PC.

Controlling the heating unit directly is kind of exciting and also an elegant solution, but it does have disadvantages. So I'll probably stick to having the Pi "push" the buttons of the radio thermostat, which will, in turn, communicate with the heating unit.

I went to the house today and I disassembled the the radio thermostat, to see what I can do with it. It seems that it's fairly easy to solder some wires to the ends of the up/down buttons on the PCB, so all that is left to figure out is how I can use the Pi to close the circuits of the wires that are soldered to the up/down buttons. The opto-coupler solution sounds good in theory, but I do not yet know how I cn actually make it happen. I'm guessing that I'll have to find some opto-couplers that can take 5V or 3V3 voltage on the input and can handle the voltage of the radio thermostat on the output (which is most likely 3V, since it's powered by two 1.5V AA batteries, but I have not measured it yet). I don't know if the inputs of these opto-couplers can be driven with the low currents that the Pi's GPIO can handle, if they cannot be driven by such low currents, then maybe they have a third pair of pins which allows me to connect them to an external power source. Also, I'm not sure how I could close the input circuit of the opto-coupler, but the way I imagine it is to connect the opto-coupler's input in series with the Pi's one programmable GPIO pin and the Pi's GND pin and then just set the GPIO pin to HIGH to close, allowing electricity to flow from the programmable GPIO pin, through the input circuit of the opto-coupler, to the Pi's GND pin. Does this sound about right? If somebody could recommend an appropriate choice of components, I'd really appreciate that.

Thanks!
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 2:21 am

Hi,

Opto-couplers could be used, but I'd rather use analog switches instead.
There are two main reasons for this:
- the transmitter is battery-powered (no need to galvanically separate RasPi and transmitter),
- you have direct access to control keys (circuit with analog switches is simpler and consumes much less power).

The circuit is quite simple - you take analog switch chip, connect RasPi power pins to it, connect chip's control input pin to GPIO pin and connect its two switching pins in parallel to button on your transmitter. You could add a 100nF ceramic capacitor close to the chip's supply pins. Additionally, you should put pull-up or pull-down resistor to the control pin (pulling up or down selection depends on selected chip).
(Repeat steps described above for each additional button you need to control ;-) )

These analog switches are semiconductor devices and are not mechanical (they are not relays). As a result, they require much less power to control them and can be controlled directly by GPIO pin. Their power consumption is minimal, they are silent, etc...
However, they have some resistance when turned on (from some mili ohms to few tens of ohms), but I don't expect that some ohms of resistance would not be detected as "button pressed" state.

There is quite some these switches on the market... you can have one switch per chip or packed more of them together, they have one "contact" or more, they are for different supply voltages, with different on-resistance, various max switching frequency, and so on...
Yes, I know, I need to write at least one part number (otherwise this question would follow immediately)... ;-)

So, let's say that my selection would be 74LVC1G66GW. It is cheap, but with relatively high on-resistance (you might check if this is a problem with ordinary resistor on your transmitter - take 33E resistor and bridge a button contacts. If the heating unit reacts, then you can pick this chip. This chip needs pull-down resistor on control pin to keep it in off state when no signal is present.

BTW #1: I'd rather work with pull-up resistors and active-low signals, but it seems that RasPi during boot procedure pulls down GPIO pins for about 750ms (actually it activates its internal pull-downs. I'm not sure if later models too, but I'd rather not risk that). Therefore, try to avoid devices with active-low signal, else (re)booting RasPi would result in pressed all connected buttons on the transmitter for listed amount of time.

BTW #2: A note to anybody else reading this - do not use these switches to control motors...


Best regards, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 8:33 am

Ivan Zilic, you are my hero of the day! Thank you so much! I will look into this :)

Unfoftunately 74LVC1G66GW is not something that I can find in my town. I just checked, none of the specialized stores have it. I'll try to fin an alternative...
Andras
http://iqjar.com

JumpZero
Posts: 1022
Joined: Thu Mar 28, 2013 7:35 pm
Location: 127.0.0.1

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 8:49 am

Hi Un4Seen,
do I need to close its contacts and keep them closed as long as I want it to heat, or just close and release quickly to start and close and release quickly again to stop
All thermostats are always close to start heating open to stop. The simple reason for that is that you can take one from any brand and replace it by another brand, it’s a kind of “de facto” standard. Note that for AC it works in the opposite way than for heating. The thermostat includes a temperature sensor and when the measured temperature is above the set-point (i.e. the temperature you want) it opens the contact, when the measure is below the set-point the contact close. There is an hysteresis (also called dead band) to avoid the contact flipping when the measure is equal to the set-point. For instance if the hysteresis is 1% and the set point 20 degree C. and room temperature is 18, the thermostat will give a close contact, the heater heats, temperature rises and when it reaches 20.2 (=20+1%) it will open the contact, then the heater stops, room temperature starts to decrease and the thermostat will close again at 19.8 (=20-1%). On good quality thermostat hysteresis is adjustable, this is usually on industrial thermostat, not home ones.
This being said, there is nothing stopping a manufacturer to build something different. What is you heating system (gas boiler? Fuel? Electric?..). If your room thermostat is part of your heating unit, there is nothing blocking the manufacturer to have the radio receiver build-in the unit in such a way you don’t have access to the contact (usually it’s not the case, but we never know). Check with you heating unit documentation.
That's not a desirable thing because if the internet connection fails, then I won't be able to control it.
No. You won’t have remote access, but access from your home local network will still work.
Also, I won't have a nice LCD
You can add one on the Pi and add functions that are not available in the existing thermostat. Look at mine.

Anyway Ivan gave a very smart solution with these analog switches (I didn’t know these, they are nice devices, no need to always use relays). So you can follow this way. It’s up to you.

--
Jmp0

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 9:06 am

JumpZero, first of all, thank you for your answer!

Controlling the heating unit (which is a gas boiler, by the way) directly is something that really appeals to me and I'm pretty sure that one day I won't be able to stop myself from doing it :) But now I need a quick solution, because the cold winter is about to set in (in about 3-4 days from now). I need to have a pretty good way of controlling the heating fast. Adding an LCD to the Pi, etc, needs figuring out. That will take time. Tapping into the radio transmitter (into the movable radio thermostat unit), by attaching to its up/down adjustment buttons is something that probably will be done a lot faster. I'll stick to that for now, but your idea of controlling the boiler directly is greatly appreciated, as a plan for the long term future.

Ivan, I looked around for the 74LVC1G66GW some more and it seems that the only quick way of getting a hold of it would be to have it shipped from the UK to Romania, buying it from Farnell (since nobody is selling it in Romania directly). That will cost a bit, but if no other choice, I'll go for it. I noticed in its specs that the output current is 32 mA. Won't that be a problem? I mean, how can I know how much current is meant to flow when the thermostat's button closes. Maybe it should be less than 32 mA, maybe more, maybe 32 mA is quite right... What do you think?
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 12:21 pm

I looked at what is available in the local stores.

I wonder if this one could work:
http://www.fairchildsemi.com/ds/CD/CD4016BC.pdf
The only thing that worries me about this one is the 400 Ohm "On" resistance. Maybe it's too much. But I could test that with a 400 Ohm resistor, see if it connects the thermostat button's ends. OTherwise deos this one seem suitable?

There's also this similar one:
http://www.futurlec.com/4000Series/CD4066.shtml
If I understand correctly, this one only has an "On" resistance of 80 Ohms.
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 3:08 pm

Hi,
Un4Seen wrote:I noticed in its specs that the output current is 32 mA. Won't that be a problem? I mean, how can I know how much current is meant to flow when the thermostat's button closes. Maybe it should be less than 32 mA, maybe more, maybe 32 mA is quite right... What do you think?
I'm sure that the current in your case is much lower. You can measure it with ampere-meter... just bridge the button contacts with it and you'll measure the current. It is in range of micro A, for sure.
(This current was the reason for my previous note that the chip is not to be used for controlling motors.)
Un4Seen wrote:I wonder if this one could work:
http://www.fairchildsemi.com/ds/CD/CD4016BC.pdf
The only thing that worries me about this one is the 400 Ohm "On" resistance. Maybe it's too much. But I could test that with a 400 Ohm resistor, see if it connects the thermostat button's ends. OTherwise deos this one seem suitable?

There's also this similar one:
http://www.futurlec.com/4000Series/CD4066.shtml
If I understand correctly, this one only has an "On" resistance of 80 Ohms.
These two switches have high on-resistance. In your case, it would be much higher than 400/80 ohms. Exact number applicable to your circuit is not presented in datasheets. The resistance increases by decreasing voltage (eg. 400 ohm listed in datasheet is for 15V supply, where you'd have just 3.3V)... Ok, temperature is also key factor here, but lets stick to 20 deg C.

By looking in the datasheet, I have a "feeling" (when combining data for various existing data points) that the on-resistance would be in your case somewhere around 5k for CD4016BC and around 3k for CD4066. This is probably too much...
Yes, you can check transmitter's behaviour with ordinary resistor, equivalent value.
The nice thing is that we can always observe/measure prameters, so no need to guess... anyway, without having the elements here, I'd take a risk and guess anyway... ;-) My guess is that the maximum allowed resistance would be in the range of few hundred ohms.
Don't trust me on these numbers, I hope I'm wrong. Check and find out. ;-)

So, what you could do is to check what is max allowed resistance... grab some resistors. bridge button contacts with each and find out, where is the limit.... and have some tolernaces (20% or so) in mind. If max resistance which triggers transmitter is below 2k, I'd not start to make further tests using any of thses two chips.

Next to on-resistance, these two chips seem to be suitable.

Yes, you could desrease on-resistance by increasing supply voltage, but you'd need some additonal elements (power supply, transistors, resistors) in the circuit.
Before thinking any further, you might find out what is max resistance accepted by the transmitter.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Fri Nov 22, 2013 3:39 pm

Like, I said, Ivan, you are my hero of the day! Thank you very much for your carefully explained answers. I will measure and let you know! :)
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 12:06 am

I went to the house again and tried to solder the wires to the terminals of the up/down buttons. It was a bit hard because of the tiny contacts on the PCB, but the operation was a success! :) I can now adjust the set temperature by touching the wires, which I elegantly took out of the case :)

And the good news is not over! I tried connecting the wires with different resistors and it even works with 50 KOhm. Maybe it would work with even higher, but there was no point in trying :)

Also, I tried to measure the current which goes across the circuit when I touch the wires, but the multimeter shows 0 even when set to a range of 2 mA.

So I guess I'll go ahead and buy one of these:
http://www.fairchildsemi.com/ds/CD/CD4016BC.pdf
http://www.futurlec.com/4000Series/CD4066.shtml

And, of course, one more RPI, because my current Pi has other duties, like running web server, etc.

I have only a few uncertainties left. What value should the pull-down resistors on the control pins of the analog switches be? I guess the higher the better because it will reduce power consumption if the value is big. But how big can it be?
Also, the Vss and Vdd pins of the analog switch IC should be connected to the 3V3 (or 5V?) and GND pins of the Pi or to the +/- of the thermostat's batteries?
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 3:41 am

Hi Andras,
Un4Seen wrote:I tried connecting the wires with different resistors and it even works with 50 KOhm.
U, quite high value... this makes me thinking about possible noise sensitivity risk.
Keep these buttons connection wires short (it is always a good idea, but specially here). The second one is whether to add additional resistor in series... we can come to this latter.
Un4Seen wrote:Also, I tried to measure the current which goes across the circuit when I touch the wires, but the multimeter shows 0 even when set to a range of 2 mA.
More expected than resistance... ;-)
Pick one. ;-)
Maybe 1st one due to higher on-resistance (which became more desirable after your measurements).
Un4Seen wrote:What value should the pull-down resistors on the control pins of the analog switches be?
Value is not critical, can be something between 4.7k and 10k.
Un4Seen wrote:I guess the higher the better because it will reduce power consumption if the value is big.
Most of the time you will actively drive the control pin(s) low, so there will be no current flow through this resistor. This resistor plays its role after power-on and before you run the software to init GPIO pin(s).
Un4Seen wrote:Also, the Vss and Vdd pins of the analog switch IC should be connected to the 3V3 (or 5V?) and GND pins of the Pi or to the +/- of the thermostat's batteries?
Use Pi's power pins. You can connect to 3.3V (because GPIO pins are also 3.3V).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 8:08 am

Ivan, I cannot thank you enough for your priceless answers! Really, this means a lot to me!

I think everything is clear now, so I'm headed to the electronics shop to buy the parts. I'm also ordering a Pi. I should be able to put everything together in 2-3 days, but it will probably take another 2-3 days to set up the software on the Pi and the longest waiting time will be for the telephone company to come and connect the house to the Internet. But in about 10 days I should be able to come back here with awesome news! :)
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 1:42 pm

Ouch! I just noticed that at the store instead of this:
http://www.fairchildsemi.com/ds/CD/CD4016BC.pdf
they gave me this:
http://pdf.datasheetcatalog.com/datashe ... 4016BN.pdf

The important difference seems to be that HEF4016BP cannot work with 3.3V, only with 5V, so I'll have to hook it up to the Pi's 5V pin instead of the 3V3 pin. I wonder if I can still use the programmable GPIO pins to switch the analogue switches in this chip (in other words connect the GPIO pins directly to the data pins of the HEF4016BP) or I can't do this because the programmable GPIO pins work at 3.3V and I have to use transistors or something to translate the signal from the programmable GPIO pins to 5V before feeding it to the HEF4016BP...

What got me wondering about this is the following section in the HEF4016BP's data sheet:
The HEF4016B has four independent analogue switches
(transmission gates). Each switch has two input/output
terminals (Y/Z) and an active HIGH enable input (E). When
E is connected to VDD a low impedance bidirectional path
between Y and Z is established (ON condition). When E is
connected to VSS the switch is disabled and a high
impedance between Y and Z is established (OFF
condition).
Note that it says that "E is connected to VDD", which smells like trouble if E is connected to RPI programmable GPIO pin (3.3V) and VDD is connected to RPI pin 5V...
Last edited by Un4Seen on Sat Nov 23, 2013 3:05 pm, edited 2 times in total.
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 2:57 pm

I've created a mock-up with Fritzing to demonstrate how I imagine the circuit:
Image

My only doubt is weather I can really do it this way (connect the RPI's programmable GPIO pins directly to the HEF4016BP's data pins) even if I connect the HEF4016BP to the Pi's 5V power pin or I need some additional components between the PI's programmable GPIO pins and the HEF4016BP's data pins.
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 4:57 pm

Hi Andras,
Un4Seen wrote:Ivan, I cannot thank you enough for your priceless answers! Really, this means a lot to me!
You're welcomed. :-)
Un4Seen wrote:I think everything is clear now
Don't be so sure... surprises are everywhere... :|
What a bit "worries" me is high resistance which still triggers transmitter... as you can see in the purchased chip, there is a leak current (so the off state is really not off, but "almost off") - so it could be that the resistor which is in series to each button would need to be increased... or maybe even some other approach used... :?:
Un4Seen wrote:I have to use transistors or something to translate the signal from the programmable GPIO pins to 5V before feeding it to the HEF4016BP
Correct. Minimal voltage for the chip's high level is 3.5V, so you need additional circuit.
There are several good discussion on this subject, check this one, for example:
https://forum.sparkfun.com/viewtopic.php?f=14&t=20395.
Un4Seen wrote:I've created a mock-up with Fritzing to demonstrate how I imagine the circuit
Ok... what you need to add is also to connect unused inputs either to Vdd or Vss. It is a good practice not to leave unused inputs floating unconnected.
For this chip, you might connect inputs E0 and E1 to Vss (to keep them in off state). But Vdd would also do the job well... just don't leave them unconnected.


Take care, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sat Nov 23, 2013 5:40 pm

Thank you, Ivan!

Well, in that case I'll use an ULN2003 chip that I have at home (which is basically 7 transistors packed together) to control the inputs of the HEF4016BP. In other words the Pi will control the ULN2003 and the ULN2003 will control the HEF4016BP.

Thanks for the tip of not leaving the inputs floating. I'll take care of that.

Indeed, there seems to be some off-state leak current for the HEF4016BP, but from the datasheet it seems to me that this leak only occurs when Vdd=15V, not when Vdd<15V, and when it occurs, it could be 200 nA. Yes, increasing the value of the resistors placed in series with the thermostat's push-buttons seem to be a good idea from this point of view. I'll probably add 100K adjustable resistors, so that I can fine-tune it after it's done. Or maybe even 500K variables, just to be on the safe side. I just hope that this will work :|

Thanks,
I'll get back to you if I manage to figure more things out.
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 12:15 am

While trying to make a connection diagram in which I use the Pi to drive the ULN2003 and the ULN2003 to drive the HEF4016BP, I realized that it's impossible to do it because the ULN2003 is "inverting", meaning that when it gets a positive voltage on the input, it connects the corresponding output to ground. What I need is the opposite of that, a transistor array chip which connects the output to positive voltage on its output when the input gets a positive voltage. I hope I'm making sense here...

I've spent the last 30 minutes or so searching for such a component, but people say that there isn't really such an IC. Is this true? It seems so hard to believe. Yes, I know, I could just use simple transistors instead, but with the IC it's easier. More elegant, less components.

If there's no other way but to use simple transistors to invert the output of the ULN2003, what would a right transistor be for the job? I mean, what mass-produced type could do the job? Yes, I'm asking for component codes again :oops: Also, what are good values for the resistors that need to be used with it as pull up/down?

Thank you!
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 2:09 am

Hi,
Un4Seen wrote:it's impossible to do it because the ULN2003 is "inverting"
You're controlling just two buttons. So, currently, 5 out of 7 darlingtons are still free... take two more to invert signals one more time, to become un-inverted. :-)


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 9:31 am

FLYFISH TECHNOLOGIES wrote:You're controlling just two buttons. So, currently, 5 out of 7 darlingtons are still free... take two more to invert signals one more time, to become un-inverted. :-)
This is a great idea. I've spent almost 2 hours trying to understand how I can do that and I'm still not sure that my solution is correct. This is how I imagine it:
Image

Explanation:
When RPI GPIO pin sends +3.3V signal to ULN2003 input pin 1, ULN2003 connects output pin 1 to GND, which means that the current will go through the resistor at ULN2003 input pin 3 to 5V, so input pin 3 will NOT be stimulated by positive voltage, meaning that output pin 3 will be NOT be connected to GND, so current will flow from 5V through the resistor at output pin 3 to the input of the HEF4016BP, causing HEF4016BP to open.
When RPI GPIO pin does not send +3.3V signal to ULN2003 input pin 1, ULN2003 output pin 1 will NOT be connected to GND, which means that current will flow through the resistor at ULN2003 input pin 3 into input pin 3, connecting input pin 3 to 5V, which will cause output pin 3 to be connected to GND. This will take the current coming form the resistor at output pin 3 from 5V to GND, so it will NOT go to the input of HEF4016BP, causing HEF4016BP to keep closed.

I hope I got it right... it seems so complicated... it exhausted me :)
Did I add pull up/down resistors everywhere where they are needed? (I haven't added any to ULN2003 input pin 1 and 2) Have I used the right values? (47K everywhere around ULN2003 and 6.8K around HEF4016BP).

Thank you!
Andras
http://iqjar.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 2:08 pm

Hi Andras,
Un4Seen wrote:I hope I got it right...
Almost... ;-) Remove pull-downs from HEF chip to ULN inputs.
HEF inputs are pushed to some level all the time (either to + trough pull-ups or to GND via conducting ULN drivers), so pull-downs are not needed.

"By default" you would need to add pull-downs to ULN inputs due to GPIO bidirectional nature, but it is not needed for this chip. The reason is in internal structure, where pull-downs already exist in the chip. Resistors value varies between sub-models and vendors, but is probably somewhere around 15k-20k ohm. (You can check this for your chip, just to be sure.)
Un4Seen wrote:it seems so complicated... it exhausted me :)
:lol:
Un4Seen wrote:Have I used the right values? (47K everywhere around ULN2003 and 6.8K around HEF4016BP).
Remove two mentioned pull-downs and you're ready to go. ;-)


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 5:50 pm

If I understand correctly, I should remove the two pull-downs from the HEF data pins E2 and E3, because the HEF data pins are either pushed to +5V through the pull-ups connected to the ULN chip's output pins 3 and 4 or to GND when the ULN chip's output pins 3 and 4 are connected to GND by the ULN internally. Yes, this seems to make sense, I haven't noticed it before, but it makes total sense.

Thank you very much, Ivan! You're very kind to patiently answer my amateur questions :) I wish I could return the favor one day :)

Best wishes!
Andras
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 6:25 pm

Oh, I forgot to mention one interesting thing! Remember when I wrote that connecting the thermostat's button wires even works with 50K resistors? Well, I was curious to see how far it goes, so I tried connecting them today with a 220K resistor and that is too much, it does not notice the connection. So I decided to put some 40-50K resistors in series with the HEF outputs to counteract any possible leaking current.
Andras
http://iqjar.com

User avatar
Un4Seen
Posts: 330
Joined: Wed Oct 31, 2012 8:43 am
Location: Cluj-Napoca, Romania
Contact: Website

Re: Wi-Fi Thermostat

Sun Nov 24, 2013 10:02 pm

OK, so hopefully this is the final, correct version :)

Image

In this version all the resistors are 47K.
Andras
http://iqjar.com

Return to “Interfacing (DSI, CSI, I2C, etc.)”