Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 08, 2014, 04:36:12 pm
Quote
String::substring() will make a substring of the value, and String::parseInt() will make an integer of the substring.
Do you know where I can find an example of this?

Quote
No. You see stuff in the Serial Monitor application (or you would if you were running it). THAT is what we need to see.
Everything that would be shown in the serial monitor is displayed on the page.
Quote
You can see for yourself @ http://192.40.125.129:801
you can click the buttons and enter in a new integer value for the temperature and click submit and below all the buttons and the text entry is all the debug you are looking for.
2  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 08, 2014, 12:46:41 pm
I am using the mega. I can add the
Code:
client.println(F("Content-Type: text/html"));
but I have been more focused getting the code to work. I have updated the code so that all things debug are displayed on the webpage rendered by the arduino. You can see for yourself @ http://192.40.125.129:801 I assume that is what you meant by 
Quote
You've been asked repeatedly since this thread began to share what you see. ALL OF IT.
I have had the page publicly available since the beginning of this thread. Outside of that I'm not sure what you mean by share all of it. I will try moving that if statement to after the carriage return this evening.
3  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 07, 2014, 09:09:18 pm
So, after a little discovery, I have found that client.parseInt isn't parsing the integer from whats being received from the text input.
Code:
if (readString.indexOf("?S=") > 0) {
           int setTemp = client.parseInt();
           delay(5);
           Serial.print("Set Temp: ");
           Serial.print(setTemp);
//            break;
          }
is running . If I am understanding client.parseInt correctly, then it should be grabbing the first integer until anything other than an integer from the string being received. If this is the case then why aren't I getting the submitted value? OR... Have I completely missed the boat again???
4  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 07, 2014, 06:26:51 pm
Thanks PaulS!!!! I found the issue with the if statements! I was missing a curly bracket before
Code:
EthernetClient client = server.available();

Code:
void loop() {

  sensors.requestTemperatures();  // was in loop

  float tempC = sensors.getTempC(insideThermometer);
  if (tempC == -127.00) {
    Serial.print("Err");
  } else {
    //Serial.println(tempC);
    // lcd.print("/");
    currentTemp = (DallasTemperature::toFahrenheit(tempC));

  }// Create a client connection
  EthernetClient client = server.available();

Now I just have one more problem and then I believe this will be done. When I want to set a new temperature to achieve I have a text input with a submit button. When the submit button is pressed it should be sending
Quote
?S=75
instead its sending a 72. A 72 in the ascii chart is an r or an H.
Code:
char c = client.read();
Code:
          else if (c = 'S') {
            Serial.print("Set To ");
            setTemp = client.parseInt();
            Serial.println(setTemp);
            break;
          }
          //clearing string for next read

Also, I took out the switch case statements as hinted.  smiley-wink
5  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 07, 2014, 04:26:25 pm
Code:
             thermstate == 2;
Hmmm. No.

I don't think your problem, whatever it is, needs to be addressed using a state machine. I'm afraid you were led down a bunny trail there.

Quote
My if staements are looking for the button press "readString: GET /?coolon HTTP/1.1" but after that comes through I also get "readString: GET /favicon.ico HTTP/1.1". I don't know where this favicon.ico is coming from.
The browser is asking for it, to display on the tab, if using tabs. In general, you could just ignore this request, and return nothing.

Can you fix the statements that use == where = should be used, and then post the code again, summarizing what problems exist with this code?


I fixed
Code:
             thermstate == 2;
to be
Code:
             thermstate = 2;
and am still having the problem. My if statements wont run.
Code:
readString
is returning
Quote
GET /?coolon HTTP/1.1
as expected but
Code:
           if (readString.indexOf("?coolon") > 0) {
              thermstate = 2;
              digitalWrite(coolLED, HIGH);
              delay(1000);
            }

Still doesn't work.
6  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 08:45:43 pm
Found that if I add
Code:
            client.println("<link rel='shortcut icon' href='data:image/x-icon;,' type='image/x-icon'>");
            client.println("<TITLE>Online Digital Thermostat</TITLE>");

then I don't have GET /favicon.ico HTTP/1.1 coming through. It did't help my if statements though.  smiley-sad
7  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 08:31:33 pm
I also have found that none of my if statements that are dependent on the readString will run because I keep receiving
Quote
readString: GET /?coolon HTTP/1.1

thermstate: 0
73
readString: GET /favicon.ico HTTP/1.1

thermstate: 0
73
My if staements are looking for the button press "readString: GET /?coolon HTTP/1.1" but after that comes through I also get "readString: GET /favicon.ico HTTP/1.1". I don't know where this favicon.ico is coming from. Its not in my code anywhere that I can find. I'll be doing some research in the mean time but I thought it would be good to have here for anyone else with the same problem.
8  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 08:14:08 pm
Quote
Or did I completely miss what you were saying?
I'm afraid you did. The switch statement with only one case is wrong.

Setting thermstate to coolON when it is already equal to coolON seems pointless.

Thanks! Is this a bit better?
Code:
            if (readString.indexOf("?coolon") > 0) {
              thermstate == 2;
            }
            if (readString.indexOf("?heaton") > 0) {
              thermstate == 4;
            }
            if (readString.indexOf("?recircon") > 0) {
              thermstate == 5;
            }
            if (readString.indexOf("?thermoff") > 0) {
              thermstate == 3;
            }
            if (c == 'S') {
              Serial.print("Set To ");
              setTemp = client.parseInt();
              Serial.println(setTemp);
              break;
            }
            //clearing string for next read
            readString = "";
            Serial.println(currentTemp);

            switch (thermstate) {

              case 2:
                cool();
                break;

              case 4:
                heat();
                break;

              case 5:
                recirc();
                break;

              case 3:
                off();
                break;

}
          }

9  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 03:16:19 pm
 Can anyone help me understand what I have done wrong here? I have followed http://www.gammon.com.au/forum/bbshowpost.php?id=12316 to the best of my ability and instead of thermstate being updated with one of these (coolON, thermOFF, heatON, recircON) it just always gets a number 1 . I'm open to just getting a really good resource that explains what to do and not to do. From what I have read enum isn't really any different than int in that it is for storing an integer. I'm not sure how any of this is to work if I'm trying to store a word!
Code:
enum { coolON, thermOFF, heatON, recircON } thermstate = thermOFF;


Code:
if (readString.indexOf("?coolon") > 0) {
              switch (thermstate) {

                case coolON:
                  thermstate = coolON;
                  cool();
                  break;

              }
              if (readString.indexOf("?heaton") > 0) {
                switch (thermstate) {

                  case heatON:
                    thermstate = heatON;
                    heat();
                    break;
                }
                if (readString.indexOf("?recircon") > 0) {
                  switch (thermstate) {

                    case recircON:
                      thermstate = recircON;
                      recirc();
                      break;
                  }
                  if (readString.indexOf("?thermoff") > 0) {
                    switch (thermstate) {

                      case thermOFF:
                        thermstate = thermOFF;
                        off();
                        break;
                    }
10  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 02:07:52 pm
Code:
            if (readString.indexOf("?button1on") > 0) {
              switch (thermstate) {
                  thermstate = coolON;
                case coolON:
                  cool();
                  break;

              }
Using a switch statement generates more code than an if statement, when there are less than three cases. Assigning a value to themrmstate in a switch statement, outside of a case statement is wrong. Nothing should happen in a switch statement that is not part of a case statement.

So...
Like this.
Code:
            if (readString.indexOf("?coolon") > 0) {
              switch (thermstate) {

                case coolON:
                  thermstate = coolON;
                  cool();
                  break;

              }


Or did I completely miss what you were saying?
11  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 12:56:14 pm
Can you give me some insight as to why I am receiving a 1 for my thermstate instead of the actual thermstate? That would be very helpful in dubugging if I could fix that.
12  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 12:24:27 pm
After thinking about it a bit more it seemed like I would have to call the thermstate in the functions so I changed it a bit. Still no good though.
13  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 12:12:34 pm
The link you provided was for something other that the state machine example. I found it and have been working with it. I tried an implementation of it in my thermostat but it doesn't seem to do anything. my thermstate (the state that should be stored) always comes back as the number 1.
I uploaded the new code to this post.... really, I did.. LOL smiley-wink
14  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 11:00:53 am
Calling functions seems in conflict with the thermostat paradigm to me.
What do you mean?

Quote
Don't you really just want to create 4 States?

Cool
Heat
Recirc
Off

then accept inputs to modify the state (set points) or change the states...
I thought thats what I did?

Quote
I'd take a look at the Nick Gammon State Machine example.
I don't really get what I'm looking at here...

15  Using Arduino / Programming Questions / Re: Help with online Thermostat Please on: July 06, 2014, 10:38:56 am
PaulS... Please refrain from "helping" me. you have not been of any "help" in the past. Thanks!
Pages: [1] 2 3 ... 8