I have a problem receiving the email Endpoint

I have a problem with the email endpoint. I can’t get it to work properly.

When the requirement to activate the endpoint is met, I only receive the mail sometimes. For example, out of 10 times that I activated the trigger manually, I only received the email once.

I have a flow meter that I use to confirm that the sprinkler system has been activated. I don’t need to send any data in the body of the email. I just need the mail to arrive confirming that the irrigation has been carried out.

The endpoint is created correctly in Thinger.io because sometimes I get the mail. The code I use is the following:

if(valor_sensor[4] != 0){
        Serial.println("Caudal distinto de cero");
        thing.call_endpoint("email_caudal");
}

Any help is welcome.
Greetings.

Hi,
I guess you need to control how often is the endpoint called, as is coded, when valor_sensor[4] != 0 it will call the endpoint as fast as it can, more than 1000 times in a second, so the server surely will block the device.

if(valor_sensor[4] != 0 && sendMail){
        Serial.println("Caudal distinto de cero");
        thing.call_endpoint("email_caudal");
        sendMail = 0;
}

WIth the boolean sendMail flag, it will call the endpoint just once, you just need to set the flat to 1 in other part of the code, by another condition , for example valor_sensor[4] == 0 or by time, or a combination.

Hope this helps.

Hello,
I have tried what you have suggested to me to use a boolean variable to ensure that the send only occurs once and the same thing keeps happening to me. It does not send the email most of the times the event is activated and sometimes when it is activated the email is received a few hours later.
This code snippet only runs once when I send the data to thinger.

int myNum = valor_sensor[4].toInt();
if(myNum != 0){
Serial.println(myNum);
Serial.println(“Caudal distinto de cero”);
thing.call_endpoint(“caudal”);
}

And this is the output that the sketch produces with the thinger DEBUG active.

12:15:55.248 → Origen: CC
12:15:55.281 → 22.20;59.77;993.06;560.83;468;3.98;-80
12:15:55.314 → 468
12:15:55.314 ->Caudal distinto de cero
12:15:55.347 → [THINGER] Writing bytes: 13 [OK]
12:15:55.380 → Conectando a orangeworld [OK]
12:16:01.209 → Conectando a api. thinger. io [OK]
12:16:02.236 → Enviando datos json… {“Temperatura”:22.20,“Humedad”:59.77,“Presion”:993.06,“Lumens”:560.83,“Caudal”:468,“Bateria”:3.98,“RSSI”:-80}
12:16:03.825 → api. thinger. io desconectado
12:16:04.554 → orangeworld desconectado
12:16:04.554 →
12:16:04.719 → [NETWORK] Starting connection…
12:16:04.819 → [NETWORK] Connecting to APN…
12:16:09.223 → [NETWORK] Connected!
12:16:09.256 → [_SOCKET] Connecting to iot.thinger. io:25200…
12:16:09.323 → [_SOCKET] Using secure TLS/SSL connection: no
12:16:10.415 → [_SOCKET] Connected!
12:16:10.415 → [THINGER] Authenticating. User: ******* Device: ESP32
12:16:10.481 → [THINGER] Writing bytes: 42 [OK]

Greetings

Hi,

Ok as you present it, I would check if the device is connected to the cloud before send the email, check this post

I havent tested connecting by GSM, but would give a try.

Hope this helps.