tony359
Posts: 30
Joined: Mon Dec 21, 2015 9:59 pm
Location: Swindon, UK

simple temperature monitor and relay activation GUI

Sun Nov 12, 2017 7:21 pm

Hi there,
I am planning to make my own home temperature sensor based on my needs but for the time being I'd like to be able to create a simple GUI showing the temperature sensed by a MCP9808 and also a button to control a relay (it would be my manual override of the house thermostat).

I do not know much about programming but I am willing to learn. Could you possibly point me to the right direction please? What software do you recommend?

Thank you!
Tony

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: simple temperature monitor and relay activation GUI

Sun Nov 12, 2017 8:17 pm

you need to choose a language you want to use, for me it was python but it would be best for you to look through examples of languages and see if you can digest any of it, if you can then use that language.

if you dont want to put much effort in and decided to go for say python it would be worth googling raspberry python thermostat relay or something as such.
if you are wanting to do this yourself then break down your project into smaller goals.
follow guides to get a temp sensor reading, and guides of how to make an LED light up from a GUI, for graphics youll need to use an extension such as tkinter for python so look into tkinter button then make that button light up ur LED, then look into tkinter text window and put ur temp reading in that, change the LED for a relay and your done.
if you have an issues post back on here but under the forum for the language you choose and always try to post examples of ur code

tony359
Posts: 30
Joined: Mon Dec 21, 2015 9:59 pm
Location: Swindon, UK

Re: simple temperature monitor and relay activation GUI

Sun Nov 12, 2017 9:07 pm

Thanks Davies,
I have played with Python a little - very little. I tested my MCP9808 (temp sensor) with it and I was able to read a temperature. I managed to open/close the relay based on a set temperature.

I am happy to go ahead with Python and experiment - I was just worried that I could achieve the same result with a couple of clicks using some graphic code or similar but if code is what you recommend then I'd probably choose python too.

your idea of breaking down the projects into smaller goals is just great, thanks! I want to do this myself because 1. it's fun 2. I can't find an existing project that actually work 100% for me.

I'll give tkinter a go.
Cheers!

btidey
Posts: 1599
Joined: Sun Feb 17, 2013 6:51 pm

Re: simple temperature monitor and relay activation GUI

Sun Nov 12, 2017 10:33 pm

tony359 wrote:
Sun Nov 12, 2017 9:07 pm
Thanks Davies,
I have played with Python a little - very little. I tested my MCP9808 (temp sensor) with it and I was able to read a temperature. I managed to open/close the relay based on a set temperature.

I am happy to go ahead with Python and experiment - I was just worried that I could achieve the same result with a couple of clicks using some graphic code or similar but if code is what you recommend then I'd probably choose python too.

your idea of breaking down the projects into smaller goals is just great, thanks! I want to do this myself because 1. it's fun 2. I can't find an existing project that actually work 100% for me.

I'll give tkinter a go.
Cheers!
Another thing you might want to think about is where you want the GUI to appear; on local raspberry HDMI screen, on a dedicated lcd display, or accessibly remotely.

If the latter it may be worth thinking about making the GUI web based as that gives a lot of flexibility for where it is displayed (e.g. on phone). In this method you use a web server on the raspberry and use server methods to access the values obtained from the separate monitoring programs. Likewise buttons or other controls on the web interface can fire server methods to control things like the relay.

Check out things like https://opensource.com/article/17/3/ope ... spberry-pi for ideas on this approach.

tony359
Posts: 30
Joined: Mon Dec 21, 2015 9:59 pm
Location: Swindon, UK

Re: simple temperature monitor and relay activation GUI

Sun Nov 12, 2017 11:51 pm

ideally, as a final goal, I'd like having something like that. But I am not a developer and it may be too much to aim for. So far I may be happy to access the Pi via remote VNC - I don't need total control of heating, it's basically only for when I am coming home early or late!
But I'll have a look, maybe it's the way to go. Thanks for your input :)

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: simple temperature monitor and relay activation GUI

Tue Nov 14, 2017 12:44 pm

as btidey posted theres also web.py, i asked a question on here which i ended up answering myself but the post could be a good example of another option you have available (it was written in python 2.7 not tested on python 3+)
viewtopic.php?f=32&t=195379

the website is accessible locally by going to localhost:8080 or "your internal IP address":8080 from a computer/phone on the same network or if you allow remote access on your router to the computer/raspberry running the code then you can access from anywhere in the world using "your public IP address":8080

if you wanted to make a pretty website you can use a w3.css template from w3schools.com amending the html file to carry $def with (msg) at top, then use $msg where ever you want the info to be displayed

const314
Posts: 2
Joined: Thu Jul 27, 2017 10:55 am

Re: simple temperature monitor and relay activation GUI

Mon Dec 04, 2017 4:26 pm

Take a look at this article: https://medium.com/cloud4rpi/humidity-i ... c989c6f836
It is not about MCP9808 sensor, but the principle is the same.

Image

tony359
Posts: 30
Joined: Mon Dec 21, 2015 9:59 pm
Location: Swindon, UK

Re: simple temperature monitor and relay activation GUI

Wed Mar 07, 2018 11:30 am

Hi there,

I have built a basic unit which has been in use for a while - thanks all for your help!

I would like to add more sensors and more relays to the rest of the house but I don't want to add Pi's too - it would mean more units to keep up to date and to configure.

I was wondering if anybody could suggest something that plugs into the network and provides relays+sensors as a 'network board' that then interfaces with a single central Pi?

Cheers!
Tony

tony359
Posts: 30
Joined: Mon Dec 21, 2015 9:59 pm
Location: Swindon, UK

Re: simple temperature monitor and relay activation GUI

Thu Mar 15, 2018 10:56 pm

Anybody? I found ethernet controlled relay boards but not ethernet sensors.
I guess I could just pack another Pi with it. I don't mind, it's having 3-4 Pi's scattered around the home does not really makes me enthusiastic.

Return to “Automation, sensing and robotics”