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

Re: Wi-Fi Thermostat

Mon Nov 25, 2013 12:09 pm

And today I've found some CD4016BCN chips in a store. These can work with 3.3V, so I'm back to the much simpler original design :)

Image
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

Tue Nov 26, 2013 1:01 am

Tonight I have finally managed to solder the components onto a breadboard and I have even tested it a bit. It seems to work, although I'm not testing it with signals from a Pi yet (my Pi hasn't arrived yet because of the black Friday madness). I'm testing it by simulating the signal which would come from the Pi by connecting the appropriate input pins of the CD4016BCN to +5V through a 4.7K resistor. Also, instead of the thermostat, I've attached LEDs to the output of the circuit. It seems to work, although if I try to simulate an opening signal on both inputs at the same time, the LEDs are very dim, if I only simulate one opening signal, the appropriate LED (connected to 5V through a 740R resistor) is bright enough. I don't understand this aspect yet, but I'm not even sure it's important, since I'll never be "pushing" the thermostat's up/down buttons at the same time.

A scary thought has crossed my mind... When you connect something to the Pi's programmable GPIO pins (like an LED), you do it through a resistor, which protects the Pi's GPIO pin against too large currents. Now, if I connect the CD4016BC, shouldn't I add some resistors in series with the Pi's programmable GPIO pins? Won't I fry my Pi pins without the resistors? The question is, I guess, what goes on inside the CD4016BC when the Pi sends it a positive voltage signal to one of its input pins? Does it internally connect the Pi's programmable GPIO pin (which sends the signal) to the Pi's GND? Because if it does, and it does it without some resistor, then it smells like trouble to me...
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

Tue Nov 26, 2013 2:06 pm

Hi,
Un4Seen wrote:if I try to simulate an opening signal on both inputs at the same time, the LEDs are very dim, if I only simulate one opening signal, the appropriate LED (connected to 5V through a 740R resistor) is bright enough.
Do you use one resistor for both LEDs ?

Not related to this observation, but 740R is also quite high. Most circuits (including mine) have resistor 470R for 5V supply and 270-330R for 3.3V. These values are for green and red LEDs, where blue and white ones, for example, need even lower values.
Un4Seen wrote:A scary thought has crossed my mind... When you connect something to the Pi's programmable GPIO pins (like an LED), you do it through a resistor, which protects the Pi's GPIO pin against too large currents. Now, if I connect the CD4016BC, shouldn't I add some resistors in series with the Pi's programmable GPIO pins?
No.
Un4Seen wrote:Won't I fry my Pi pins without the resistors?
This chip (like all other logic chips available on the market today) have very large input resistance already "embedded". They are all voltage-driven.

LEDs are current-driven. Therefore, they suck current which needs to be limited with resistor. For voltage-driven elements, this reisistor is not needed.
Interesting parts are transistors, where you have both types (if classified by this criteria) - some transistors need resistor (bipolar transistors, like NPN or PNP), where some don't (FETs, like MOSFET, IGBT, JFET etc.)...


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

Tue Nov 26, 2013 2:33 pm

FLYFISH TECHNOLOGIES wrote:Do you use one resistor for both LEDs ?
One LED is green, the other is red. I use two resistors for driving the LEDs (one resistor for one LED), but I used a common resistor to connect the CD4016BC inputs to 5V in order to simulate the Pi signals.
FLYFISH TECHNOLOGIES wrote:Not related to this observation, but 740R is also quite high. Most circuits (including mine) have resistor 470R for 5V supply and 270-330R for 3.3V. These values are for green and red LEDs, where blue and white ones, for example, need even lower values.
I suppose I could use a smaller value resistor, but my experiments in the past have shown that modern standard LEDs are quite bright even with 0.5-1 mA of current passing through them and a 740 Ohm resistor should result in 4-5 mA of current in green and red LEDs. I admit, my experiment was with white and blue LEDs...
FLYFISH TECHNOLOGIES wrote:No.
Thank the heavens!
FLYFISH TECHNOLOGIES wrote: This chip (like all other logic chips available on the market today) have very large input resistance already "embedded". They are all voltage-driven.

LEDs are current-driven. Therefore, they suck current which needs to be limited with resistor. For voltage-driven elements, this reisistor is not needed.
Interesting parts are transistors, where you have both types (if classified by this criteria) - some transistors need resistor (bipolar transistors, like NPN or PNP), where some don't (FETs, like MOSFET, IGBT, JFET etc.)...
Thank you, again, Ivan! I have learned a lot from you in this thread. That knowledge is even more valuable than the thermostat circuit itself. I am truly grateful.

Best wishes!
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

Tue Nov 26, 2013 3:53 pm

Hi Andras,
Un4Seen wrote:I suppose I could use a smaller value resistor, but my experiments in the past have shown that modern standard LEDs are quite bright even with 0.5-1 mA of current passing through them and a 740 Ohm resistor should result in 4-5 mA of current in green and red LEDs.
Yes, for "home use" your values are ok... but I use resistors with lower values anyway... ;-)
There are two main reasons for that:
- schematics are "more generic", so somebody can reproduce it unmodified and it would work also with his/her LEDs from a drawer (thus avoiding messages in various forums :lol: ),
- if you have more than one circuit next to each other, the LEDs brightness is the same on all of them (so a potential customer has one less doubt regarding quality of circuits). ;-)

By the way: Generally speaking, dimming LEDs (eg. to save power or to create visual efects) by increasing resistor is usually not a proper approach. There have been some discussions dealing with this subject also in this forum...


P.S. You're welcomed. ;-)

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

Tue Nov 26, 2013 4:04 pm

Yes, I think the proper way of dimming LEDs (and probably also the proper way of saving power) is using PWM. Still, I usually give them less than the official rating of 20 mA, mostly not to waste power, but also because the Pi is rated at maximum 16 mA per GPIO pin and maximum 51 mA for all GPIO pins, so there's not much power to take from it (unless you use its 5V supply, which can output 80-100 mA as far as I remember, or if you some external power supply and then you're free to drain as much as you like :) ) Anyway, I'll remember that in professional solutions this is not the best way to do it :)
Andras
http://iqjar.com

thienson30
Posts: 26
Joined: Mon Jul 08, 2013 7:53 am

Re: Wi-Fi Thermostat

Tue Nov 26, 2013 5:03 pm

You control HVAC from Anywhere if you have internet either on Your phone or Computer. Check the video out. It might help you. While controlling other things, you can still use the raspberry Pi for media center or control other things at the same time. https://www.youtube.com/watch?v=KZ59sDgKqXE
Have fun my friend

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

Re: Wi-Fi Thermostat

Wed Nov 27, 2013 8:24 am

Ouch! I have discovered a fundamental problem in our CD4016BC based circuit :(

When everything is connected, it works just fine. But if I disconnect the CD4016BC from power while leaving the target circuit (in my case it will be the thermostat circuit) connected to its outputs, the outputs become connected. I think this is what is called "active low", so in other words "passive high"?

This is a huge problem, because the thermostat circuit will run from batteries, so it will always have power. But the Pi driving the CD4016BC will run from the 230V main grid, so if there's a power failure, the thermostat's buttons will remain in a constantly pushed state, which is very bad.

It's interesting how it behaves. If everything is powered, all outputs of the CD4016BC are off. If I disconnect the CD4016BC only from 5V, just one of the outputs becomes slightly connected. If I disconnect it only from GND, the same one output becomes a bit more connected, but still not fully connected (LED is dimmer). If I disconnect it both 5V and GND, both (all) outputs become fully connected (LEDs at full brightness).

If there a way to force the outputs of the CD4016BC to be fully disconnected when there's no power on the inputs of the chip?

Thanks,
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

Wed Nov 27, 2013 10:02 am

After thinking some more about it, I suspect that the problem is that when the Raspberry Pi loses power, it does not send any signal to the CD4016BC input pins, which means that the inputs of theCD 4016BC will be floating, so there's really no guarantee about the state of the corresponding outputs. In my case the inputs seem to float towards HIGH, causing the outputs to close the output circuit (at least partially). So the solution I should be looking for is to somehow prevent the inputs of the CD4016BC from floating and to keep them LOW...
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

Wed Nov 27, 2013 1:59 pm

Hi Andras,
Un4Seen wrote:the thermostat circuit will run from batteries, so it will always have power.
The solution would be to supply also transmitter from mains (= from 3.3V available on RasPi's GPIO). To decrease this voltage a bit to be within battery voltages, you could add one diode (eg. 1N400x; x=1..7) for some voltage drop.
Un4Seen wrote:If I disconnect the CD4016BC only from 5V
You should not experiment it that way... these chips have various internal protection diodes on inputs which then start to conduct and "supply" the chip - these protection diodes are not designed for this purpose and this is a stress for them.

So, general guideline is that if a chip does not have power supply attached, you should not apply voltages to other pins, and inputs are top on that list.
Un4Seen wrote:After thinking some more about it, I suspect that the problem is that when the Raspberry Pi loses power, it does not send any signal to the CD4016BC input pins, which means that the inputs of theCD 4016BC will be floating
Nope, you already have pull-downs...
The reason is that when no power is attached, there is no "barrier" voltage present in the chip and the "current flow channel" is opened (we're digging here into physics of semiconductors).


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

Wed Nov 27, 2013 2:23 pm

Clever solution :) This would also spare me from ever having to change the batteries in the thermostat.

I do wonder, though what exactly will happen in the exact moments when the power is lost or when the power comes back. Could it happen that because of some internal circuitry the thermostat will go offline a brief moment later compared to the CD4016BC and because of that its buttons will register some pressing?

You mentioned that the 1N400x diodes drop just enough voltage to get from 3.3V to 3V (actually if it drops more, it should not be a problem, since the thermostat is able to run from 2x rechargeable AA batteries too, which are only 2*1.2V = 2.4V). I was wondering if there's a solution to drop enough voltage so that I can supply it not form the 3.3V pin but form the 5V pin, because I'm already connected to the 5V pin, so it would be one less wire...

I don't know how much current the thermostat drains from the batteries, hopefully not too much because the batteries are supposed to last 1 year according to the manual. I'm concerned about this because the Pi's GPIO pins cannot supply very much current...
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

Wed Nov 27, 2013 3:11 pm

Hi Andras,
Un4Seen wrote:I do wonder, though what exactly will happen in the exact moments when the power is lost or when the power comes back.
Hard to tell... you already have pull-downs to control behaviour when RasPi is not running your script, but when voltage is applied also to transmitter at the same time, this is another story...
Un4Seen wrote:Could it happen that because of some internal circuitry the thermostat will go offline a brief moment later compared to the CD4016BC and because of that its buttons will register some pressing?
The good news is that this switch chip is only a "dumb chip", without any brains, so it comes into final state very quickly.
But to sleep well, you can improve your circuit... see below. ;-)
Un4Seen wrote:You mentioned that the 1N400x diodes drop just enough voltage to get from 3.3V to 3V
I didn't write final voltage number. ;-) Voltage drop varies also with current, but the battery-powered devices have good tolerances to accept various types of batteries and work well also when batteries voltage drops a bit...[/quote]
Un4Seen wrote:I was wondering if there's a solution to drop enough voltage so that I can supply it not form the 3.3V pin but form the 5V pin, because I'm already connected to the 5V pin, so it would be one less wire...
Connect CD4016BC to 3.3V and add voltage regulator in the circuit.
Voltage regulator is then connected to 5V and it provides 2.8 or 2.7V, or so (if you cannot locate one with fixed voltage, get the varialbe one and fix output voltage with a couple of resistors).
The nice feature for voltage regulator would be Enable input (also called Shutdown, or similarly)... it can be used to delay powering the transmitter until the "RasPi part" gets settled after power-on. This can be achieved with a capacitor + resistor connected to this enable input.

There are a bunch of these voltage regulators available... but let me just write one suitable, as a reference: TC1016-2.8V
Un4Seen wrote:I don't know how much current the thermostat drains from the batteries
Close to zero when not transmitting and probably around 20-30mA when transmitting... you can measure this, to be sure. ;-)


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

Wed Nov 27, 2013 3:28 pm

Thank you :)

I just read somewhere that a regular diode, like the 1N4007 (which I happen to have at home :) ) drops about 0.65-0.7V. So, connecting 3 of those in series could be used to go from 5V down to 2.9-3.05V, which should be fine. Or I could just use one and connect to the Pi's 3.3V power pin, one extra wire is not the end of the world after all. I'll use a UTP cable between the thermostat's radio transmitter and my circuit. That is nice and has a white coating and has 8 wires inside, which should be plenty.

The voltage regulator is a nice addition in the sense that with it I could delay the powering on of the circuit, but I'd rather not complicate things until it proves to be really necessary :) I'll just take the power form the Pi a few times and see how things behave. If I'm not satisfied, I'll look into the voltage regulator based solution.

I'm starting to wonder if we're over complicating things... after all, I could use a ULN2003 to drive two low power relays to connect the thermostat's button ends when powered. There are some 5V, 30 mA relays in the store. They also have the advantage of remaining off when the power goes out. But they have the disadvantage of mechanical wear and of drawing much power from the Pi's GPIO, which would limit further things being connected to the same Pi...
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

Wed Nov 27, 2013 4:06 pm

Hi,
Un4Seen wrote:I just read somewhere that a regular diode, like the 1N4007 (which I happen to have at home :) ) drops about 0.65-0.7V. So, connecting 3 of those in series could be used to go from 5V down to 2.9-3.05V, which should be fine. Or I could just use one and connect to the Pi's 3.3V power pin, one extra wire is not the end of the world after all.
Better to use one diode with 3.3V.
I'm not going to repeat myself... supply the CD chip from 3.3V.
Un4Seen wrote:I'll use a UTP cable between the thermostat's radio transmitter and my circuit.
I'm not going to repeat myself again... ;-) keep wires short.
Use pairs to connect switch contacts. Since they are twisted together, they provide better noise immunity.
Un4Seen wrote:The voltage regulator is a nice addition in the sense that with it I could delay the powering on of the circuit, but I'd rather not complicate things until it proves to be really necessary :) I'll just take the power form the Pi a few times and see how things behave. If I'm not satisfied, I'll look into the voltage regulator based solution.
I agree.
Un4Seen wrote:I'm starting to wonder if we're over complicating things... after all, I could use a ULN2003 to drive two low power relays to connect the thermostat's button ends when powered.
This is always a dilemma when there are more approaches possible... ;-) It's up to you... 8-)


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

Wed Nov 27, 2013 4:15 pm

Whatever will turn out, I thank you for your most valuable help, Ivan :) One way or another, I'm sure it will turn out right after learning all this!

I missed your line saying to power the CD4016BC from 3.3V, probably because I had some memories about it needing a minimal voltage of 3.5V, but I've checked the datasheet again and it can work from 3V up, so that's great!

I'll try to keep the wires short, but I'll need some overhead inside the thermostat's casing, inside my own circuit's casing, some cable which will allow me to position them relative to each other. I'll probably need at least 30-40 cm of cable. Let's hope it won't turn into a problem. I'll go with the pairs inside the UTP cable :)
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

Wed Nov 27, 2013 7:52 pm

Hi,
Un4Seen wrote:Whatever will turn out, I thank you for your most valuable help, Ivan :)
Ok, you're welcomed.

Thanks also to the forum moderator for not taking any action, since the primary discussion objective has deviated away from RasPi. :D


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

Thu Nov 28, 2013 12:41 am

Well, I wouldn't exactly say that it's not entirely about the RPI, but I agree that we're deviating a bit... :)

The strangest thing happened. I soldered an 1N4007 diode onto my circuit board. Its unmarked leg (positive leg) is connected to the Pi's 3V3 pin and its marked (negative) leg is just attached to a free wire. I also have a free wire attached to the Pi's GND pin. But for the sake of simulation, I'm not powering the circuit from the Pi's 3V3 and GND, instead I'm powering it from a 5V power source (my Pi has not arrived yet). So I tried to measure the voltage between these two free wires (which are meant to be soldered to the thermostat's battery compartment in order to power it from the grid, not from batteries). If I measure the 5V power supply's voltage, it's 5.1V, but if I measure the voltage across the two free wires (which is basically the power supply in series with the 1N4007), I get 6.2-6.8V. Instead of the diode dropping 0.7V (resulting in 4.4V), it seems to increase it. I know that it's theoretically impossible, but this is what's happening. Maybe the diode just confuses the multimeter? I wouldn't want to fry the thermostat with a too big voltage, that's why I'd like to understand the situation...

Could the other components influence the voltage? between the same + and - power pins between which is the diode, there is also a 100 nF capacitor, the CD4016BC and a DS18B20 temperature sensor.

If I try to measure the voltage simply across the diode, it gives me a reading of around 2V! How can this be possible when the diode's one end is not even connected to anything? This is extremely strange...
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

Thu Nov 28, 2013 1:00 am

Hi,
Un4Seen wrote:So I tried to measure the voltage between these two free wires
Place a resistor between these two wires and measure voltage drop on it... then the measured value must be "reasonable".
Un4Seen wrote:Could the other components influence the voltage? between the same + and - power pins between which is the diode, there is also a 100 nF capacitor, the CD4016BC and a DS18B20 temperature sensor.
They cannot cause any influence in this your case.

P.S. "Good old" analog multimeters have some advantages over digital ones, indeed... ;-)


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

Thu Nov 28, 2013 1:12 am

So, I'm not the only one who is up late thinking about circuits :)

Yes, if I place a 1.5K resistor between the two wires, I get the expected 4.45V (5.1V without diode).

Thank you! I'm going to sleep better now ;)
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 Dec 01, 2013 12:36 am

I have mostly good news :)
Since yesterday I have Internet connection in the house and the Pi has also arrived. I managed to solder and connect everything together and, after some long and painful configuration, I managed to make the whole thing work :) I can really control my thermostat from the distance :) It works!
I couldn't have done it without Ivan's help, I'm really grateful for it!

Unfortunately, the system is not perfect. When the Pi "presses" the buttons (connects them via the CD4016BC's output) it behaves a bit randomly, meaning that sometimes one press is registered by the thermostat as one press, other times as two presses and some other times as zero presses. Usually one press is one press. What this means in practice is that if I try to increase the temperature by 5 degrees, for example (this means 11 presses - 1 to put the thermostat into change mode and 10 to modify the temperature by 10*0.5 degrees), in about 30% of the attempts it really increases it by 5 degrees, in 30% of the cases it increases it by 5.5 degrees and in another 30% of the cases it increases it by 4.5 degrees instead of 5. In the remaining 10% of the cases it increases it by 4 or 6 degrees instead of 5. I have a bash script for repeating the push-release sequence as many times as needed and I use sleep inside it. I played around with the duration to press the button and the duration to release the button, but there doesn't seem to be a setting which makes it work in a deterministic way. Thinking back, I saw the same behavior when I was not using the Pi, but touching the wires together myself. I thought that my hand was not stable and the wires touched more than once, but it seems that the problem is different. I wonder if the resistor between the button ends (the resistor at the output of the CD4016BC) has anything to do with this. I can't realy remember what resistor value I used there in the end, but I do remember that I measured about 6-7 KOhms between the CD4016BC's outputs when they became connected (without any other resistors). Perhaps it's worth a try to short those output resistors and keep only the resistance given by the CD4016BC itself on the output.

There's also one other unfortunate fault in the system. Given the fact that I had to keep the cable between the Pi and the thermostat short (to avoid noise as much as possible), the Pi is close to the thermostat. and the Pi is generating heat :) Currently, when I'm not at the house, I want to set the thermostat to 8 degrees Celsius. But I fear that because the Pi is so close to it, when it measures 8 degrees, that might actually be only 4-5 degrees in reality (farther from the Pi).
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 Dec 01, 2013 7:15 am

Hi,
Un4Seen wrote:Unfortunately, the system is not perfect. When the Pi "presses" the buttons (connects them via the CD4016BC's output) it behaves a bit randomly, meaning that sometimes one press is registered by the thermostat as one press, other times as two presses and some other times as zero presses.
Decrease the resistors which are in series to the switches,
Optionally, you could also place an old web cam to RasPi to get a "control back loop" - to be able to check what is the temperature value on transmitter's LCD.
Un4Seen wrote:I have a bash script for repeating the push-release sequence as many times as needed and I use sleep inside it.
Bash minimal sleep time is 1 sec, right ?
It could be that this time is also close to a "repeat" timeout. I'd implement my own sleep utility being able to set press for around 300ms, or so. (If you need C code for this, let me know.)
Un4Seen wrote:But I fear that because the Pi is so close to it, when it measures 8 degrees, that might actually be only 4-5 degrees in reality (farther from the Pi).
A quick dirty hack could be a sheet of A4 card-paper placed between RasPi and the transmitter. It would prevent air flow between two of them.


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

Sun Dec 01, 2013 8:52 am

Yepp, I did think of these :)

I do have a webcam, to see what is going on and this morning it gave me an unpleasant surprise. I checked to see what is going on and, although the target temperature is still set to 8 degrees, there are 19 degrees in the house, in spite the fact that yesterday night is was only about 12 (and slowly going down). So something went wrong. Either I accidentally left the boiler on manual setting and it's ignoring the thermostat or the thermostat is measuring the heat from the Pi, not the real temperature. The Pi is in a cardboard box beneath the thermostat, so in a way they are "isolated", but there are holes on the cardboard box for the wires, so that might be the problem. The Pi's DS18B20 temperature sensor is showing always 3 degrees more (22 in this case), which could mean that the heat is coming out of the box right near it or the sensor could be a little off or the thermostat's sensor could be a little off, or both.

I have to make a run to the house, see what is really going on there...
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 Dec 01, 2013 2:04 pm

I went and checked it. Surprisingly nothing seems to be wrong. Everything works as expected. Probably the reason for the excess heating was that I shut off the heat radiator in the boiler room, at night the temperature went below zero and the boiler turned on to protect itself from freezing, but since the radiator in that room was turned off, it kept heating other parts of the house, not its own room. That's the best explanation I can find. So the system we've built is a success apart from minor flaws which I'll try to fix. I put the Pi, the temperature sensor and the thermostat as far from each other as I could (about 20 cm space plus the Pi in the cardboard box). Now the Pi's heat does not seem to be a problem anymore :)

PS: I really went off topic here. I apologise for that. I just really wanted to share this info :)
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

Tue Dec 03, 2013 10:52 pm

After a few days of testing I can say that my system is mostly working well. I'll have to try to decrease the resistors wired in series with the thermostat's buttons in the hope that this will remove that small amount of randomness that exists today in the "pressing" of the buttons.

However I seem to have another, more important, problem :( Sometimes, when the thermostat is turning the heating on or off, the boiler does not react to the command. The best explanation I can come up with is that it's not receiving the signal all the time. The thermostat and the boiler are placed about 6 meters away from each other, but there are 3 walls between them, two of which are simple brick walls, 15 cm thick each and the third one is a 55 cm thick brick wall, reinforced with a bit of iron net in some places. Perhaps these walls are blocking the signal? Some of these walls contain electrical (mains) wiring and there are also some metal objects (like heat radiators or water pipes attached to them). I will have to experiment the next time when I get a chance to visit the house. Anyway, approaching this from an electronic point of view, I have the following observations:
1. I read somewhere that the optimal length of radio transmitter antennas is 17.2 cm. This was for a 433 Mhz transmitter, I'm not sure this is the case with all transmitters. I wonder what the optimal length of the thermostat's antenna is. Currently it's a thin wire, which looks pretty regular (probably copper), coated with plastic, about 8 cm long. While I was working on soldering my own wires onto the buttons, I managed to damage the plastic coating of the antenna in one place, but I doubt that it matters. Should I change this antenna to a longer one? Could it help? If yes, how long should it be? Does thickness matter? Is copper wire the best, or some other metal is more suitable?
2. Could it be that the wires which I added into the thermostat for my own purposes are somehow shielding the thermostat's antenna from the boiler (creating a block between them)?
3. As you know, now the thermostat does not run off 3V battery power anymore, but 2.6V coming from RPI (3.3V reduced by a diode to around 2.6V). Could this also weaken the transmitted signal?

Generally speaking, is there a way to strengthen the signal sent by the thermostat?
Andras
http://iqjar.com

User avatar
DougieLawson
Posts: 36150
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Wi-Fi Thermostat

Tue Dec 03, 2013 10:57 pm

433MHz is a 0.6928406466512702m (69cm) wavelength
So 0.17321016166281755m (or 17.3cm) is 1/4 wavelength
So 8cm is about 1/8th wavelength
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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