[SOLVED] ESP8266 resets while is waiting for serial data

Hy, I would like to send data to Ubidots platform. The data are received by the
ESP8266 through the serial interface. I have already managed strings with standard
Arduino and now I am playing with the ESP8266 stand alone programmed with the Arduino Ide.
I don’t understand why the ESP8266 resets if I put the following instruction:while(character_read !=‘b’);
I would like to use this instruction in order to beginto acquire serial data
I have also tried to move the instruction to the loop program but I see the same problem
Below is the Arduino code and the error that the ESP8266 returns

#include "UbidotsMicroESP8266.h"
#define TOKEN  "KAHI9rZ36jAceKQVv8Mvi2hg7FD9MW"  // Put here your Ubidots TOKEN
#define WIFISSID "xxx"
#define PASSWORD "yyy!"

Ubidots client(TOKEN);
int pompa;
char character_read;
void setup(){
  pinMode(2,OUTPUT);
    Serial.begin(9600);
    delay(10);
    character_read=Serial.read();
    while(character_read !='l');
  //Serial.println("OK");
    client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){
  
  
      //float value = analogRead(A0);
    client.add("voltage_battery", 12);
    client.add("Temperature", 12);    
    client.sendAll(true);
     pompa=client.getValue("586e140b76254216ca49b981");
    if(pompa==1)digitalWrite(2,HIGH);
    else digitalWrite(2,LOW);
}

Soft WDT reset

ctx: cont
sp: 3ffef490 end: 3ffef670 offset: 01b0

stack>>>
3ffef640: 3fffdad0 00000000 3ffee614 40202048
3ffef650: feefeffe feefeffe 3ffee638 40204224
3ffef660: feefeffe feefeffe 3ffee650 40100718
<<<stack<<<

Hi @gmarocc,

The device should always be connected first, then in the loop is where you should watch the trigger character come to you to send the data.

At this line you enter to a infinity loop and memory is overflowing:

while(character_read !='l');
 //Serial.println("OK");
   client.wifiConnection(WIFISSID, PASSWORD);

We modified your code, take a look of it.

#include "UbidotsMicroESP8266.h"
#define TOKEN  "Toke_here"  // Put here your Ubidots TOKEN
#define WIFISSID "xxx"
#define PASSWORD "yyyy"

Ubidots client(TOKEN);
int pompa;
char character_read;

void setup(){
    pinMode(2,OUTPUT);
    Serial.begin(9600);
    delay(10);
    client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){
    
    character_read=Serial.read();
    if(character_read !='l'){
    delay(1000);
    }
    //float value = analogRead(A0);
    client.add("voltage_battery", 12);
    client.add("Temperature", 12);    
    client.sendAll(true);
     pompa=client.getValue("variable_ID");
    if(pompa==1)digitalWrite(2,HIGH);
    else digitalWrite(2,LOW);
}

Regards