Open fredythegreat opened 10 months ago
I will be available next week, if I haven't answered, please ping me here. Thanks.
Meanwhile, please attempt to use the latest commit from master
branch, as it contains some fixes which are not included in the version that is installed by default using the IDE. Let me know if the problem persists.
So, i am trying to get a esp32cam module to run a web server via a LTE Router with UPnP. I have created a No-Ip Account and a hostname without ddns key for my project. The router has a working sim-card with internet flatrate. The problem is i am not getting a connection to no-ip and i have no idea, why. The code looks like this (UPnP Example):
/
Note: This example includes the library EasyDDNS. You'll have to add this package using your Arduino Library Manager. The purpose of this package is to publish your dynamic IP to a DDNS service that will allocate a human readable address to your current IP. If you do not need that, you can remove this dependency. /
include
include
include
include
include
include // see note above
const char ssid = "";
const char password = "";
define LISTEN_PORT 2222 // http://:/?name=
define LEASE_DURATION 36000 // seconds
define FRIENDLY_NAME "" // this name will appear in your router port forwarding section
define DDNS_USERNAME ""
define DDNS_PASSWORD ""
define DDNS_DOMAIN ""
TinyUPnP tinyUPnP(20000); // -1 means blocking, preferably, use a timeout value (ms) WebServer server(LISTEN_PORT);
const int led = 13;
void handleRoot() { digitalWrite(led, 1); server.send(200, "text/plain", "hello from esp32!"); digitalWrite(led, 0); }
void handleNotFound() { digitalWrite(led, 1); String message = "File Not Found\n\n"; message += "URI: "; message += server.uri(); message += "\nMethod: "; message += (server.method() == HTTP_GET) ? "GET" : "POST"; message += "\nArguments: "; message += server.args(); message += "\n"; for (uint8_t i = 0; i < server.args(); i++) { message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; } server.send(404, "text/plain", message); digitalWrite(led, 0); }
void setup(void) { pinMode(led, OUTPUT); digitalWrite(led, 0); Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.println("");
// Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP());
boolean portMappingAdded = false; tinyUPnP.addPortMappingConfig(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME); while (!portMappingAdded) { portMappingAdded = tinyUPnP.commitPortMappings(); Serial.println("");
}
Serial.println("UPnP done");
if (MDNS.begin("esp32")) { Serial.println("MDNS responder started"); }
server.on("/", handleRoot);
server.on("/inline", []() { server.send(200, "text/plain", "this works as well"); });
server.onNotFound(handleNotFound);
server.begin(); Serial.println("HTTP server started");
}
void loop(void) {
EasyDDNS.update(300000);
tinyUPnP.updatePortMappings(600000); // 10 minutes
server.handleClient();
delay(5); }
I was not sure which port to use so i chose 2222 not sure if thats the way to go. As all the DDNS Definitions are not used in the code i copied the code from the EasyDDNS page into my code:
EasyDDNS.service("noip"); EasyDDNS.client("DDNS_DOMAIN", "DDNS_USERNAME", "DDNS_PASSWORD");
The esp boots normally and in the serial monitor the last three lines say "UPnP done, MDNS responder started, HTTP Server started". The UPnP stuff seems to work and i am not really sure what i am doing wrong. Can anyone point me in the right direction? Thanks