Utilizing Email End Point

Well done @alvarolb ! It is working as it should…

Saludos!

1 Like

hi everyone,
I got a problem here. I use NodeMCU V2,previously i try any codes (without endpoint),there’s no error. But after i added an endpoint and can sent 1-2 emails, suddenly may device disconnected/offline. i think my internet connection, but i try browse any websites, no problem. Then i use another NodeMCU, there’s no changes. The last way,i made a new device id, and it works. After i try sent email,it happened again, my device id such like blocked,unused. :sob::sob:
This my code :

#define EMAIL_ENDPOINT1 “pintu_1”

#define DOOR_PIN D1
#define WINDOW_PIN D2
#define DHTPIN D3
#define DHTTYPE DHT11
#define ALARM_PIN D4

String door;
String window;
String kit;
float temp;

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

DHT dht(DHTPIN, DHTTYPE);

void setup() {
dht.begin();
pinMode(DOOR_PIN, INPUT);
pinMode(WINDOW_PIN, INPUT);
pinMode(DHTPIN, INPUT);
pinMode(ALARM_PIN, OUTPUT);

thing[“pintu 1”] >>(pson& out){ out = (door); };
thing[“pintu 2”] >>(pson& out){ out = (window); };
thing[“dht11”] >> (pson& out){ out = temp; };
thing[“dapur”] >>(pson& out){ out = (kit); };
thing[“alarm”] <<(pson& in){
if(in.is_empty()){
in = (bool) digitalRead(ALARM_PIN);
}
else{
digitalWrite( ALARM_PIN, in ? HIGH : LOW);
}
};

thing.add_wifi(SSID, SSID_PASSWORD);
}

void loop() {
thing.handle();
int baca1 = digitalRead(DOOR_PIN);
int baca2 = digitalRead(WINDOW_PIN);

//pembacaan sensor pada Pintu
if (baca1!=HIGH){
thing.call_endpoint(EMAIL_ENDPOINT1, “door”);
door = “Pintu 1 Terbuka!!!”;
}else{
door = “Aman.”;
}

//pembacaan sensor pada Jendela
if (baca2!=HIGH){
window = “Pintu 2 Terbuka!!!”;
}else{
window = “Aman.”;
}

//pembacaan sensor DHT11
float t = dht.readTemperature(); //Membaca suhu dalam satuan Celcius

temp = t;
if (temp>40){
kit = “Dapur Kebakaran!!!”;
}else{
kit = “Aman.”;
}

}

i got an email from no-reply@thinger.io. It said

Your device Tugas_Akhir has been disabled due to excessive call fails. This often happens when your device calls your resources (endpoints or buckets) at inappropriate rate. Please, verify your device code.

my question is : which real problem??

  1. my code,cause i use String data, not Value.
  2. my internet connection, cause i use wireless internet (wifi), so it’s not stable.

thanks for reply, sorry for my bad english. :pray::pray::pray:

Is your code, not by the variable kind you are using, is the rate that the endpoint is called.

Is important to made the call just one time, by your code you are calling it at the speed that the microcontroller can when the condition “baca1!=HIGH” is present… Thats why the device become blocked

You need to limit the frequency with which you call the endpoint, I think I read it somewhere (I do not remember the specific amount of time should be waited between calls), but totally sure you are breaking it as how is the endpoint called.

so the problem is the code??i must set the limit frequency for calling the endpoint,could you remember the link you mean??i need it so much,i’m newbie here, :pray::pray::pray:

but its no connection with the widget at dashboard,right? cause i set the refresh rate for that widget by sampling for every 1 second,

You must set the frequency in code, there is no field to establish this, the link doesn’t says how to do it.

I don’t know if you understand how the microcontroler works, in the example that you posted, when the condition “baca1!=HIGH” is true, and the microcontroler can run this routine more than 10k times in one second…

You should asure by any method that it run just one time, I use a flag for this as this example:

if (baca1!=HIGH && mailFlag)
{
thing.call_endpoint(EMAIL_ENDPOINT1, “door”);
door = “Pintu 1 Terbuka!!!”;
mailFlag=0;
}

And you should set the “mailFlag” again somewhere else in the code, I dont know your process and have no idea where is appropiate to do it.

Hope this helps

1 Like

okay,i’ll try that one.
thank you very much.

i’m confused,i have no idea. Just like what u said, i need to find a method so it run just one time. I just using flag which you exemplify before. And it same,my device id still blocked,although i receive that notification emails. Have you any other ideas @ega ??

The device is becoming blocked because you are seting the “mailFlag” again in the wrong place, the routine I gave you will run just one time as max, and it is running the “if” with the call to endpoint routine several times.

You need to establish where is the best place to set this flag again, I recommend to do it in another natural routine of the process, in the code.

1 Like