Search

Register

Thanks for signing-up! You will receive an email with further instructions to activate your account!

username already taken
You already have an account? .

Login

Forgot password?
Don't have an account yet? Register now for using the UI-Designer and the forum or creating projects.
Login to create topics and posts!



Basic thermostat control

#1 Sept. 24, 2013 13:32:48 by ruud835

Basic thermostat control

Hello,

I'm Ruud and i want to control my heater with my iphone.
(Reading temperature, setting a temperature so the heater stops when reaching this temperature)
The hardware i want to use:
Raspberry Pi with Wifi
Piface
DS18B20 (temp sensor)

Because i'm pretty new in programming and have not yet a Raspberry :-( (network knowlegde is good)
i want to know if this is programmable with NetIO?

I hope someone have an answer for me and excuse me for my bad englisch.

Kind regards Ruud

#2 Sept. 25, 2013 09:25:59 by david.eickhoff

Basic thermostat control

Hi Ruud, you can build such a system in general with NetIO.

What you would need to do before setting up NetIO:
- check how the DS18B20 must be connected to the GPIOs (or to the piface shield), I guess this is pretty straight forward: http://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&limitstart= (it is in german, but maybe google translate will do the trick)

- check how to control your heater electrically, is there an interface or is it just power on / power off? for the latter case, you could probably use the relays on the piface shield. Before connecting a heater, try to connect an LED for testing.. remember that the relay has a limits (20Volt, 5Ampere)

- now go into the software side and get all libraries to control the piface shield and read the temperatur sensor “manually” with a small python or bash script.. for this you would need to learn a little bit about python

- if you are able to read the sensor and control the heater, check out one of the python server implementation (for example http://en.gnublin.org/index.php/NetIO ), remove all the gnublin stuff and use the structure to call your read and write methods.

- then you can setup NetIO if the tcp server is running, this would be quite easy I guess

Bests
David

#3 Sept. 29, 2013 09:33:27 by ruud835

Basic thermostat control

Thank you very much David for your help.

The connecting part with the heater is clear now for me.
The only thing that is not quite clear for me is the connecting part
between the iPhone and raspberry.
Do you mean i have make a tcp shocket driver on the raspberry for the communication with netio?
(I can make a VPN connction by the way)
And after that i can program with netio the thermostat function?

Grtz Ruud

#4 Sept. 29, 2013 10:31:36 by david.eickhoff

Basic thermostat control

Correct, you need TCP Socket Server (not a ‘driver’). See this example: http://netio.davideickhoff.de/forum/topic/141/

(there are a few more examples in this forum)

In the big if-else part, you can define your own functionality. If this is running, test with telnet or netcat if the functions work. For example you have a command “set temp x”:

telnet <ip of raspberry> <port>
set temp 23

If this works with telnet, you can then create a netio configuration, enter the connection details in the ‘general-tab’ with the correct ip and port. then add a button and define the ‘sends’ attribute to be “set temp 23” . Start the app, sync the configuration and see if it sends the command.

I would also add some print statements to the python server on the raspberry to check if the commands come in correctly.

#5 Oct. 16, 2013 11:30:43 by ruud835

Basic thermostat control

Hi David, thank you for your support.
I have put some scripts of other people together.
This script (i hope this is the good one) works fine but not with NETIO.
I can get a connection but what i want is the “settemp()” controlled by my Phone (with a slider)
instead of a file on the raspberry
Also i can't get the “currtemp()” readout on my Phone.

I hope you can help me with the right read and send comment for my Phone

Kind Regards Ruud

Attachments:
attachment temp8.py (2.8 KB)

#6 Oct. 16, 2013 20:46:50 by david.eickhoff

Basic thermostat control

oh, why do you have this infinite loop? the handle methods is called multiple times, if there is data available.. if you want something to run in parallel (that holds the temperature) you should do this in a separate thread or process.. what do you mean with “it works fine?” does it work with telnet?

#7 Oct. 16, 2013 22:26:17 by ruud835

Basic thermostat control

Thank you david for mentioning other methods. i'm totally new in programming, that's why i paste scripts together ) (it was also the wrong script)
What i mean with “it works fine” is that the script controls the relay automaticly by the temp sensor
Also when i change the settemp() in var/bin/thermostat file with telnet. So for me this is a good starting point for the next step: controling the settemp() with the APP and read the temperature with the APP

What i like to know is how i can readout the temperature with the app and how do i have to setup a slider for controling the settemp. Mybe you can give me an example so i can change my script for these functions.

Kind Regards

Ruud


Attachments:
attachment furnace.py (2.7 KB)

#8 Oct. 17, 2013 09:34:47 by david.eickhoff

Basic thermostat control

first, you do not handle the incoming command.. every command you are sending from the app will appear in the self.data variable, gut you actually never use this to set a temperature

so you would need something like (pseudocode)
if self.data.startswith(“set temp”):
settemp(self.data)

Maybe you confuse telnet with an ssh connection? if the python script is running, you should go to your pc and use telnet to check if everything works:

telnet 192.168.0.90 54321    (change to the IP of your rpi)
once connected you enter the commands, for example:
set temp 23

in the script, the self.data would be “set temp 23” then, so you must check the incoming data and handle it properly.

You set the temperature through a tcp connection, so you wouldn't need the file

Edited david.eickhoff (Oct. 17, 2013 12:45:37)

#9 Oct. 17, 2013 18:43:20 by ruud835

Basic thermostat control

Wow!! Thanks David for your time. This is excactly what i needed

Grts Ruud