Update_2: No change after Update_1, same error. I still have to comment either email, I2C, or Temperature out, that the other two can work.

Update_1: I'm also using a DS18B20 with #include <DallasTemperature.h> and #include <OneWire.h>. If I comment Temperatures_Sens.begin(); in Setup() out, the problem is solved as well. I excluded Dallas now and wrote my own code. Let's see, on a naked ESP32 it works... I will test later...

Original Post: I'm facing a really hard nut. It's a weird issue, at least for me. I'm reading data via I2C and want to send them via email. Therefore I have two functions. The code compiles normally and I can upload it. But after that the ESP32 immediately restarts without even going through the setup(). But if I mark //Wire.requestFrom(PCF8591, 2); or //MailClient.sendMail(&smtp, &mail); as a comment, the program runs perfectly, well without the functionality of the comment. I'm really LOST and it keeps me busy for days already. I would be very grateful for any help that would solve my problem.

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
mode:DIO, clock div:2
entry 0x400805e4

Here are my functions:

#include <ESP_Mail_Client.h> //mobizt/ESP Mail Client@^3.4.19
#include <Wire.h>

int readAnalogFromPCF8591(int channel) {  
   Wire.write(0x40 | channel);  

   Wire.requestFrom(PCF8591, 2); -> Option 1 to comment out

   if(Wire.available() > 0){Wire.read();}
   if(Wire.available() > 0){
     int value = Wire.read();
     return value;}   
   return -1;}

void SendEmail(const char* subject, const char* content){
    if(WiFi.status() == WL_CONNECTED){
        session.server.host_name = smtpServer;
        session.server.port = smtpServerPort;
        session.login.email = emailSender;
        session.login.password = emailSenderPassword;
        session.login.user_domain = "";
        session.secure.startTLS = true;
        mail.sender.name = "Sensor";
        mail.sender.email = emailSender;
        mail.subject = subject;
        mail.addRecipient("Recipient", emailRecipient);
        mail.text.content = content;
        mail.text.charSet = "us-ascii";
        mail.text.transfer_encoding = Content_Transfer_Encoding::enc_7bit;

        MailClient.sendMail(&smtp, &mail); -> Option 2 to comment out


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.