If anyone sees how to fix my problem ... Thanks in advance!#include <EMailSender.h> #include "HX711.h" #include "SD.h" #include "SPI.h" #include "RTClib.h" #include "Adafruit_Sensor.h" #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <Ethernet.h> // Ethernet or ethernet2 library only W5500 … #define DEFAULT_EMAIL_NETWORK_TYPE_ARDUINO NETWORK_W5100 uint16_t SMTP_PORT = 25; const char *smtp_server = "smtp.orange.fr"; const char *email_login = "xy@wanadoo.fr"; const char *email_from = "xy@wanadoo.fr"; const char *name_from = "roland"; const char *email_password = "password"; #define SECRET_MAC {0x90, 0xA2, 0xDA, 0x10, 0x40, 0x4F}// mac address Ardiuno mega #define pinCS_SD 4 // we reserve Pin 4 for the SD reader #define pinCS_ETH 10 IPAddress ip(192, 168, 1, 143); // The default IP address that the shield will take if the box does not assign an IP byte mac[] = SECRET_MAC; // The MAC address of the shield String Typefichier = ".csv"; //type of file that we want on SD attention if modification must be modified fileDescriptor[0].mime = "text/csv"; in the envoimail function! String NomFichierMensuel; //storage file name previous month EthernetClient client; File file; // Creating the file object named file Sd2Card card; int nbessai = 2; // number of attempts to send emails in case of failure … int a = 0; /* we configure the sender’s mailbox and the server !*/ EMailSender emailSend(email_login, email_password, email_from, name_from, smtp_server, SMTP_PORT); void setup() { Serial.begin(9600); //we initialize the serial monitor at 9600 bauds pinMode(53, OUTPUT); //mega card to be able to access SD and Ethernet at the same time must be activated /*Test to see if the SD card is working */ if (!card.init(SPI_HALF_SPEED, pinCS_SD)) Serial.println(F("problem!")); else Serial.println(F("Correct assembly and card present")); /* THE COMMISSIONING OF ETHERNET IS ATTACKED */ Ethernet.init(pinCS_ETH); // start the ethernet card on pin 10 char erreur = 0; erreur = Ethernet.begin(mac); // We try to start the Ethernet shield WITHOUT an IP address (therefore given via DHCP from the box) if (erreur == 0) { Ethernet.begin(mac, ip); // forcing the ip address if not acquired by box Serial.println(F("IP fixe")); } // end of if error getting dynamic IP! Serial.println(F("Init…")); delay(1000); //Give the shield a second to initialize } void loop() { if (a == 0) boolean retourmail = envoimail(3, "", 2); // send email swarming alert with 2 attempts to send email if (a == 1) boolean retourmail = envoimail(2, NomFichierMensuel, 1); //send mensual mail } boolean envoimail(int lequel, String NomFichierMensuel, int nbessai) { boolean piecejointe; String msgsujet; String msgcorps; switch (lequel) { case 1: { // sending mail theft piecejointe = 0; msgsujet = F("WARNING THEFT of your beehive in progress!"); msgcorps = F( "The weight sensor just dropped to less than 5kg, either the scale has a problem, someone is taking your hive away, or you take a thorough visit and test the function …"); break; } case 2: { //monthly email piecejointe = 1; msgsujet = F("Don’t panic, it’s the monthly statement"); msgcorps = "Please find attached the monthly statement " + NomFichierMensuel + " of beehive n° 1"; break; } case 3: { // sending email swarming… piecejointe = 0; msgsujet = F("CAUTION possible swarming"); msgcorps = F( " The weight sensor has just lost 5 kg quickly, either you intervene on the hive or there is swarming."); break; } } // end of switch // start of sending email EMailSender::EMailMessage message; // structure defined in EmailSender.h message.subject = msgsujet; message.message = msgcorps; EMailSender::FileDescriptior fileDescriptor[piecejointe]; // structure defined in EmailSender.h 2 = 2 attachments fileDescriptor[0].filename = NomFichierMensuel; fileDescriptor[0].url = NomFichierMensuel; fileDescriptor[0].mime = "text/csv"; fileDescriptor[0].encode64 = false; fileDescriptor[0].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD; EMailSender::Attachments attachs = { piecejointe, fileDescriptor }; // structure defined in EmailSender.h const char *arrayOfEmail[] = { "dupont@gmail.com", "abc@wanadoo.fr" }; EMailSender::Response resp = emailSend.send(arrayOfEmail, 2, message, attachs); Serial.print(F("Shipment status : ")); Serial.println(resp.status); Serial.print(F("resp Code: ")); Serial.println(resp.code); Serial.print(F("Description : ")); Serial.println(resp.desc); // redo an e-mail return test … if (nbessai > 0 && resp.code != 0) { EMailSender::Response resp = emailSend.send(arrayOfEmail, 2, message, attachs); Serial.println(F("we try again…")); } nbessai = nbessai - 1; Serial.println(F("send of mail")); return (resp.code); } //end of function send mail
Problem loop stop after my send email function
Hello, while waiting for a solution to my mail problem with orange, I am working on sending mail with gmail.
I’m trying to put your program in a function to integrate it into a connected hive program …
When I solicit this function (sending email) at the end of sending the main loop stops …
I don't understand why at the end of this function I don't go back to the main program ...
I isolated the function in question and I put it below ...