How to Send E-mail using PIC Microcontroller and ESP8266

Sending-email-with-PIC

In this tutorial let us learn how to send E-mails from PIC Microcontroller using famous WiFi module the ESP8266. This tutorial uses PIC16F877A IC and MPLABX and XC8 compiler for programming.

At the end of this tutorial you will be able to send E-mail from any normal E-mail ID like Gmail, yahoo etc to any other E-mail ID. Hence this tutorial assumes that you have some basic knowledge on ESP8266-01 Modules and PIC Microcontrollers. If not, the following tutorials will help you

Getting your Hardware Ready:

The complete schematic of the project is shown below.

Circuit-for-Sending-Email-w

The LCD display is used here for debugging purpose. It is not mandatory for you to connect this. The program will work fine even without the LCD display. If you want to know more about the schematics you visit this tutorial. (Interfacing PIC with ESP).

You can simply assemble this circuit on a breadboard and then proceed with the programming.

Programming your PIC to send E-mail:

In order to send an E-mail from the ESP8266 a sequence of AT commands has to be sent to the ESP module. The following steps have to be followed to send an E-mail from ESP8266.

  1. Set the module in AP+STA (Access Point and station) mode
  2. Connect to an Access point to get internet connection
  3. Enable multiple connections
  4. Start a server on any specific port
  5. Establish a TCP connection  with SMPT2GO website
  6. Navigate to the Login section of the website
  7. Enter the E-mail ID and Password in base64 format
  8. Enter From mail ID
  9. Enter To mail ID
  10. Enter the Subject of the mail
  11. Enter the body of the mail
  12. Indicate the end of mail
  13. Send the mail
  14. Quit the TCP connection

It is a bit lengthy and tedious process but do not worry. I have simplified the process by creating a header file and you can use it directly by just calling some functions (explained below) which makes this task very easy. The complete code along with the header file can be downloaded from here.

Note: If you are using the code in a new project make sure you download the header file and add it in your project.

I have explained some important parts of the code below, the other parts are self explanatory. But if you have any doubts feel free to use the comment section.

for more detail:How to Send E-mail using PIC Microcontroller and ESP8266

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter