Help with Blynk Server + SSL + NodMcu

Hello everyone.

I have my Blynk server working fine and in a simple way, but I can’t make it work using the “BlynkSimpleEsp8266_SSL.h” library.

This is my code:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "26d495c0..."; // My server

//char auth[] = "540aef59413..."; // Blynk Server

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXX";
char pass[] = "XXXXXXX";

BlynkTimer timer;

WidgetLED led1(V1);

void setup()
{
  // Debug console
  Serial.begin(9600);

  //Blynk.begin(auth, ssid, pass);
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8441);
  Blynk.begin(auth, ssid, pass, "mc-casainteligente.ddns.net",8441 );
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,xx,xx), 8441);

   while (Blynk.connect() == false) {
  Serial.println("Nao Conectado");
  }

  Serial.println("Conectado");

  timer.setInterval(1000L, blinkLedWidget);
}

// V1 LED Widget is blinking
void blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    Serial.println("LED on V1: on");
  }
}

void loop()
{
  Blynk.run();
  timer.run();
}

I get this on my monitor:

Capturar1

These are my configurations:

Capturar

pasta

server

I’ll be gratefull if someone could help me.

@mauroviana are you using 2.4.0-rc2 core as SSL was very flakey with 2.3.0? Still pushing an ESP to it’s limit’s doing SSL though.

I don’t see any cert on your site and I think you need a thumb / fingerprint to do the validation.

I would get up and running with SSL to Blynk’s server before attempting SSL to your own server.

Are you saying of the library? I have already finished the installation.

I use the “No-IP” DNS “mc-casainteligente.ddns.net

Ok but how can I make it? You can help with some instructions?

Yes it work perfectly but I would like have my own server.
I know it’s not so simple to make one, but I would try.

Can you tell me if something is missing on the hardware side?

I’m trying this sketch and I get the certificate successfully, but I can not read the virtual pin “V1”.

My goal is to have the ArduinoMega2560 pin value and write to NodeMcu, but I am not succeeding. Can someone tell me where I’m missing?

My hardware:

NodeMcu -> API -> ArduinoMega2560

/*
 *  HTTP over TLS (HTTPS) example sketch
 *
 *  This example demonstrates how to use
 *  WiFiClientSecure class to access HTTPS API.
 *  We fetch and display the status of
 *  esp8266/Arduino project continuous integration
 *  build.
 *
 *  Created by Ivan Grokhotkov, 2015.
 *  This example is in public domain.
 */

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

const char* ssid = "xxxxx";
const char* password = "xxxxx";

const char* host = "mc-casainteligente.ddns.net";
const int httpsPort = 8441;

// Use web browser to view and copy
// SHA1 fingerprint of the certificate
const char* fingerprint = "ff d5 9e 34 xx xx xx xx xx xx xx xx xx xx xx xx 15 1b 6b 3d";

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;
  }

  if (client.verify(fingerprint, host)) {
    Serial.println("certificate matches");
  } else {
    Serial.println("certificate doesn't match");
  }

  String url = "https://mc-casainteligente.ddns.net/4cb39a87c6b5xxxxxxxxxxxxxxb07bd/get/V1";
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "User-Agent: BuildFailureDetectorESP8266\r\n" +
               "Connection: close\r\n\r\n");

  Serial.println("request sent");
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println(" CI successfull!");
  } else {
    Serial.println(" CI has failed");
  }
  Serial.println("reply was:");
  Serial.println("==========");
  Serial.println(line);
  Serial.println("==========");
  Serial.println("closing connection");
}

void loop() {
}

Capturar

@mauroviana does https://mc-casainteligente.ddns.net/4cb39a87c6b5xxxxxxxxxxxxxxb07bd/get/V1 work in a web browser?

Yes. Sometimes I use from my PC.

Sim, não é certo?