Device Disable by the endpoint

Hello to the whole thinger.io community.

I’m developing a project for my school’s final project, and I’m having some difficulties regarding the alerts created for email.
Going into details, my project is to build a weather station, from esp8266, having DHT11 sensor, wind speed sensor and wind direction sensor. After everything is in sync and fully working, I would create an alert system, to alert when the temperature, for example, was above 24 degrees, and send a notification to the email.
I managed to do this, the problem is that I received an email saying that my device was disabled due to an excessive call that failed.

First of all, how can I fix the problem in the code that call_endpoint stops running constantly without control and how do I activate my device again after replacing the code. Code below

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending and Receiving Thinger IO
// see here: https://www.youtube.com/watch?v=8jMr94B8iN0 to add NodeMCU ESP8266 library and board
//----------------------------------------Include Library
#include <ThingerESP8266.h>
#include <ESP8266WiFi.h>
#include "DHT.h"
//----------------------------------------

//----------------------------------------Thinger IO configuration
#define USERNAME "***************"
#define DEVICE_ID "Teste1"
#define DEVICE_CREDENTIAL "******************"
//----------------------------------------

#define ON_Board_LED 2  //--> Defining an On Board LED, used for indicators when the process of connecting to a wifi router. GPIO2 = D4.

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); //--> Initialize Thinger IO (ThingerESP8266)

//----------------------------------------SSID and Password of your WiFi Router/Hotspot.
const char* ssid="JJLESTOFOS"; // Nome do WIFI
const char* password="jjl0ur0est0f0$"; // Palavra-passe do WIFI
//----------------------------------------

//----------------------------------------DHT11 Sensor Configuration
#define DHTPIN D1 //--> Digital pin connected to the DHT sensor. D1 = GPIO5.
#define DHTTYPE DHT11 //--> DHT11

DHT dht11(DHTPIN, DHTTYPE); //--> DHT11 Sensor Initialization
//----------------------------------------

float temperature,humidity; //--> Variables for temperature and humidity data

#define LEDGreenPin D5 //--> Green LED pin. D5 = GPIO14.
#define LEDBluePin D6 //--> Blue LED pin. D6 = GPIO12

void setup() {
  // put your setup code here, to run once:

  pinMode(ON_Board_LED,OUTPUT); //--> On Board LED port Direction output
  digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board

  pinMode(LEDGreenPin, OUTPUT);
  pinMode(LEDBluePin, OUTPUT);

  WiFi.begin(ssid, password); //--> Connect to your WiFi router

  //----------------------------------------Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    //----------------------------------------Make the On Board Flashing LED on the process of connecting to the wifi router.
    digitalWrite(ON_Board_LED, LOW);
    delay(250);
    digitalWrite(ON_Board_LED, HIGH);
    delay(250);
    //----------------------------------------
  }
  //----------------------------------------
  
  digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router.

  thing.add_wifi(ssid, password); //--> Initialize wifi

  dht11.begin(); //--> Starts reading DHT11 Sensor
  
  //----------------------------------------Sends DHT11 Sensor data (Temperature and Humidity) to Thinger IO
  // Symbol or operator ">>" means to transmit data
  thing["dht11"] >> [](pson& out){
      out["temperatura"] = temperature;
      out["humidade"] = humidity;
  };
  //----------------------------------------

  //----------------------------------------Receive data from Thinger IO to turn on or off the LED
  // Symbol or Operator "<<" means to receive data
  thing["LEDGreen"] << digitalPin(LEDGreenPin);
  thing["LEDBlue"] << digitalPin(LEDBluePin);
  //----------------------------------------
}

void loop() {
  // put your main code here, to run repeatedly:
  
  // call always the thing handle in the loop and avoid any delay here
  thing.handle();
  
  //----------------------------------------To get temperature and humidity data from the DHT11 sensor
  temperature = dht11.readTemperature();
  humidity = dht11.readHumidity();
  //----------------------------------------

  pson data = dht11.readTemperature();
  if(dht11.readTemperature()>24){
    thing.call_endpoint("alerta_temp_email", data);
  }
};

Hi @Xavier_Brites,

The device is disabled due excessive calls, reading your code I can see that the uC is sending as much calls as it can, if temperature rises more than 24.

You need to ensure that this call is made just once to avoid get the device disabled.

Hope this helps.

I am still new in this world. Do you think you could help me solve the code, or how to make it stop so it only sends once?

Hi

I would do it by an histeresis and a boolean value, if it over 24 and false, send notification and set boolean to true (to avoid sending high temp multiple notifications) , if it drops below 22 and true send notification and set boolean to false (to avoid sending low temp multiple notifications).

Hope this helps.

Now I understand, thank you very much for your help. I hope that this way I can also help people with the same problem