Guru Meditiation Error with Email boilerplate example

I am a new Blynk user. I am using an AdaFruit Huzzah ESP32 module with Arduino
I got the quickstart template and device example to work.
I grabbed the Send Email code example from your code generation widget, copied it into a new sketch, changed the credentials: Template ID, Device Name and Auth Token to match a new template and new device I created. It compiles and I send the firmware to my board.
There is no email sent when my board connects even though I see the Ready Message like I see with the Quickstart device.
And the example has an interrupt feature that is supposed to send an email when a button is pushed.
I push the button for the pin I assigned (not the default digital pin 2) and then I get the Guru Meditation Error:

    11:26:49.055 -> [3834] Ready (ping: 16ms).
    11:26:49.126 -> Email should be sent here!
    11:26:54.175 -> Button is pressed.
    11:26:54.492 -> Guru Meditation Error: Core  1 panic'ed (Unknown reason). 
    11:26:54.492 -> 
    11:26:54.492 -> Core  1 register dump:
    11:26:54.492 -> PC      : 0x4008e2d2  PS      : 0x00060235  A0      : 0x8008d26e  A1      : 0x3ffbe99c  
    11:26:54.492 -> A2      : 0x3ffcd10c  A3      : 0x3ffb8890  A4      : 0x00000004  A5      : 0x00060223  
    11:26:54.492 -> A6      : 0x00060223  A7      : 0x00000001  A8      : 0x3ffb8890  A9      : 0x00000018  
    11:26:54.529 -> A10     : 0x3ffb8890  A11     : 0x00000018  A12     : 0x00000000  A13     : 0x00000000  
    11:26:54.529 -> A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x00000000  
    11:26:54.529 -> EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
    11:26:54.529 -> 
    11:26:54.529 -> 
    11:26:54.529 -> Backtrace:0x4008e2cf:0x3ffbe99c |<-CORRUPTED
    11:26:54.529 -> 
    11:26:54.529 -> 
    11:26:54.529 -> Core  0 register dump:
    11:26:54.529 -> PC      : 0x4008e453  PS      : 0x00060035  A0      : 0x8008ce97  A1      : 0x8008c5f1  
    11:26:54.567 -> A2      : 0x3ffbe9bc  A3      : 0x3ffcd10c  A4      : 0xffffffff  A5      : 0x00060023  
    11:26:54.567 -> A6      : 0x00060021  A7      : 0x0000cdcd  A8      : 0x0000abab  A9      : 0x800f9b09  
    11:26:54.567 -> A10     : 0x3ffbe9dc  A11     : 0x00000000  A12     : 0x3ffcd134  A13     : 0x3ffbf0e8  
    11:26:54.567 -> A14     : 0x00000000  A15     : 0x00000001  SAR     : 0x00000000  EXCCAUSE: 0x00000006  
    11:26:54.567 -> EXCVADDR: 0x00000000  LBEG    : 0x3ffc341c  LEND    : 0xcb36abd5  LCOUNT  : 0x00000000  
    11:26:54.601 -> 
    11:26:54.601 -> 
    11:26:54.601 -> Backtrace:0x4008e450:0x8008c5f1 |<-CORRUPTED
    11:26:54.601 -> 
    11:26:54.601 -> 
    11:26:54.601 -> 
    11:26:54.601 -> 
    11:26:54.601 -> ELF file SHA256: 0000000000000000
    11:26:54.601 -> 
    11:26:54.601 -> Rebooting...

Any ideas? I did not use Edgent_ESP32 code to initialize the board with the mobile app first.
This the boilerplate code I am using:

/*************************************************************

  Simple e-mail example

  App project setup:
    E-mail Widget

  Connect a button to digital pin 2 and GND
  Pressing this button will send an e-mail

  WARNING: You are limited to send ONLY ONE E-MAIL PER 5 SECONDS!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "redacted"
#define BLYNK_DEVICE_NAME           "redacted"
#define BLYNK_AUTH_TOKEN            "redacted"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
/* Set this to a bigger number, to enable sending longer messages */
//#define BLYNK_MAX_SENDBYTES 128

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

unsigned count = 0;

void emailOnButtonPress()
{
  // *** WARNING: You are limited to send ONLY ONE E-MAIL PER 5 SECONDS! ***

  // Let's send an e-mail when you press the button
  // connected to digital pin 2 on your Arduino

  int isButtonPressed = !digitalRead(2); // Invert state, since button is "Active LOW"

  if (isButtonPressed) // You can write any condition to trigger e-mail sending
  {
    Serial.println("Button is pressed."); // This can be seen in the Serial Monitor

    count++;

    String body = String("You pushed the button ") + count + " times.";

    Blynk.email("your_email@mail.com", "Subject: Button Logger", body);

    // Or, if you want to use the email specified in the App (like for App Export):
    //Blynk.email("Subject: Button Logger", "You just pushed the button...");
  }
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Send e-mail when your hardware gets connected to Blynk Server
  // Just put the recepient's "e-mail address", "Subject" and the "message body"
  Blynk.email("your_email@mail.com", "Subject", "My Blynk project is online.");

  // Setting the button
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), emailOnButtonPress, CHANGE);
}

void loop()
{
  Blynk.run();
}

Unfortunately, the Sketch Builder examples havent been fully updated to include the Blynk IoT methods for doing things like sending emails, sending notifications, accessing the RTC etc.

Also, I believe the way that interrupts are handled by the later version of the ESP32 core are different to how they were handled before, so if you’re running ESP32 core version 2.0.5 (the latest) then this may also be something to consider. You frind your core evrsion in the IDE - Tools > Board > Boards Manager > search for ESP32

Emails are now sent by logging an Event which has an e-mail notification attached…

https://docs.blynk.io/en/blynk.console/templates/events/custom-events/events-notification-settings?q=email+event

Pete.

Thanks Pete for the observation and suggestion. So I need to set up eventing first as a component of the template and then try.
Also I am running the latest version of the board manager: 2.0.5.
Do you or anyone who is Blynk guru have an example with sketch code to use to overcome this?
I was basically trying to duplicate a Fall Detector application that I saw on the web:
Fall Detector
This is from 2021 and lots has changed since then I guess for ESP32 support and Blynk.

Yes, you should probably read this, although it primarily focuses on notifications, but as that is part of what you want then the code examples should get you started…

Pete.

You should try

void IRAM_ATTR emailOnButtonPress()
{

}

Instead of:

attachInterrupt(digitalPinToInterrupt(2), emailOnButtonPress, CHANGE);

??

Instead of

void emailOnButtonPress()
{

OK, thanks. I will give that a try and report my results here.

1 Like

Maybe you will have to debouce using a flag if you still have issues.

When you use interrupts, there are a few things that you should keep in mind, like keeping the Interrupt Service Routine (ISR) as short as possible, avoiding delay and serial prints, not declaring any non-static variables inside the handler, etc.
Read this for more details
https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

1 Like