Trouble with WiFi and webhook code..

Hey guys, I need some help!
I recently bought a ESP8266-01 and a Arduino Micro and wanted to make a smart door opener using a ifttt webhook.
While the code has no errors, it doesnt work as intented.
I want the code to send the webhook data via serial to the micro and have it activate a relay.
After connecting to the Wifi with the configured IP it just does nothing...
I'll post the full code here including a debugging webhook site.
I guess it has something to do with the fact that its an https site and the functions say http..

Also I would like to set a Name that is displayed by my Internet router but my method doesnt seem to work either.

I am flashing the Code with this chip and the serial monitor works as intended except the first few characters are cut off but that doesnt matter...

Thanks in advance!

#include <ArduinoJson.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>


const char* ssid = "GUBANO";
const char* password = "*************";
const char* httprequestserver = "https://webhook.site/dc54e41a-d54d-44fd-942f-d93709e921df";
const char* DeviceName = "Doorlock Arduino"; //enter the Devicename shown in your router here. For best purposes set it to the projects name, you're building!
float checkspeed = 1; //in seconds!!
IPAddress ip(192, 168, 178, 200);

//Variables used throughout the programm
int adelay = checkspeed * 1000;

void setup() {

  Serial.begin(115200);
  Serial.println("Serial Startet... Can you see this?");
  // Serial.setDebugOutput(true);

  IPAddress gateway(192, 168, 178, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 178, 1);

  WiFi.hostname(DeviceName);
  delay(adelay*2);
  WiFi.config(ip, dns, gateway, subnet);
  delay(adelay*2);
  WiFi.begin(ssid, password);

  int Signalstrength = WiFi.RSSI();
  String SigStrength = String("Wifi Strength is" + Signalstrength);
  Serial.println(SigStrength);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Not Connected yet...");
    delay(adelay);
  }
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("Succesfully connected!");
    Serial.println("IP adress is:");
    Serial.println(WiFi.localIP());
  }
  if (WiFi.status() == WL_CONNECT_FAILED) {
    Serial.println("Connection can not be established. Try checking the password!");
    setup();
  }


}

void loop() {
  // wait for WiFi connection
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;  //Object of class HTTPClient
    http.begin(httprequestserver);
    int httpCode = http.GET();
    //Check the returning code
    if (httpCode > 0) {
      // Get the request response payload
      String payload = http.getString();
      // TODO: Parsing
      Serial.println(payload);
      http.end();   //Close connection
    }
    if (WiFi.status() == WL_CONNECTION_LOST) {
      Serial.println("Connection broke up... :(");
      Serial.println("Trying to reconnect!");
      setup();
    }

    delay(adelay);
  }
  else
  {
    Serial.println("No Wifi... Weird... The Code should not even be able to land here.... Thanks for using my script! :^)");
  }
}
  if (WiFi.status() == WL_CONNECT_FAILED) {
    Serial.println("Connection can not be established. Try checking the password!");
    setup();
  }

Calling setup() recursively is a BAD idea.

  if (WiFi.status() == WL_CONNECTED) {

Is it?

    int httpCode = http.GET();
    //Check the returning code
    if (httpCode > 0) {

Printing it might reveal a clue-by-four.

PaulS:

  if (WiFi.status() == WL_CONNECT_FAILED) {

Serial.println("Connection can not be established. Try checking the password!");
   setup();
 }



Calling setup() recursively is a BAD idea.



if (WiFi.status() == WL_CONNECTED) {



Is it?



int httpCode = http.GET();
   //Check the returning code
   if (httpCode > 0) {



Printing it might reveal a clue-by-four.

It does connect, I see it in my router but the webhook testserver does not report any get requests (what it should do) and the recursive setup is maybe bad but in this case it shouldnt be any bad because the problem is somewhere else but thanks, I'll remember that!

OK, The http.get request issues -1 wich is "no connection"

I updated the code to this and it still doesnt work...
to get the certificate I clicked in chrome on the lock in search bar when I was on the webhook server and selected the top one, created a k´copy of it with the second option and opened it as a text file.

#include <ArduinoJson.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>


const char* ssid = "*********";
const char* password = "*************";
const char* httprequestserver = "https://webhook.site/dc54e41a-d54d-44fd-942f-d93709e921df";

const char* https_certificate= \
"-----BEGIN CERTIFICATE-----\n" \
"MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" \
"MSQwIgY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sWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" \
"Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" \
"-----END CERTIFICATE-----\n";



const char* DeviceName = "Doorlock Arduino"; //enter the Devicename shown in your router here. For best purposes set it to the projects name, you're building!
float checkspeed = 1; //in seconds!!
IPAddress ip(192, 168, 178, 110);

//Variables used throughout the programm
int adelay = checkspeed * 1000;

void setup() {

  Serial.begin(115200);
  Serial.println("Serial Started... Can you see this?");
  // Serial.setDebugOutput(true);

  IPAddress gateway(192, 168, 178, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 178, 1);

  WiFi.hostname(DeviceName);
  delay(adelay*2);
  WiFi.config(ip, dns, gateway, subnet);
  delay(adelay*2);
  WiFi.begin(ssid, password);

  int Signalstrength = WiFi.RSSI();
  String SigStrength = String("Wifi Strength is" + Signalstrength);
  Serial.println(SigStrength);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Not Connected yet...");
    delay(adelay);
  }
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("Succesfully connected!");
    Serial.println("Local IP adress is:");
    Serial.println(WiFi.localIP());
  }
  if (WiFi.status() == WL_CONNECT_FAILED) {
    Serial.println("Connection can not be established. Try checking the password!");
    setup();
  }


}

void loop() {
  // wait for WiFi connection
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;  //Object of class HTTPClient
    http.begin(httprequestserver, https_certificate);
    int httpCode = http.GET();
                                                                 Serial.println(httpCode);                //for debugging
    //Check the returning code
    if (httpCode > 0) {
                                                                 Serial.println("httpCode > 0");                //for debugging
      // Get the request response payload
      String payload = http.getString();
      // TODO: Parsing
      Serial.println(payload);
      http.end();   //Close connection
    }
    if (WiFi.status() == WL_CONNECTION_LOST) {
      Serial.println("Connection broke up... :(");
      Serial.println("Trying to reconnect!");
      setup();
    }

    delay(adelay);
  }
  else
  {
    Serial.println("No Wifi... Weird... The Code should not even be able to land here.... Thanks for using my script! :^)");
  }
}

I might have read that the esp8266 library doesnt support https so Ill go for the normal lib now.

I always get -1 out of the http request. I tried it with a sha1 key, I tried it with the full sha256 key, I tried using different libraries, nothing works, infact when I use different libs I cant even compile because they use a completely different scheme.

Also it still doesnt display the right name in the router...
Pls help :frowning:

#include <ArduinoHttpClient.h>
#include <ArduinoJson.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>


const char* ssid = "*******";
const char* password = "**********************";
const char* httprequestserver = "https://webhook.site/dc54e41a-d54d-44fd-942f-d93709e921df";

const char* https_certificate = "DA C9 02 4F 54 D8 F6 DF 94 93 5F B1 73 26 38 CA 6A D7 7C 13";



const char* DeviceName = "Doorlock Arduino"; //enter the Devicename shown in your router here. For best purposes set it to the projects name, you're building!
float checkspeed = 1; //in seconds!!
IPAddress ip(192, 168, 178, 110);

//Variables used throughout the programm
int adelay = checkspeed * 1000;

void setup() {

  Serial.begin(115200);
  Serial.println("Serial Started... Can you see this?");
  // Serial.setDebugOutput(true);

  IPAddress gateway(192, 168, 178, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 178, 1);

  WiFi.hostname(DeviceName);
  delay(adelay*2);
  WiFi.config(ip, dns, gateway, subnet);
  delay(adelay*2);
  WiFi.begin(ssid, password);

  int Signalstrength = WiFi.RSSI();
  String SigStrength = String("Wifi Strength is" + Signalstrength);
  Serial.println(SigStrength);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Not Connected yet...");
    delay(adelay);
  }
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("Succesfully connected!");
    Serial.println("Local IP adress is:");
    Serial.println(WiFi.localIP());
  }
  if (WiFi.status() == WL_CONNECT_FAILED) {
    Serial.println("Connection can not be established. Try checking the password!");
    setup();
  }


}

void loop() {
  // wait for WiFi connection
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;  //Object of class HTTPClient
    http.begin(httprequestserver, https_certificate);
    int httpCode = http.GET();
                                                                 Serial.println(httpCode);                //for debugging
    //Check the returning code
    if (httpCode > 0) {
                                                                 Serial.println("httpCode > 0");                //for debugging
      // Get the request response payload
      String payload = http.getString();
      // TODO: Parsing
      Serial.println(payload);
      http.end();   //Close connection
    }
    if (WiFi.status() == WL_CONNECTION_LOST) {
      Serial.println("Connection broke up... :(");
      Serial.println("Trying to reconnect!");
      setup();
    }

    delay(adelay);
  }
  else
  {
    Serial.println("No Wifi... Weird... The Code should not even be able to land here.... Thanks for using my script! :^)");
  }
}
  if (WiFi.status() == WL_CONNECT_FAILED) {
    Serial.println("Connection can not be established. Try checking the password!");
    setup();
  }

You still have recursive code. If the password is wrong, calling setup() again isn't going to change the password, so calling setup() again is just plain stupid. Stop doing that.

    HTTPClient http;  //Object of class HTTPClient

That comment has NO value. Get rid of it.

Does the certificate really have all those spaces in it? Is it really a string?