These are chat archives for Links2004/arduinoWebSockets

4th
Jan 2017
Mehrdad K
@mkeyno
Jan 04 2017 10:29
Markus I set the debug to all but not more much information , however I found after sending new sensor data the async websocket disconnected, folksinging is the loop code
void loop() 
{ 

 if( (millis()-last_reading)>period*1000)
  {
       String s="THL$";
    bool new_val=false;
    int sum=0;
    for(int i=0;i<10;i++) {sum += map(analogRead(A0), 0,1023,0,99);delay(1);  }
    Light=sum/10;
     s+="L"+String(Light);
     if(L_light!=Light  ){ L_light=Light; new_val=true;} // check if new sensor data 
    byte h = dht.readHumidity(); 
    byte t = dht.readTemperature();
     if (!isnan(h)&& !isnan(t)&& h>0 && t>0 ) // sensor data valid 
     {  
       s+="H"+String(h);
       if(L_humid!=h && h< 100)           {  L_humid=h; new_val=true;}   
        s+="T"+String(t);
       if(L_temp!=t  && abs(L_temp-t)< 5 ){ L_temp=t;new_val=true;} //    

       if( new_val) 
       {
          Serial.println("send ws humid="+s);
        // ws.text(wsNumber, s.c_str());
         ws.textAll(s);
        // after sending websocket  disconnected 
       }
       last_reading= millis();

     }
  }

}
do you have any idea where might problem initiated ?