LED not lighting when it should.

Hey, so I have this code that pulls data from a server, parses it, and stores two integers in variables. Based on what these integers are, the LED attached to pin 13 should be lighting, but it’s not. I can’t figure out why, but I’m new to all this. Can someone spot what’s wrong with my code? I do know that my variables are what they should be, because I’m a uncomment all the serial command, the variables print actually what they should. This is on a asynclabs yellow jacket wifi board.

// A sketch that downloads heat index and weather condition from local server
// and displays it using RGB LEDS.


#include <WiServer.h>


#define WIRELESS_MODE_INFRA      1
#define WIRELESS_MODE_ADHOC      2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,0,7};      // IP address of WiShield
unsigned char gateway_ip[] = {10,0,0,1};      // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};      // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"XXXXXXXXX"};            // max 32 bytes

unsigned char security_type = 3;      // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"XXXXXXX"};      // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 
  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,      // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00      // Key 3
};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


//Variables
int ledPin = 13;
char Temp[4];
char Rain[2];
int t;
int r;

// IP Address for local server
uint8 ip[] = {10,0,0,9};

// A request that gets the latest data from server
GETrequest getWeather(ip, 80, "10,0,0,9", "/html/weatherData.txt");


void setup() {
  
  pinMode(ledPin, OUTPUT);
  
  // Initialize WiServer 
  WiServer.init(NULL);
  
// Serial.begin(57600);
  WiServer.enableVerboseMode(false);
  
  // Have the processData function called when data is returned by the server
  getWeather.setReturnFunc(processData); 

}


 // --- Function that process data from a .submit request
    void processData(char* data, int len) {
      int myPointer=0, foundit=0;
      if (len > 0) { // if len of packet greater than 0 then do following
        memset(data, ' ', sizeof(data));  // initialize to empty
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read
          char theChar=data[ix]; // read 1 character
          if ((theChar=='|') || (foundit!=0)) { // found the pointer
            if((foundit!=0) && (theChar!='\n') && (theChar!='\t')) { // If foundit already set to true, and char isn't junk, then add char to wiDateTime
              data[myPointer] = theChar; // add qualified char to wiDateTime
              myPointer++; // increment wiDateTime pointer
            }
            foundit=1; // terminator was found so foundit = true
          }
        } // if the pointer wasn't found in this packet, then it'll do the same to the subsequent packets, until the pointer is found
        if (foundit!=0) {
          // The terminator was found, now split the string into light_sensor, door_sensor, lounge_pir, hallway_pir
          sscanf (data,"%[^','], %[^',']", Temp, Rain);
         // the last variable is limited to the number of bytes expected, so that sscanf doesn't add extra bytes
         
          r = atoi(Rain);
          t = atoi(Temp);
         
        // Serial.println(r);
        // Serial.println(t);
         
         }  
      }  
  }
      
        
  
// Time (in millis) when the data should be retrieved 
long updateTime = 0;

void loop() {
  
 if (t >= 85 && r == 0) {
    digitalWrite(ledPin, HIGH); }
  

  // Check if it's time to get an update
  if (millis() >= updateTime) {
    getWeather.submit();    
    // Set update time in milliseconds
    updateTime += 1000 * 30;
  }

  // Run WiServer
  WiServer.server_task();


  delay(10);
}
      if (len > 0) { // if len of packet greater than 0 then do following
        [glow]memset(data, ' ', sizeof(data));  // initialize to empty[/glow]
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read

Fill the buffer with spaces1 and then process what’s in the buffer. I seriously doubt that’s what you want.

1 The way memset is called, only the first two bytes of data are filled with spaces. I also doubt this is what you want.

Sorry, I should have mentioned that the segment of code that parses the txt file is taken from here: http://asynclabs.com/forums/viewtopic.php?f=19&t=314#p1898

Would the code that you highlighted cause my problem. I thought that the parser code was working fine, but I don't have a full understanding of how it works.

You commented out the code that showed the parsed values of r and t. You don’t have a statement to echo the input. So, we have no way of knowing whether the input is correct, and whether the parsing is done correctly. Although, as Coding Badly pointer out, overwriting the first two characters with spaces hardly seems like a smart thing to do.

You only turn the LED on when the temperature is above 85 and rain is 0.

You haven’t shown us that these two values really are 85+ and 0. They may not be, which might explain why the LED is not being turned on.

Also, note that once the LED does come on, there is no code to ever turn it off again. I’m not sure I want to buy one of whatever it is you are building, yet.

“Turns the light on forever when the temperature reaches 85 degrees on a dry day. You need one now. You know it. Order now! Operators are standing by.”

This is incomplete code that I am testing. I plan to expand on it. That's why I have the arbitrary temp values in the if statement for r and t. The serial parts of the code are just for testing purposes, if I uncomment them and run the code, this is what I get on the serial monitor:

http://img198.imageshack.us/img198/7414/serial.png

So, unless I'm misunderstanding something, it seems like the parsing code is doing its job, as the text file that is being parsed looks like this:

|98,0,

Once this code is finished, I plan to removed the Serial code completely, as I will not be using any serial devices. This board is going into a lamp with RGB LEDs. The problem is, I have no idea why I can't even make the pin 13 and its LED go HIGH.

The problem is, I have no idea why I can't even make the pin 13 and its LED go HIGH.

One possibility is that this call...

// Run WiServer WiServer.server_task();

...never returns. Put a Serial.println after it.

The possibility that Coding Badly pointed out is why I wanted to see the data being processed in processData. If that function never gets called, that would explain why your light doesn't come on.

Serial output is very useful for debugging code.

Do you need to see more than the serial output screenshot I posted above? I put another Serial.print() function where suggested, and It printed fine.

So, it appears as though the parsing code is being called, and working correctly. It implies that the loop function is looping. So, something is either stepping on r and t, or the LED is burned out.

Add some Serial.print and Serial.println statements in loop, to print r and t with descriptive labels.

Serial.print("r: ");
Serial.println(r);

Nothing obvious jumps out as being wrong with the code.

[edit]PS: You might want to change this:

  WiServer.enableVerboseMode(false);

to

  WiServer.enableVerboseMode(true);

to see if you learn anything.[/edit]

Ok, I did both those things. The LED is not burned out by the way, the Blink example runs as it should. Still haven’t gotten the LED to light in my code though. I even removed the if statement once and just put digitalWrite(ledPin, HIGH); in the loop, and it didn’t light! no idea whats going on…

Here’s what the serial monitor is ouputting now:

t: 99
r: 0
t: 99
r: 0
t: 99
r: 0

Over and over again, obviously, as it’s in the loop.

Current Code:

// A sketch that downloads heat index and weather condition from local server
// and displays it using RGB LEDS.


#include <WiServer.h>


#define WIRELESS_MODE_INFRA      1
#define WIRELESS_MODE_ADHOC      2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,0,7};      // IP address of WiShield
unsigned char gateway_ip[] = {10,0,0,1};      // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};      // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"SSID Here"};            // max 32 bytes

unsigned char security_type = 3;      // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"Password Here"};      // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 
  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,      // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00      // Key 3
};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


//Variables
int ledPin = 13;
char Temp[4];
char Rain[2];
int t;
int r;

// IP Address for local server
uint8 ip[] = {10,0,0,9};

// A request that gets the latest data from server
GETrequest getWeather(ip, 80, "10,0,0,9", "/html/weatherData.txt");


void setup() {
  
  pinMode (ledPin, OUTPUT);
  
  Serial.begin(57600);
  
  // Initialize WiServer 
  WiServer.init(NULL);
  
  WiServer.enableVerboseMode(true);
  
  // Have the processData function called when data is returned by the server
  getWeather.setReturnFunc(processData); 

}


 // --- Function that process data from a .submit request
    void processData(char* data, int len) {
      int myPointer=0, foundit=0;
      if (len > 0) { // if len of packet greater than 0 then do following
        memset(data, ' ', sizeof(data));  // initialize to empty
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read
          char theChar=data[ix]; // read 1 character
          if ((theChar=='|') || (foundit!=0)) { // found the pointer
            if((foundit!=0) && (theChar!='\n') && (theChar!='\t')) { // If foundit already set to true, and char isn't junk, then add char to wiDateTime
              data[myPointer] = theChar; // add qualified char to wiDateTime
              myPointer++; // increment wiDateTime pointer
            }
           foundit=1; // terminator was found so foundit = true
          }
        } // if the pointer wasn't found in this packet, then it'll do the same to the subsequent packets, until the pointer is found
        if (foundit!=0) {
          // The terminator was found, now split the string into light_sensor, door_sensor, lounge_pir, hallway_pir
          sscanf (data,"%[^','], %1[^',']", Temp, Rain);
         // the last variable is limited to the number of bytes expected, so that sscanf doesn't add extra bytes
         
          r = atoi(Rain);
         t = atoi(Temp);
         
         }  
      }  
  }
      
        
  
// Time (in millis) when the data should be retrieved 
long updateTime = 0;

void loop() {
  
  
  if(t>=85 && r == 0) {
  digitalWrite (ledPin, HIGH); 
  }
  
    // Check if it's time to get an update
 if (millis() >= updateTime) {
   getWeather.submit();    
    //Set update time in milliseconds
   updateTime += 1000 * 30;
  }

  // Run WiServer
  WiServer.server_task();
  
  Serial.print("r: ");
  Serial.println(r);
  Serial.print("t: ");
  Serial.println(t); 


  delay(10);
}

I’m starting to think there is some glitch in the WiShield library or something. This makes no sense.

I think I figured it out. I guess the Wifi shield uses pin 13 for SPI, I switched the ledPin to 6 and put a led on it, and it works.

Thanks for letting us know. I guess I assumed that you know which pins were free, and that is why you were using pin 13 for the LED. I never occurred to me to ask the obvious question about the pins that the shield uses.

Yeah I should have realized it sooner. Pin 13 is such a natural one to use for testing purposes it didn’t occur to me to double check which ones the shield used.

Well now that that’s figured out, I’m trying to write the rest of the code so the RGB LEDs will light according to the temp and rain data. I can’t get it to work right, so my thinking on how to program this must be wrong. Here’s what I have:

// A sketch that downloads heat index and weather condition from local server
// and displays it using RGB LEDS.


#include <WiServer.h>


#define WIRELESS_MODE_INFRA      1
#define WIRELESS_MODE_ADHOC      2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,0,7};      // IP address of WiShield
unsigned char gateway_ip[] = {10,0,0,1};      // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};      // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"XXXXXX"};            // max 32 bytes

unsigned char security_type = 3;      // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"XXXXXXX"};      // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 
  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,      // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00      // Key 3
};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


//Variables
int redLed = 3;
int greenLed = 6;
int blueLed = 5;

char Temp[4];
char Rain[2];
int t;
int r;

// IP Address for local server
uint8 ip[] = {10,0,0,9};

// A request that gets the latest data from server
GETrequest getWeather(ip, 80, "10,0,0,9", "/html/weatherData.txt");


void setup() {
  
  pinMode(redLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  
  Serial.begin(57600);
   
  WiServer.init(NULL);
  
  WiServer.enableVerboseMode(false);
  
  // Have the processData function called when data is returned by the server
  getWeather.setReturnFunc(processData); 

}


 // --- Function that process data from a .submit request
void processData(char* data, int len) {
      int myPointer=0, foundit=0;
      if (len > 0) { // if len of packet greater than 0 then do following
        memset(data, ' ', sizeof(data));  // initialize to empty
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read
          char theChar=data[ix]; // read 1 character
          if ((theChar=='|') || (foundit!=0)) { // found the pointer
            if((foundit!=0) && (theChar!='\n') && (theChar!='\t')) { // If foundit already set to true, and char isn't junk, then add char to wiDateTime
              data[myPointer] = theChar; // add qualified char to wiDateTime
              myPointer++; // increment wiDateTime pointer
            }
           foundit=1; // terminator was found so foundit = true
          }
        } // if the pointer wasn't found in this packet, then it'll do the same to the subsequent packets, until the pointer is found
        if (foundit!=0) {
          // The terminator was found, now split the string into light_sensor, door_sensor, lounge_pir, hallway_pir
          sscanf (data,"%[^','], %1[^',']", Temp, Rain);
         // the last variable is limited to the number of bytes expected, so that sscanf doesn't add extra bytes
                r = atoi(Rain);
                t = atoi(Temp);
                
                Serial.println(t);
                Serial.println(r);
     
         
         }  
      }  
      
  }
      
        
        
     
long updateTime = 0;

void loop() {
  
breakout:
  
      if (millis() >= updateTime) {
         getWeather.submit();    
                  
           //Set update time in milliseconds
           updateTime += 1000 * 30;  }

  // Run WiServer
  WiServer.server_task();


  delay(3000);
  
  while(t>=80 && r==1) {
                  digitalWrite(redLed, HIGH);
                   delay(1000);
                    digitalWrite(redLed, LOW); 
                    digitalWrite(blueLed, HIGH);
                      delay(1000);
                      digitalWrite(blueLed, LOW); 
                    
                   if (millis() >= updateTime) {
                     goto breakout; }
                }
   
  
  while(t>=80 && r==0) {
              digitalWrite(redLed, HIGH);
            
              if (millis() >= updateTime) {
                goto breakout; }
   
             }
  
              
  while(t<80 && r==0) {
          digitalWrite(greenLed, HIGH); 
         
          if (millis() >= updateTime) {
           goto breakout; }
   
           }
    
              
   while(t<80 && r==1) {
            digitalWrite(greenLed, HIGH);
            delay(1000);
            digitalWrite(greenLed,LOW); 
            digitalWrite(blueLed, HIGH);
            delay(1000);
            digitalWrite(blueLed, LOW); 
           
           if (millis() >= updateTime) {
            goto breakout; }
         
           }
       

}

All that happens is the the greenLed pin goes HIGH, and nothing prints on the serial. Commenting out all the while loops gets the serial to start printing what it should again. I’ve been trying to figure it how for hours but no luck so far. How should I be doing this?

Note that when you goto breakout, that that is exactly the same as reaching the end of loop. In other words, got rid of the breakout label and all the goto statements. Replace them with break;.

Using millis and delay together implies a lack of understanding of one or the other.

If the status of the red, green, and blue LEDs is to change every 30 seconds, why do you delay for 3 seconds (10% of the time) after getting new values before changing the LED states?

You should have one while loop after reading the new values, that executes while millis() is less than updateTime.

Inside that while loop, you want if/else if/else statements to select the action to perform.

while(millis() < updateTime)
{
   if(r == 0)
   {
       if(t < 80)
       {
       }
       else
       {
       }
   }
   else
   {
       if(t < 80)
       {
       }
       else
       {
       }
   }
}

Doing this will mean that on each pass through loop, you need to call getWeather.submit(), update millisTime, and call WiServer.server_task().

While this will simplify the structure of the program, I don’t see what is causing the issue you are having. So, if you want to stick with it (ugh!), I’d put Serial.print() calls inside loop, to print the time that loop gets called, each time it gets called. I’d print the time that updateTime gets set to.

Then, inside each while loop, I’d print the time again (adding a small delay as necessary) to see how long it stays in each while loop.

I’ll also note that updateTime should be an unsigned long, not a long.

Ok, I tried to implement your solution. Still can’t get it to work. It seems like any time I add ANYTHING to the loop() function except for the updating if statement and WiServer.server_task(), my parsing code stops working, which makes no sense. Also, I want to be able to do things with the LEDs that require loops (blinking, fading, etc.). How would I be able to do that with an if/else structure? That’s the reason I had a bunch of while loops in my solution. Thanks.

//Variables
int redLed = 3;
int greenLed = 6;
int blueLed = 5;

char Temp[4];
char Rain[2];
int t;
int r;

// IP Address for local server
uint8 ip[] = {10,0,0,9};

// A request that gets the latest data from server
GETrequest getWeather(ip, 80, "10,0,0,9", "/html/weatherData.txt");


void setup() {
  
  pinMode(redLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  
  Serial.begin(57600);
   
  WiServer.init(NULL);
  
  WiServer.enableVerboseMode(false);
  
  // Have the processData function called when data is returned by the server
  getWeather.setReturnFunc(processData); 

}


 // --- Function that process data from a .submit request
void processData(char* data, int len) {
      int myPointer=0, foundit=0;
      if (len > 0) { // if len of packet greater than 0 then do following
        memset(data, ' ', sizeof(data));  // initialize to empty
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read
          char theChar=data[ix]; // read 1 character
          if ((theChar=='|') || (foundit!=0)) { // found the pointer
            if((foundit!=0) && (theChar!='\n') && (theChar!='\t')) { // If foundit already set to true, and char isn't junk, then add char to wiDateTime
              data[myPointer] = theChar; // add qualified char to wiDateTime
              myPointer++; // increment wiDateTime pointer
            }
           foundit=1; // terminator was found so foundit = true
          }
        } // if the pointer wasn't found in this packet, then it'll do the same to the subsequent packets, until the pointer is found
        if (foundit!=0) {
          // The terminator was found, now split the string into light_sensor, door_sensor, lounge_pir, hallway_pir
          sscanf (data,"%[^','], %1[^',']", Temp, Rain);
         // the last variable is limited to the number of bytes expected, so that sscanf doesn't add extra bytes
                r = atoi(Rain);
                t = atoi(Temp);
                
                Serial.println(t);
                Serial.println(r);
     
         
         }  
      }  
      
  }
      
        
        
     
unsigned long updateTime = 0;

void loop() {
  
if(millis() >= updateTime)
{
 getWeather.submit();
 updateTime += 1000 * 30;
Serial.println("submitted"); 
}


 WiServer.server_task();
 
 
 while(millis() < updateTime)
 {
   
   if(t < 80 && t>60 && r == 0)
     {
       digitalWrite(blueLed, HIGH);
       digitalWrite(redLed, HIGH);
       digitalWrite(greenLed, LOW);
       Serial.println("1");
     }
     
    else if (t >=80 && r == 0)
     {
       digitalWrite(blueLed, HIGH);
      digitalWrite(redLed, LOW);
     digitalWrite(greenLed, HIGH);
     Serial.println("2");
     }

     
     
   }
  
 
 
}

Serial output:

submitted
submitted
submitted
submitted
submitted
submitted

Inside the while loop (while (millis() < updateTime), print r and t. Without knowing what value r and t have, how do you know that it is not working? Suppose r is 1. What does your code do? What if t is 55?

I had r and t printing up in the processData function, and it never printed anything, but I did what you said too, and it just printed zero's for both. It seems that whenever anything is in the loop except the submit and wiserver calls, the processData function isn't called correctly. So, I moved all my if/else statements into the end of the processData function, and things are working now.

However, I still don't know how to structure the code so I can do things with the LEDs that require loops, but still be able to break those loops to send another submit request to the server. How would you do it?

What happens if the stuff in loop comes before the submit and WiServer.server_task() calls?

Does setting WiServer.enableVerboseMode to true generate any useful output that might give a clue what is happening?

Same thing, I just get on “submitted” and then endless 0’s on the serial output. Verbose Mode true didn’t output anything at all.

Code to make sure I did it right:

void processData(char* data, int len) {
      int myPointer=0, foundit=0;
      if (len > 0) { // if len of packet greater than 0 then do following
        memset(data, ' ', sizeof(data));  // initialize to empty
        for (int ix=0; ix < len; ix++) { // count number of characters from the packet to read
          char theChar=data[ix]; // read 1 character
          if ((theChar=='|') || (foundit!=0)) { // found the pointer
            if((foundit!=0) && (theChar!='\n') && (theChar!='\t')) { // If foundit already set to true, and char isn't junk, then add char to wiDateTime
              data[myPointer] = theChar; // add qualified char to wiDateTime
              myPointer++; // increment wiDateTime pointer
            }
           foundit=1; // terminator was found so foundit = true
          }
        } // if the pointer wasn't found in this packet, then it'll do the same to the subsequent packets, until the pointer is found
        if (foundit!=0) {
          // The terminator was found, now split the string into light_sensor, door_sensor, lounge_pir, hallway_pir
          sscanf (data,"%[^','], %1[^',']", Temp, Rain);
         // the last variable is limited to the number of bytes expected, so that sscanf doesn't add extra bytes
                r = atoi(Rain);
                t = atoi(Temp);    
      }
    }    
  }        


void loop() {
  
 while(millis() < updateTime)
 {
   
  Serial.println(t);
  Serial.println(r);
   
   if(t < 80 && t >= 60 && r == 0)
     {
       analogWrite(redLed, 150);
       analogWrite(greenLed,0 );
       analogWrite(blueLed, 50);
      
     }
     else if(t >= 80 && r == 0)
     {
       analogWrite(redLed,255);
       analogWrite(greenLed,50 );
       analogWrite(blueLed,0);
       
      } 
      
      else if(t < 80 && t >= 60 && r == 1)
        {
          analogWrite(redLed, 0);
          analogWrite(greenLed, 50);
          analogWrite(blueLed, 100);
          
        }
        
        else if(t >= 80 && r ==1)
        {
           analogWrite(redLed, 200);
          analogWrite(greenLed, 0);
          analogWrite(blueLed, 200);
          
        }
 }    
  
if(millis() >= updateTime)
{
 getWeather.submit();
 updateTime += 1000 * 60;
Serial.println("submitted"); 
}


 WiServer.server_task();  
 
 
}