Let's look at the hardware setup for this project. Though Adafruit HUZZAH or NodeMCU are perfectly suitable boards to complete this project, I chose to design my own board with NodeMCU firmware to better understand the ESP module. Below is the schematic of my design.

For the power supply, I have multiple connection options on-board. I have a USB connector as well as 2-pin header to power up the board. The ~5 V DC power supply is regulated to 3.3 V for the ESP using LM317. If you are doing something similar, remember to adjust the 2k trim pot to set the required VDD for the ESP without the JP5 jumper, else you risk smoking out the ESP. A big 470 uF cap is added to act as a secondary battery if the power supply (should be able to at-least source 500 mA) temporarily fails to source enough current while transmitting/receiving WiFi signals.

The connections for the ESP-12 module are pretty straight-forward. The DSLEEP jumper enables the deep-sleep option of the ESP with power consumption in uA's, while the FLASH jumper is used to update the ESP with NodeMCU's awesome LUA-based firmware. Initially, I was inclined towards Arduino-based ESP, but I had a tough and unsuccessful time trying to get the Arduino to recognize my ESP with the home-built USB-UART converter. As I was able to easily flash my ESP with NodeMCU's 0.9.5 build 20150318 firmware, the entire project uses LUA-based functions. The LUA syntax is quite easy and the many helper functions available all over the net is quite handy to complete the project in quick time.

For the software-side of things, I wanted to keep the code simple without comprising the security of accessing your Gmail account. A very convenient way of doing this is to use the power of Google Spreadsheets. Google provides a set of API functions through their Apps Script developer platform to embed simple functions related to your Gmail account inside a google spreadsheet.

An example of this can be found here.

The process of creating a google spreadsheet that logs the number of unread emails in your Gmail account can be summarized as follows:

1. Create a new google spreadsheet in your google drive folder.

2. Goto Tools -> Script editor

3. Add some basic code as shown below:

function processInbox() {
        var unreadMessages = 999;
        unreadMessages = GmailApp.getInboxUnreadCount();
4. Create a trigger for the above function.

Goto Resources -> Current project's triggers & set a time-driven every-minute timer on the above function.

5. Go-back to the spreadsheet and publish it to the web using the File -> Publish to the web option. Remember to check the option which says "Automatically republish when changes are made" .

The above 5 steps, if done correctly will create a google spreadsheet that is automatically updated every minute with the number of unread messages in your Gmail account as the first cell of the spreadsheet.

Note: Google will perform a 1-time authentication with your Gmail credentials, the every first time the excel-script is executed.

Google also provides another powerful method of accessing the just created spreadsheet using the web browser with many different options.

For example: Below link prints the contents of the A1 cell of the spreadsheet in the web browser.


This is where I resort to some not-so-cool hacks to complete the project. Though NodeMCU provides an API to access HTTPS websites, I decided to use a ThingSpeak HTTP App to convert the HTTP Secure google spreadsheet web link to a HTTP version. This reduces my struggle with the software coding and enables easy integration with the ESP.
The procedure is quite simple:
1. Create an account on the ThingSpeak website.
2. Configure the ThingSpeak HTTP App with the above web-based google spreadsheet link.
3. Use the generated ThingSpeak HTTP weblink in...

Read more »