Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

system for controlling and monitoring device

Wed Jul 18, 2018 2:13 pm

I am looking for some advice. I am missing basic of project design step. I am not really going to make this system but I am taking one example for easy understanding.

Suppose I want to make smart system that would be monitor and control temperatures of AC over web browser. I am going to use raspberry in my project and I have all the component's required for project.

My research say I have to run server on raspberry pi. so that It can be control AC over web browser. But How to monitor temperature of AC?

I think, I have to store the temperature reading on database. so I can see the AC temperature and I can control as I want to use.

I think , I have to run one server on raspberry like apache to adjust AC temperature and I have to run database server on raspberry pi to monitor temperature reading.. Am I correct ?

mutrised
Posts: 44
Joined: Thu Nov 08, 2012 12:41 am
Location: France

Re: system for controlling and monitoring device

Wed Jul 18, 2018 2:33 pm

Hi,

Depend of what you want to do. If you want full temp history then yes, you may need a database, or a least a "log file".
If you just need to set a temperature. Database seems a bit overkilled... since you'll be writing only several values in it.
You would rather go for a single file (txt, JSON, or whatever).

You would need apache to serve file over HTTP and monitor/set the temperature. So Apache would need write access to the above described file.

And you finally need a backend script (python is best to handle GPIO on RPI), which will read the temperature you want, check ambient temperature thanks to I2C temperature sensor for example. And trigger external device (through relay ?) to heat of cool.

You would like to monitor directly the setting of you AC device ? I'm afraid you may not find the help you ask for here. This needs a bit of hacking that depends a lot of the device :/. And... keep in mind you may brake everything ^^.
RPI2B 7/24 - web, NAS/media, Owncloud and more
RPI0 7/24 - VPN, DHCP, DNS (including filtering), wakeonlan proxy
RPI0W - VPN gateway providing secure WIFI AP and network router, some kind of internet BOX when on the move ;)

drgeoff
Posts: 9365
Joined: Wed Jan 25, 2012 6:39 pm

Re: system for controlling and monitoring device

Wed Jul 18, 2018 2:38 pm

Your project does not require a database.

You do need something which measures the temperature and somehow feeds that into the RPi as a number which can be put in the appropriate page on the web server.

You also need some way of getting whatever commands you click on the web page out of the RPi and control the air conditioner.

User avatar
The Traveler
Posts: 360
Joined: Sat Oct 21, 2017 3:48 pm

Re: system for controlling and monitoring device

Wed Jul 18, 2018 2:38 pm

Your basic understanding is correct. By way of example, if you wanted to keep it fairly simple and scripted in Python, you could use Flask: http://flask.pocoo.org/ for the web server and Sqlite3: https://www.sqlite.org/index.html to hold the data. Both can be loaded on your RPi using a package manager. As pointed out, you can dispense with the database unless you wanted to keep the data for analysis later on. As your requirements are simple, no need to use Apache or any other dbms like mariaDB and add unneeded complexity.

How you monitor the temperature depends on what physical sensors you use.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

Heater
Posts: 12657
Joined: Tue Jul 17, 2012 3:02 pm

Re: system for controlling and monitoring device

Wed Jul 18, 2018 3:41 pm

Fan174,
I am not really going to make this system but I am taking one example for easy understanding.
In which case I will not really tell you how to do this, just offer some clues...
Suppose I want to make smart system that would be monitor...[temperature]
So just read temperatures from whatever temperature measuring devices you have in whatever programming language like to do it in. There are many such devices and many libraries in all kind of languages to help with that.
...and control temperatures
Without any idea of what you are using to raise or lower temperature it is impossible to advise. But again most any hardware can be controlled from a Pi using whatever language you like given a suitable hardware interface.

With a means of measurement and a means of control you have everything you need to set up a "smart device". That is to say a normal program that takes temperature as an input and controls your heater/cooler in order to reach some required temperature.
My research say I have to run server on raspberry pi. so that It can be control AC over web browser.
Ah, if you want to monitor what your system is doing and/or set it's parameters from a web browser you will need a web server.
But How to monitor temperature of AC?
See above. It all depends on your temperature sensor how you connect to it and read it's temperature. Cannot advise further without a specific device in mind.
I think, I have to store the temperature reading on database
Why? If you want to record a history of temperatures over time then by all means save them to a database. Not really required for basic temperature control.
I have to run one server on raspberry like apache
Apache or other web server is not required. One could create the whole project you have defined so far in a few tens of lines of Javascript running under node.js. Or in Python using Flask or many other ways. In fact I would argue that using a web server like Apache just makes the whole thing more complex than it needs to be.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Re: system for controlling and monitoring device

Wed Jul 18, 2018 5:22 pm

let's make it simple

There are three case
1. Control the AC
2. Monitor the AC
3. Control and Monitor AC

Control the AC : If I only want to turn on/off AC. I have to run any one webserver to like Apache, Flask, node.js ..

Monitor AC : If I only want to see the temperature of AC over the time. I have to run any one database server like MSSQL, MySQL..

Control and Monitor AC : I have to install one server (Apache, Flask, node.js ) for controlling AC. And one database server(MSSQL, MySQL) for monitoring temperature of AC. If I can see the current temperature then I can control the temperature of AC.

Heater
Posts: 12657
Joined: Tue Jul 17, 2012 3:02 pm

Re: system for controlling and monitoring device

Wed Jul 18, 2018 5:47 pm

Yes and no.

All depends on what it is you actually want to do.

1) Something to read sensors is required if you want to measure temperature.

2) Something to command actuators is required if you want to control temperature. ("actuator" could be just a heater but may also include fans etc)

3) A web server is required if you want to observe and/or control this from a browser.(Could be anything from Apache/nginx to a hand made web server in node.js or Python or whatever)

4) A database is required if you want to store a historical record of temperature measurements and/or control commands and/or whatever else. ("database" could be just a file you write to)

Without further specific details of requirements it's a waste of time us talking about it. Especially as you say you are not actually building such a thing.

What is this really about? Is it a homework assignment?

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Re: system for controlling and monitoring device

Thu Jul 19, 2018 12:04 am

Heater wrote:
Wed Jul 18, 2018 5:47 pm
What is this really about? Is it a homework assignment?
All depends on what it is you actually want to do.
No, I am confused, I know database is use to store the information. I don't understand when I need to use database server.

I am not going to monitor and control AC really. This is just example for understanding but I am interested to make similar type of project.

let's say in my web browser there are five button's
  • Start button : start button to turn on AC
  • Stop button : Stop button to turn off AC
  • increase button : increase button to increase temperatures
  • Decrease button: decrease button to decrease temperature
  • Temperature Button: This button to see the current temperature
If I want to increase or decrease the temperature of AC, then first of all, I should know what's temperature now. I will see the current temperature on web browser and then I will take decision to increase or decrease temperature

Do I have to use database in this project. I think yes because I would store the all reading of temperature in database and so I can easily monitor temperature value on web web browser

Heater
Posts: 12657
Joined: Tue Jul 17, 2012 3:02 pm

Re: system for controlling and monitoring device

Thu Jul 19, 2018 12:15 am

No. You do not need a database for such a simple control task.

PhatFil
Posts: 1233
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: system for controlling and monitoring device

Thu Jul 19, 2018 2:41 am

you would only need some sort of database If you were interested in recording either a simple log of temperatures or more usefully an audit trail of activity, that is logging an entry for every time the A/C is switched on/off and if its switched manually via the web interface or automatically by the rules you program in.

as is without logging information your system has a single variable the target temperature and all programming languages/tools suitable for such a task will allow you capacity for significantly more than one dynamic variable

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Re: system for controlling and monitoring device

Thu Jul 19, 2018 3:23 am

Heater wrote:
Thu Jul 19, 2018 12:15 am
No. You do not need a database for such a simple control task.
please let me know in which condition do you use both server web server and database server.

It would be batter if you take one example

Heater
Posts: 12657
Joined: Tue Jul 17, 2012 3:02 pm

Re: system for controlling and monitoring device

Thu Jul 19, 2018 5:57 am

Fan174,
please let me know in which condition do you use both server web server and database server.
See my previous post: viewtopic.php?f=63&t=218418#p1342373
It would be batter if you take one example
Example: This forum.

Return to “General discussion”