Any idea why?
After the lines
if (sendEmailFlag) {
sendEmail();
sendEmailFlag = false; // Reset the flag after sending the email
}
it's also disconnected from MQTT brocker and stuck in that loop:
void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
if (client.connect("ArduinoNano33IoTClient", mqtt_user, mqtt_password)) {
Serial.println("connected");
client.subscribe(subscribe_topic);
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
delay(5000);
}
}
}