Could not connect to the server, please check your network and your firewall rules

Hi, I´m trying to send data to Ubidots, but when I connect my ESP32S to serial port I have the message “Could not connect to the server, please check your network and your firewall rules” and the datas doesnt send.
this is my code, please help me.

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <Ubidots.h>

//Credenciales WiFi
#define WIFI_SSID "INTERNET_CNT YEPEZ"
#define WIFI_PASSWORD "Titokeluckyfer12345"

//Variables reseteo de funcion millis
long previousMillis = 0;

//Control de motor
int ON = 14; //BOTON DE ON/OF
int lect_M = 0;
int MOTOR = 27;

//Control de dispensador (Rele e IR)
int lect_IR = 0;
const int pinIR = 25;
int bomba = 26;
int cont = 0;
int seg = 0;

//Variables sensor Ultrasónico (Medidor de cantidad)
volatile const int Trigger = 0; 
volatile const int Echo = 15;
volatile long t = 0; //timepo que demora en llegar el eco
volatile long d = 0; //distancia en centimetro
volatile int porcent = 0; 
int lect_ULTRA = 0; 
const int ON_ULTRA = 19; //Switch para presentar cantidad restante del envase

//Variable de la alarma (buzzer)
int buzzer = 33;

//Credenciales Proyecto Ubidots
#define UBIDOTS_TOKEN "BBFF-73VWnb4z2xgXxb5FtmkBGNcmvqL2uP"
#define DEVICE_LABEL "dispensador-1"
Ubidots ubidots (UBIDOTS_TOKEN, UBI_HTTP);

//Constantes del servidor Ubidots
#define LAB_CANT "canti"
#define LAB_VASOS "vasos"
#define LAB_pH "pH"

#define I2C_ADDR 0x27
LiquidCrystal_I2C lcd(I2C_ADDR,2, 1, 0, 4, 5, 6, 7);

void setup() {
  Serial.begin(115200);
  
  //Pines para motor
  pinMode (MOTOR, OUTPUT);
  pinMode(ON, INPUT); 

  //Pines para dispensador (Rele e IR)
  pinMode(pinIR , INPUT);
  pinMode(bomba, OUTPUT);

  //Pines para el sensor Ultrasónico 
  pinMode(Trigger, OUTPUT); //pin como salida
  pinMode(Echo, INPUT);  //pin como entrada
  pinMode(ON_ULTRA, INPUT);
  digitalWrite(Trigger, LOW);//Inicializamos el pin con 0
  
  //Pin buzzer (alarma)
  pinMode(buzzer, OUTPUT);

  lcd.begin(16,2);
  lcd.setBacklightPin(3,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.setCursor(0, 0);
  lcd.home();
  lcd.clear(); 

  
  //Configuración WiFi
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Conectado a la red: ");
  while (WiFi.status() != WL_CONNECTED){
    Serial.print(".");
    delay(250);
  }
  Serial.println();
  Serial.print("MAC: ");
  Serial.println(WiFi.macAddress());

  //Inicializa conexión hacia FIREBASE
  Serial.println("Conectando a Ubidots...");
  dots.wifiConnect(WIFI_SSID, WIFI_PASSWORD);
  dots.setDebug(true);
  
}

void loop() {
  unsigned long currentMillis = millis();
  //Código del motor
  lect_M = digitalRead(ON);
  if (lect_M == HIGH){
    on_MOTOR();
  }
  else{
    off_MOTOR();    
  }
  
   //Código de Rele e IR 
  lcd.setCursor(0, 0);
  lcd.print("  Esperando....");
  lcd.setCursor(0, 1);
  lcd.print(" Acerque el vaso");
  lect_IR = digitalRead(pinIR);  //lectura digital de pin
  
  if (lect_IR == LOW){
    delay(25);
    vaso_DETECT();  
    if (seg >= 20){  
      retire_VASO();
    }
  }
  CONTADOR_VASOS();
  
  if (seg >= 20 || lect_IR == HIGH) {
    esperando_VASO();   
  } 
  delay(400);

 //Para el sensor Ultrasónico
  datos_ULTRA();
  lect_ULTRA = digitalRead(ON_ULTRA);
  if (lect_ULTRA == HIGH){
    delay(25);
    muestra_CANTIDAD(); 
  }
  
  //Alarma envase casi vacío 
  if (porcent <= 40){
    llenar_ENVASE();
  }
}





/*
 * FUNCIONES A SER LLAMADAS POR LAS CONDICIONES 
 * VOID LOOP MÁS PRESENTABLE Y VACÍO
 */


//Encendido y apgado del motor
void on_MOTOR(){
  delay(25);
  digitalWrite(MOTOR, LOW);
  delay(25);
}

void off_MOTOR(){
  delay(25);
  digitalWrite(MOTOR, HIGH);
  delay(25);
}

//Detección y llenado del vaso
void vaso_DETECT(){
  digitalWrite(bomba, HIGH);
  lcd.backlight();
  lcd.display();
  lcd.clear();   
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > 1000){
    previousMillis = currentMillis; 
    seg ++;
    lcd.setCursor(0, 0);
    lcd.print(" Aprox. 13 seg. ");
    lcd.setCursor(0, 1);
    lcd.print("Ha(n) pasado: ");        
    lcd.print( seg);
  if (seg > 20){
    lcd.setCursor(9, 1);
    lcd.print("00");
    }
  }
}

//Función conteo de vasos
void CONTADOR_VASOS(){
  if (lect_IR != HIGH){
    cont++;
    ubidots.add(LAB_VASOS, cont);
    bool buffersent = false;
    buffersent = dots.send(DEVICE_LABEL);
  } 
}

//Función retirar el vaso
void retire_VASO(){
  digitalWrite(bomba, LOW);
  lcd.setCursor(0, 0);
  lcd.print(" Retire el vaso");
  delay(2000);
  lcd.noDisplay();
  lcd.noBacklight();
}

//Función detectando vaso
void esperando_VASO(){
  unsigned long currentMillis = millis();
  seg = 0;
  delay(25);
  digitalWrite(bomba, LOW);
  delay(20);
}

//Lectura del sensor Ultrasónico
void datos_ULTRA(){
  digitalWrite(buzzer, LOW);
  digitalWrite(Trigger, HIGH);
  delay(10);        //Enviamos un pulso de 10us
  digitalWrite(Trigger, LOW); 
  t = pulseIn(Echo, HIGH);      //obtenemos el ancho del pulso
  d = t/58.2;                     //escalamos el tiempo a una distancia en cm
  porcent = map (d, 4, 26, 100, 0);
  millis();                     //Reatardo para que el sensor recolecte bien los datos
}

//Muestra cantidad del envase
void muestra_CANTIDAD(){
  digitalWrite(buzzer, LOW);  
  lcd.backlight();
  lcd.display();
  lcd.clear();
  cont++;
  ubidots.add(LAB_CANT, porcent);
  bool buffersent = false;
  buffersent = dots.send(DEVICE_LABEL);
  lcd.setCursor(0,0);
  lcd.print(" Cant. restante");
  lcd.setCursor(6,1);
  lcd.print(porcent);
  lcd.print(" %"); 
  delay(500); 
}

//Lectura <= 10% del envase
void llenar_ENVASE(){
  lcd.backlight();
  lcd.display();
  lcd.clear();
  ubidots.add(LAB_CANT, porcent);
  bool buffersent = false;
  buffersent = dots.send(DEVICE_LABEL);
  lcd.setCursor(0,0);
  lcd.print(" Cant. restante");
  lcd.setCursor(6,1);
  lcd.print(porcent);
  lcd.print(" %"); 
  delay(500);
  digitalWrite(buzzer, HIGH);
  delay(300);
  digitalWrite(buzzer, LOW);
  delay(50);
}

Hi @kev98y,

Thank you for sharing your question with the community,

Based on the code, the error seems to be related to the two following lines, you should use ubidots instead of dots

Please refer to the following article where you can find examples and how to use the library.

I will be attentive in case you have further questions.

Have a nice day!
-Isabel