Connect to the microcontroller directly from the world. Is this possible?

I have an ESP32 microcontroller that runs a mini web server. It is used to control the barrier. You approach the barrier, connect to it as a WiFi point, log in via IP, and click open. This is very inconvenient, especially if there are many people with access. Is it possible to make access directly from the world?

#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>

WebServer server(80);

bool needsOpened = false;
bool realOpened = false;
...
void setup() {
...
  Serial.println("Run web server");

  server.on("/wicket/open", [] {
    needsOpened = true;
    Serial.println("OPEN Barrier");
    redirect("/");
  });
  server.on("/wicket/close", [] {
    needsOpened = false;
    Serial.println("CLOSE Barrier");
    redirect("/");
  });
  server.on("/",  indexPage);

  server.begin();
}
1 Like

Yes if the ESP32 is connected to your network

You will need to open a port on your router to allow access to it from outside and redirect access to that port to the webserver on your ESP32

NOTE that this may not be a good idea as you are creating a hole in your router firewall

could you implement a smartphone app which on app startup does this sequence automatically?