I am in the process of getting to know my YUN, but I needed to ask some general questions related to the sketch and control mechanisms.
The project:
I am gathering data from sensors. Generally speaking, I want the sketch to be on autopilot by gathering the said data and monitoring it in the background, even if I am streaming it to a local web page merely to see it.
At some point, based on parameters established in my sketch initially, I want the sketch to "react" and do something, whether that is to turn on a light based on my light sensor reading, or turn on a fan because of a temperature reading.
Based on the number of articles I've read and the simple sketches provided for the YUN in the "Examples" section, I know I can respond via Web by using various programming methods including Ardunio code, HTML, JS, python, etc
The Question:
Without rewriting my sketch can I reset parameters externally, ie on the local Web page, to overwrite, or at least ignore, my initial parameters.
For example, if my initial sketch hardcoded Temperature parameters are set to turn the Fan on when T > 85 degrees F, then turn off again when the T < 78 degrees F--but now I want to lower my high point to only 80 degrees F instead of 85, and lower my lower point to 75 degrees F. Can I do this without recoding my sketch and reloading it?
I am bearing in mind that some pin(s) on the Arduino board may have to be manipulated to actually effect a change as in the examples mentioned.
If it would be better to do the major programming through the web code I am okay with that since this is to be a wireless device project anyway.
I just need some intelligent direction here and some thoughts from the more experienced programmers.
TY, houdinihar
Without rewriting my sketch can I reset parameters externally, ie on the local Web page, to overwrite, or at least ignore, my initial parameters.
Of course not.
You CAN have the Arduino read the GET requests that the browser makes, and NOT return the same page every time. Instead, return a page, after taking action, based on what the browser asked for.
For example, if my initial sketch hardcoded Temperature parameters are set to turn the Fan on when T > 85 degrees F, then turn off again when the T < 78 degrees F--but now I want to lower my high point to only 80 degrees F instead of 85, and lower my lower point to 75 degrees F. Can I do this without recoding my sketch and reloading it?
You should be able to. In your server code set the deg values as a variable, then send new variable values to the server via client GET request.
Thank you both PaulS and zoomkat. I will try these suggestions.
PaulS what do you mean exactly by this:
and NOT return the same page every time
So, are you saying I could create multiple html pages and place them, say on my SD card in a projects folder, and call them at will thru hyperlink calls, or do you mean something else totally altogether?
I mean that if the browser makes a GET request like GET / HTTP1.1, you should return the main page. If the browser then makes a GET request like GET /favicon.ico HTTP1.1, you should NOT return the main page. If the browser makes a GET request like GET /?Temp=37&LED7=on HTTP 1.1, the response should indicate that the temperature set point was changed and the LED on pin 7 is now on.