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
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
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.beginTransmission(PCF8591);
Wire.write(0x40 | channel);
Wire.endTransmission();
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;
smtp.setTCPTimeout(10);
smtp.connect(&session);
MailClient.sendMail(&smtp, &mail); -> Option 2 to comment out
}