I cannot connect to pushbullet from ESP8266

425 views Asked by At

I have followed several instructions to connect from ESP8266 to Pushbullet Here is a code snippet

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

const char* ssid = ".......";
const char* password = ".......";
const char* host = "api.pushbullet.com";
const int httpsPort = 443;
const char* PushBulletAPIKEY = "..............."; //get it from your pushbullet account

// Use web browser to view and copy
// SHA1 fingerprint of the certificate
const char* fingerprint = "2C BC 06 10 0A E0 6E B0 9E 60 E5 96 BA 72 C5 63 93 23 54 B3"; //got it using https://www.grc.com/fingerprints.htm

void setup() {
  Serial.begin(115200);
  Serial.println();

  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

It fails on !client.connect(host, httpsPort).

Using a browser api.pushbullet.com:443 fails

https://api.pushbullet.com returns a nice JSON code

Is it possible to connect using https://api.pushbullet.com ?

Is there a port issue?

Help appreciated.

PS From RPI

curl --header 'Access-Token: o.abcdefghijklmnopqrstuvwxyz' \ https://api.pushbullet.com/v2/users/me

works like a charm.

1

There are 1 answers

0
HvdW On

Solution found.

   // Use WiFiClientSecure class to create TLS connection
   WiFiClientSecure client;
   Serial.print("connecting to ");
   Serial.println(host);
   if (!client.connect(host, httpsPort)) {
     Serial.println("connection failed");
     return;
   }

Add: <client.setInsecure();> just below: WiFiClientSecure client;

Found it somewhere on GitHub, just sharing to help other find the solution.