I am trying the example email notifier and haven’t had any luck in getting it to work. I’ve tried my main email (herb@hwblair.com) and my alternate, without any success.
any help would be appreciated.
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my auth code";
void emailOnButtonPress()
{
// *** WARNING: You are limited to send ONLY ONE E-MAIL PER MINUTE! ***
// 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
{
BLYNK_LOG("Button is pressed."); // This can be seen in the Serial Monitor
Blynk.email("herb_blair@yahoo.com", "Subject: Test", "Test Email");
}
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "MYSSID", "MYPASSword");
while (Blynk.connect() == false) {
// Wait until connected
}
// 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("herb_blair@yahoo.com", "test", "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();
}
Make sure you have the email widget in your app and are not sending an email more then once every 15 seconds. You could be getting button bounce causing multiple email attempts?
You are constantly disconnecting… probably due to the repetitive email attempts. Look for button debouncing solutions (Google button debounce) to implement into your sketch.
@Herb_Blair Your code looks different than the example on the sketch builder, very close, but still different. Try using it as is, and just put your email, wifi information and auth token in the appropriate places.
I’m not using any of the button code.
in set up I check for the flag, if not set then I send the email and set the flag
if set, do nothing.
that’s about as simple as I can get it.