Hello and welcome to my first Instructable.
I will show you how to send emails from any ESP8266 wifi module using Gmail server.
This instructable relies on Arduino core for ESP8266 WiFi chip,
which makes a self-contained microcontroller from it (no need of AT commands and master devices).
You can connect sensors and get notified by email about changes.
Before we begin
Required hardware:
- Any ESP8266 (I’m using ESP8266-07 ebay link).
- In my case USB UART Board(I’m using FT232RL FTDI Serials Adapter Module ebay). Not needed if your board has usb port.
- Some jumper cables.
- WIFI router of course.
List may be incomplete.
Required software:
- Arduino Software
- Arduino core for ESP8266 WiFi chip
- Sketch with project and test code (ESP8266_Gmail_Sender.zip).
Step 1: Gmail account setup
We are going to use SMTP to send messages.
Using SMTP Authentication we provide only email and password,
by default Google uses more complex verification methods so we need to change settings.
Go to your Google account settings and enable “Allow less secure apps” at the bottom of the page.
This mean apps only need your email and password when login to your gmail account.
If you concerned about security, just use different account.
Step 2: Edit sketch
I wrote a little sketch which send one test message to check if all works as should.
When all software downloaded and installed:
- Unzip ESP8266_Gmail_Sender.zip
- Find and open ESP8266_Gmail_Sender.ino
- Set your wifi access point name (SSID) and password. Should be like this:
-
const char* ssid = "MyWiFi";<br>const char* password = "12345678";
- In setup() function find
-
<strong>if(gsender->Subject(subject)->Send("boris.on@live.com", "Setup test"))<br></strong>
- first parameter of Send function is recipient email, second message text.
Change recipient from > to your email which will receive message.
Subject function is optional! Subject sets once and stored until you change it.
You can send mails without subject or if it already set
-
<strong>gsender->Send(to, message);</strong>
-
- Now open Gsender.h tab
- We need Base64 encoded email address and password of gmail account which will be used to send emails.
You can use base64encode.org for encoding, result must be something like:
-
const char* EMAILBASE64_LOGIN = "Y29zbWkxMTExMUBnbWFpbC5jb20=";<br>const char* EMAILBASE64_PASSWORD = "TGFzZGFzZDEyMzI=";
- Now set FROM field.
-
const char* FROM = "your_email@gmail.com";
- That`s all for this part.
- Step 3: Code uploading and testing
Save changes. Don`t forget to set your board in Tool menu.
Upload sketch to your ESP8266 board.
Open Serial monitor, board will print log messages.
That`s all I hope you will receive “Message send.”. Thanks.
Leave a Reply
You must be logged in to post a comment.