ESP8266 get unread email count in gmail
Posted: Fri Nov 08, 2019 10:55 pm
Hi all,
I am very new to ESP8266 and following this tutorial
https://tttapa.github.io/ESP8266/Chap17 ... ifier.html
From this I am trying to get the unread email count from google. My code looks like
Didn't completed the function getUnread(). But as of now, always showing "connection failed" and returning -1.
Hardware : NodeMCU Amica (Has an ESP8266 Wifi Module)
IDE : Arduino latest version 1.8.10
Can anyone help ?
I am very new to ESP8266 and following this tutorial
https://tttapa.github.io/ESP8266/Chap17 ... ifier.html
From this I am trying to get the unread email count from google. My code looks like
Code: Select all
#include <WiFiClientSecure.h> // Include the HTTPS library
#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* host = "mail.google.com";
const char* url = "/mail/feed/atom";
const int httpsPort = 443;
const char* ssid = "BSNL";
const char* password = "PASSWORD123";
void setup() {
Serial.begin(115200);
delay(10);
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
}
void loop(){
int unread = getUnread();
Serial.print(unread);
}
int getUnread() {
WiFiClientSecure client; //connection
Serial.printf("Connecting to %s:%d ... \r\n", host, httpsPort);
if (!client.connect(host, httpsPort)) { // Connect to the Gmail server, on port 443
Serial.println("Connection failed"); // If the connection fails, stop and return
return -1;
}
}
Didn't completed the function getUnread(). But as of now, always showing "connection failed" and returning -1.
Hardware : NodeMCU Amica (Has an ESP8266 Wifi Module)
IDE : Arduino latest version 1.8.10
Can anyone help ?