Arduino library for sending email and SMS from nothing but the ESP8266!

#AlertMe Library

Did you know your ESP8266 could send Email and SMS without any special hardware or paid services like Twilio?

With AlertMe, your ESP8266 project can:

  • Email you when an external sensor triggers, such as a button press, tilt, vibration, or any other sensor/interrupt combo you can think of!
  • Text you when a motion sensor detects something it shouldn't!
  • Quickly connect to any WiFi network, with hotspot configuration of your notification settings!
  • Send Email through the provider of your choice via SMTP! (*Only Gmail tested so far)
  • Send SMS through your cell phone carrier's SMS-to-Email portal! (Over 200 worldwide carriers supported)

Contents


Usage

Here's a quick example, which will automatically reconfigure as a configuration hotspot if it can't connect to a saved network/server:

#include "AlertMe.h"
AlertMe alert;
void setup() {
  alert.connect();
  alert.send("AlertMe Demo", "This is an email demonstrating the AlertMe library!", "[email protected]");
}
void loop(){}

This would send an email with your subject line "AlertMe Demo", with the contents you specify, to [email protected]! Simple as that.

Reliability and Security

No need to worry about reliance on any extra services but your email provider. If you're pairing this with Gmail, you can pretty well guarantee 100% uptime through them. As far as security goes, the data is sent over HTTPS/SSL to the SMTP server of your choice, which is encrypted as WPA2 traffic on your network, and stored quite securely with any name-brand email service!

HOWEVER, The credentials you input for WiFi and SMTP are stored away inside the ESP8266's filesystem, which could be read back if your ESP8266 is stolen by a stranger who just-so-happens to know how to access the SPIFFS filesystem on this type of microcontroller and knows that the credentials are in base64. Highly unlikely, but a possibility. Be safe! Your smartphone being stolen is a much more likely and threatening scenario than this.

I highly recommend creating an email account specifically for your ESP8266.

Free SMS Capability

Most cell carriers are including unlimited text nowadays due to the focus being on data plans, so if you have a smartphone with a data plan, odds are that unlimited texts are already included in the cost! This is done through an Email-to-SMS portal provided by almost every carrier in the world. For example:

Phone Number Carrier SMS Portal
555-123-4567 Verizon [email protected]
123-456-7890 AT&T [email protected]
555-555-5555 Sprint [email protected]

These special email addresses forward the mail recieved to the specified phone number!

A list of over 200 supported worldwide carriers can be found at the bottom of this page:
https://martinfitzpatrick.name/list-of-email-to-sms-gateways/


Disclaimer

Don't use this for spam. Don't you do it. I assume no responsibility for how this is used.


Installation

With Arduino Library Manager:

  1. Open Sketch > Include Library > Manage Libraries in the Arduino IDE.
  2. Search for "AlertMe", (look for "Connor Nishijima") and select the latest version.
  3. Click the Install button and Arduino will prepare the library and examples for you!

Manual Install:

  1. Click "Clone or Download" above to get an "AlertMe-master.zip" file.
  2. Extract it's contents to the libraries folder in your sketchbook.
  3. Rename the folder from "AlertMe-master" to just "AlertMe".

Dependencies

You'll need these two libraries already installed for AlertMe to work:


Email Configuration

To send Email or SMS, you'll need to get SMTP access with your email provider. A quick Google search for "[Provider] SMTP port" will usually get you what you need. There's too many to cover here, so I'll go over Gmail usage:

SMTP Port: 465
SMTP Server: smtp.gmail.com
SMTP Email: your Gmail address
SMTP Password your Gmail password

ALMOST DONE!

These are the four inputs you need to enter on the AlertMe configuration hotspot, but you're not quite done yet. To allow your Gmail account to accept SMTP connections from your ESP8266, follow the steps of this instruction guide: https://support.google.com/accounts/answer/6010255

After you've entered your config info, and set up your Gmail account for SMTP access, be sure to reboot your ESP8266 and check that the configuration is saved!

TIP: place alert.debug(true) above alert.connect() and watch the Serial monitor for connection reports!


Functions

AlertMe alert;

This initializes the AlertMe library after import. "alert" can be any word you want, as long as it's reflected in the rest of your code.

void alert.connect(bool debug_wifi = false);

When called, the underlying WiFiManager code first checks to see if there's a saved WiFi network to continue connecting to. If it can't, your ESP8266 will reconfigure as a hotspot named "AlertMe Configuration" and prompt you to enter your WiFi/SMTP credentials. (Once connected, visit http://192.168.4.1 in your browser to do this)

After a WiFi connection is established, AlertMe makes a test authorization with your email provider over SMTP. If it can't connect or authorize, AlertMe falls back to hosting the configuration hotspot again until this step is successful. debug_wifi can be enabled to see WiFiManager information output to Serial.

const char* alert.send(String subject_line, String message, String destination);

This is where the magic happens. This function sends an Email/SMS of subject_line/message to destination! If successful, the word "SENT" is returned. If not, an error message from SMTP is returned, such as "Could not connect to mail server".

void alert.debug(bool enabled);

When enabled, SMTP and filesystem debug information will be sent over Serial.

void alert.config();

Allows you to call up the config hotspot at all, a good practice would be adding this at the top of your setup() function:

if(digitalRead(config_pin) == LOW){
    alert.config();
}

void alert.reset(bool format == false);

Used to reset WiFi configuration, and delete saved SMTP credentials from the ESP8266. Good for if you're giving this microcontroller to someone else!

const char* alert.get_error();

Used to get the last SMTP error encountered, such as if you just used an alert.send() destined for an invalid email address.


Contributing

Any advice or pull requests are welcome. :)


License and Credits

Developed for free by Connor Nishijima in response to cheap proprietary greed

AlertMe includes modified code from these sources:
Borya's Gmail Sender: http://www.instructables.com/id/ESP8266-GMail-Sender/
Adam Rudd's arduino-base64: https://github.com/adamvr/arduino-base64

Released under the GPLv3 license.

Owner
Lixie Labs
I'm a bit of a cheapass. You might know me from adding motion detection, SMS alerts and 10-bit analog audio to various Arduino platforms with NO extra hardware.
Lixie Labs
Comments
  • URL redirection is corrupted

    URL redirection is corrupted

    Everytime I connect to the AP it redirects me to http://smtp.gmail.com192.168.4.1/. Even if I try to enter the IP manually.

    Debug lines:

    *ALERTME: Mounting SPIFFS...
    *ALERTME: Mounted file system.
    *ALERTME: Reading alertme_config.json...
    *ALERTME: Opened config file!
    *ALERTME: Parsed config:
    {"smtp_server":"smtp.gmail.com","smtp_port":465,"smtp_email":"****","smtp_password":"****"}*ALERTME: 
    
    *ALERTME: Connecting to your WiFi network...
    
    Failed to connect to WiFi, config AP active at: 'AlertMe Configuration'
    

    Any idea how to resolve it?

  • Specify library dependencies in library.properties

    Specify library dependencies in library.properties

    Specifying the library dependencies in the depends field of library.properties causes the Arduino Library Manager (Arduino IDE 1.8.10 and newer) to offer to install any missing dependencies during installation of this library.

    arduino-cli lib install will automatically install the dependencies (arduino-cli 0.7.0 and newer).

    Reference: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

  • Fixed issue #4

    Fixed issue #4

    This is my proposed fix for issue #4 which causes URL redirection to become corrupted. I fixed it by allocating memory to the smtp_server variable, which was being initialized to an empty string. When the domain is copied to smtp_server is overwrites the memory after it, which is what causes the corruption. By allocating a fixed amount of memory to it we can prevent this.

  • Can't get it to work with default settings

    Can't get it to work with default settings

    I tried it with my own smtp info, no luck. I could not connect to my smtp.

    Next, I created a gmail email address, set less security access, rebooted, etc. I used the default gmail settings. Altered the program with my email and sms info. Wemos D1 would mount the SPIFFS file (all data read correctly), connect to my WiFi network, and fail to connect to smtp.

    Connecting to WIFI/SMTP...*ALERTME: Mounting SPIFFS... *ALERTME: Mounted file system. *ALERTME: Reading alertme_config.json... *ALERTME: Opened config file! *ALERTME: Parsed config: {"smtp_server":"smtp.gmail.com","smtp_port":465,"smtp_email":"[email protected]","smtp_password":"RXXXXXX"}*ALERTME:

    *ALERTME: Connecting to your WiFi network... *ALERTME: Testing SMTP connection... *ALERTME: Connecting to : *ALERTME: smtp.gmail.com Failed to connect to SMTP, config AP active at: 'AlertMe Configuration'

    I just go round and round back to the config AP. Cannot connect to smtp. Am I missing something?

    email_and_sms.zip

  • AlertMe Configuration has password

    AlertMe Configuration has password

    Hello, it seems after the first time I configure the device and power cycle it, there is a password set on the access point. Can anyone help me understand what this password is so I can gain access again?

  • example doesn't seem to use the config pin properly

    example doesn't seem to use the config pin properly

    in line 66 of the example, you have if(config_pin == LOW){ // Short pin to GND for config AP now shouldn't that be if (DigitalRead(config_pin)==LOW){

    ?

  • Constant resets after second upload.

    Constant resets after second upload.

    Arduino IDE 1.8.4 on a Wemos D1 R2

    Library compiles and works as expected, configuration via 'AlertMe Configuration' AP with scanning is smooth (and is a fantastic feature!) and I am receiving the emails/texts just fine. The issue comes if I modify the Arduino sketch and re-upload...this causes the board to go into a (seemingly) endless cycle of resets. Power cycling doesn't fix it, nor does uploading the example sketch, nor does shorting the config_pin (which I defined as D6 on the Wemos).

    What does reliably work is to upload an empty SPIFFS image and then re-upload the sketch.

    Once things go pear-shaped, this is what I see in the serial monitor:

    ⸮���������������������������������������������������������������⸮HP⸮⸮`M,⸮⸮lCd⸮⸮Hh⸮⸮⸮⸮⸮ѥ⸮⸮⸮to WIFI/SMTP...
    Exception (28):
    epc1=0x4000bf3c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
    
    ctx: cont 
    sp: 3fff2390 end: 3fff2610 offset: 01a0
    
    >>>stack>>>
    3fff2530:  3fff2568 3fff4008 3fff3f5c 4020831d  
    3fff2540:  3ffea0d8 00000000 000003e8 00000100  
    3fff2550:  3fff3f1c 3fff2ff4 3fff2568 3fff3ff6  
    3fff2560:  3fff3fc2 feefef0a 3ffe98d8 3fff15e4  
    3fff2570:  3fff3ffc 00000200 3fff34ac 4021102b  
    3fff2580:  3ffe90e0 00000000 3fff1118 3fff15e4  
    3fff2590:  3fffdad0 00000000 3fff1118 40208d1e  
    3fff25a0:  3fffdad0 3fff1118 3fff1528 40206afc  
    3fff25b0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25c0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25d0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25e0:  feefeffe feefeffe feefeffe 3fff15e4  
    3fff25f0:  3fffdad0 00000000 3fff15dd 40210514  
    3fff2600:  feefeffe feefeffe 3fff15f0 40100718  
    <<<stack<<<
    R⸮⸮Lv⸮0UHh⸮⸮⸮⸮⸮ѥ⸮⸮⸮to WIFI/SMTP...
    Exception (28):
    epc1=0x4000bf3c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
    
    ctx: cont 
    sp: 3fff2390 end: 3fff2610 offset: 01a0
    
    >>>stack>>>
    3fff2530:  3fff2568 3fff4008 3fff3f5c 4020831d  
    3fff2540:  3ffea0d8 00000000 000003e8 00000100  
    3fff2550:  3fff3f1c 3fff2ff4 3fff2568 3fff3ff6  
    3fff2560:  3fff3fc2 feefef0a 3ffe98d8 3fff15e4  
    3fff2570:  3fff3ffc 00000200 3fff34ac 4021102b  
    3fff2580:  3ffe90e0 00000000 3fff1118 3fff15e4  
    3fff2590:  3fffdad0 00000000 3fff1118 40208d1e  
    3fff25a0:  3fffdad0 3fff1118 3fff1528 40206afc  
    3fff25b0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25c0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25d0:  feefeffe feefeffe feefeffe feefeffe  
    3fff25e0:  feefeffe feefeffe feefeffe 3fff15e4  
    3fff25f0:  3fffdad0 00000000 3fff15dd 40210514  
    3fff2600:  feefeffe feefeffe 3fff15f0 40100718  
    <<<stack<<<
    
    

    (lather, rinse, repeat)

    I will have a different ESP8266 board soon to test against. I'll let you know if it produces different results.

  • loading smtp port and server

    loading smtp port and server

    Is there a way to load the smtp port and server information without having to do it through the AP? I am developing a board for automating a daily function and if something goes wrong with the equipment I would like to send a SMS and your library is exactly what I am looking for. I just don't want to incorporate the AP function. I am going to have all of the details of my machine set up in a web page, including the local wifi set-up and I would include all of the information you require, I save it to eprom for safety.

    Thanks

Related tags
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32

The Approximate Library The Approximate library is a WiFi Arduino Library for building proximate interactions between your Internet of Things and the

Dec 7, 2022
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485

ABB Aurora protocol You can refer the complete documentation on my site ABB Aurora PV inverter library for Arduino, esp8266 and esp32 I create this li

Nov 22, 2022
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)

Arduino Websockets A library for writing modern websockets applications with Arduino (see prerequisites for supported platforms). This project is base

Dec 26, 2022
This Arduino IDE for ArduCAM ESP8266 UNO Board with Integrated ArduCAM Library and Examples
This Arduino IDE for ArduCAM ESP8266 UNO Board with Integrated ArduCAM Library and Examples

ArduCAM_ESP8266_UNO Please use josn board manager script from http://www.arducam.com/downloads/ESP8266_UNO/package_ArduCAM_index.json to download ESP8

Jan 7, 2023
Anto client library for ESP8266-Arduino

Anto client library for ESP8266-Arduino ESP8266-AntoIO provides common and easy way to connect your ESP8266 to Anto.io IoT platform service. Stable ve

Dec 1, 2021
Arduino Arduino library for the CloudStorage server project. The library provides easy access to server-stored values and operations.

Arduino-CloudStorage Arduino/ESP8266 library that allows you to easly store and retreive data from a remote (cloud) storage in a key/value fashion. Cl

Jan 30, 2022
A library to simplify the process of getting and storing data to Antares IoT Platform through HTTP on ESP8266.
A library to simplify the process of getting and storing data to Antares IoT Platform through HTTP on ESP8266.

Antares ESP8266 HTTP This is the documentation for Antares ESP8266 library. This library is meant to simplify the process of retrieving and deploying

Jul 2, 2021
A library to simplify the process of subscribing and publishing data to Antares IoT Platform through MQTT on ESP8266.
A library to simplify the process of subscribing and publishing data to Antares IoT Platform through MQTT on ESP8266.

Antares ESP8266 MQTT A Library to simplify the process of MQTT publication and subscription to Antares IoT Platform using ESP8266. This library works

Mar 9, 2022
Library for ESP32 and ESP8266 to work with the Fernando K app

App Fernando K This library is meant to work with the Fernando K app https://play.google.com/store/apps/details?id=com.appfernandok https://apps.apple

Aug 5, 2020
Library for auto Light Emitting Diode (LED) control based on the timer function of the ESP8266

Library for auto Light Emitting Diode (LED) control based on the timer function of the ESP8266. The purpose is to have LED running for their own without the need to to such things like blinking on your own.

Jan 18, 2022
Arduino library for making an IHC in or output module using an Arduino

Introduction This is an Arduino library for making an IHC in or output module using an Arduino. (IHC controller is a home automation controller made b

Mar 26, 2020
ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT Cloud

ArduinoIoTCloud What? The ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT

Dec 16, 2022
ESP8266 examples and toolchain setup

README These apps accomplish the following: -- ESP8266-EVB-blinkLED : Blink by green LED on ESP8266-EVB -- arduino_style : -- esphttpd : Advanced web-

Oct 22, 2022
Simple web interface builder for esp8266 and ESP32
Simple web interface builder for esp8266 and ESP32

GyverPortal Простой конструктор веб интерфейса для esp8266 и ESP32 Простой конструктор - делаем страницы без знаний HTML и CSS Библиотека является обё

Jan 8, 2023
Connecting an ESP8266 to a Google Calendar service to turn an useless "On Air" sign into a smart meeting indicator
Connecting an ESP8266 to a Google Calendar service to turn an useless

ESP8266-GoogleCalendar Intro I had an useless "On Air" sign hanging around my home, and I thought it would be cool to connect it to my Google Calendar

Jan 20, 2022
ESP8266 MQTT Sharp-fu-y30 air purifier controller
ESP8266 MQTT Sharp-fu-y30 air purifier controller

ESP8266 MQTT Sharp-fu-y30 air purifier controller Disclaimer Note: if you decide to do those changes to your air purifier, you take all the responsibi

Dec 6, 2022
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

107-Arduino-NMEA-Parser Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages. This library

Jan 1, 2023
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.

Adafruit IO Arduino Library This library provides a simple device independent interface for interacting with Adafruit IO using Arduino. It allows you

Dec 23, 2022
Arduino library for SPI and I2C access to the PN532 RFID/Near Field Communication chip

Adafruit-PN532 This is a library for the Adafruit PN532 NFC/RFID breakout boards This library works with the Adafruit NFC breakout https://www.adafrui

Dec 23, 2022